Jump to content
  • Advertisement
Sign in to follow this  
muhkuh

decomposing an affine transformation matrix

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, in my modelling format (.x) there are 4x4 matrices for the skeletal animation of the bones. So I think they are affine transformation matrices. I need to decompose these into translation, rotation and scaling components. I did some googling but didn't find a working algorithm or source code. Could somebody point me in the right direction and tell me what's the exect term to search for or even how this is done? I would naivly just take the 4th colum as the translation component and the upper left 3x3 part might be the rotation*scaling. So When rotating the 3 axis vectors and looking how their length has changed would give me the scaling factors that need to be removed from the 3x3 matrix to get the pure rotation component that I can convert to a quaternion. Any suggestion or hints welcome :-) Regards, Markus

Share this post


Link to post
Share on other sites
Advertisement
Thank you. Seems to be what I'm looking for. I've not enough time to read the paper thoroughly but I've got 2 questions about the source code:

What's this "stretch rotation" quaternion for? Can I just take the translation, scaling factors, essential rotation and interpolate the first two linearly, the last by angle? Is this "stretch rotation" a concatenated rotation and scaling?

Share this post


Link to post
Share on other sites
I don't know if this will help, but I posted a solution to the special case of scale->rotate>translate in this thread. Note that I haven't tested this yet so I can't guarantee its correctness.

I think the example in the thread refers to a D3D matrix, so you'll have to transpose the solution if you're using column vectors.

Share this post


Link to post
Share on other sites
Quote:
Original post by muhkuh
Thank you. Seems to be what I'm looking for. I've not enough time to read the paper thoroughly but I've got 2 questions about the source code:

What's this "stretch rotation" quaternion for? Can I just take the translation, scaling factors, essential rotation and interpolate the first two linearly, the last by angle? Is this "stretch rotation" a concatenated rotation and scaling?


In practice, the quaternions are interpolated (lerp, slerp, squad, etc.), and the vectors are lerp'd. The interpolated values are then converted back into an affine matrix. decomp_affine() is used in 3DSMax (see the SDK docs for more info):

Quote:

For a full discussion of this decomposition see Graphics Gems IV - Polar Matrix Decomposition by Ken Shoemake. ISBN 0-12-336155-9.

T F R U K U'

T - translation matrix
F - either an identity matrix or negative identity matrix
R - rotation defined by Quat q.
U - rotates you into the coordinates system where the scaling or stretching is done
K - scaling matrix
U' - inverse of u.


See also page 6, "Conclusions", from the Paper link above:

Quote:

With the assistance of Polar Decomposition, a non-singular
4 × 4 homogeneous matrix M can be factored into
meaningful primitive components, as

M = PTRNS,

where P is a simple perspective matrix, T is a translation
matrix, R is a rotation matrix, N is ±I, and S is a symmetric
positive definite stretch matrix. The stretch matrix can
optionally be factored, though not uniquely, as UKUT,
where U is a rotation matrix and K is diagonal and positive.
For a 4×3 affine matrix the perspective factor can be
dropped; and for a 3×3 linear matrix, so can the translation.
Also, N can be multiplied into S if desired.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!