Matrix stacks

Started by
3 comments, last by Mort 18 years, 7 months ago
I've built at graphics engine where each object in the engine has its own 4x4 transformation matrix (Translation, rotation and scaling). Objects can be grouped together in a parent/child relationship, so that moving an arm will also move its hand along. This is done using matrix stacks to multiply each child matrix with its parent matrix in order to produce a combined matrix. Now the problem I have now is that when I attach a child object to its parent, I want the combined matrix to become the same result as the child matrix itself is. This is done to maintain the position, rotation and scaling of the child object, so that these parameters do not change when the child is attached to its parent. In order to do this, I need to derive a new matrix for the child object, so that the new child matrix multiplied with the parent matrix will equal the old child matrix. Can anyone tell me how to derive such a matrix ?
- Mort
Advertisement
If:

A is the known parent matrix
B is the unknown matrix converting from parent space to child space
C is the known child matrix

then (assuming transformations are applied like this - matrix*local_vector = world_vector)

A B = C

pre-multiply by A-1 (inverse of A)

A-1 A B = A-1 C

so B = A-1 C

If A is just rotation and translation finding its inverse is much simpler than finding the general inverse of a 4x4 matrix - should also be the case with scaling I assume.

That was the same formula I tried to use, but it is not giving me the correct result. When calculating the combined matrix, rotation and scaling is identical to the new child matrix (B in your sample), but translation coordinates are different.

I'm thinking it's because the translation part of the new child matrix is being translated in the wrong direction due to the rotation part of the parent matrix (A in your sample).
- Mort
Did you perhaps forget to reverse the order on the component matrices after taking their inverse? If you rotate->scale->translate then you untranslate->unscale->unrotate.
Keys to success: Ability, ambition and opportunity.
Actually I took the inverse Translation, inverse Rotation and inverse Scaling matrix and applied to the child. The child then combines these in the order Scaling * Rotation * Translation * Parent (The Parent matrix consist of it's Scaling * Rotation * Translation too).
- Mort

This topic is closed to new replies.

Advertisement