Sorry, my answer was really too short and incorrect.
While I mean multiplication of the transformations, instead I put the transform of a point. Also, I assume you have operations on your rotation structure defined (inversion,multiplication,rotation).
Hence, by writing “rot * some_vector” I mean the operation of rotation that your structure delivers, not a per-component multiplication.
Suppose you have the following functions defined for a rotation object:
“Rotate(rot,loc)” - to rotate a vector (or a point)
“Inverse(rot)” - to inverse the rotation
“Multiply(r1,r2)” - to combine rotations.
The corresponding routines for the whole transformation object (whatever name you give to it) can be written as follows:
Transform((loc,rot,scale),pos) = Rotate(rot,pos)*scale+loc;
Inverse((loc,rot,scale)) = ( Rotate(Inverse(rot), loc/scale), Inverse(rot), 1/scale );
Multiply((l1,r1,s1),(l2,r2,s2)) = (Rotate(r1,l2)*s1+l1, Multiply(r1,r2), s1*s2 );
If you have that implemented, the change of parenting is trivial:
New_local(object) = Multiply( Inverse(Wolrd(new_parent)), World(object) );