Global to local rotation
I'm trying to get an object to latch onto another by changing it's parentage in the node tree, the two objects having different orientations. I got the parentage thing worked out in a previous project, and got the vector translation worked out pretty quickly, so that it's position doesn't change at the instant of the node tree change. However, I've spent hours and hours trying to get the rotation right. Either it translates the global rotations over to it's new local axes, or it just assumes a seemingly random rotation. I've been reading about transforms and Eulers til my ears ring, but I just seem to be going around in circles.
How do you rotate an object in it's new local space so that it assumes the same global orientation that it had before?