affine decomp

Started by
1 comment, last by rfterdarc 17 years, 3 months ago
This has prob been asked before... If i have: M = ScaleMatrix * RotationMatrix * TranslationMatrix (Left Handed) How can i extract the scale vector, rotation quat? (translation vector is obvious)
Advertisement
The scaling factors are the sizes of the heterogeneous vectors constituting the top-left 3x3 block. Dividing these vectors so that each is unitary, you're left with a rotation matrix. For (a column-vector) example:

The rotation-scaling-translation matrix:
a11 a12 a13 a14a21 a22 a23 a24a31 a32 a33 a34 0   0   0   1
Translation vector = (a14, a24, a34)

The rotation-scaling matrix:
a11 a12 a13 0a21 a22 a23 0a31 a32 a33 0 0   0   0  1
XScale = sqrt(a11² + a12² + a13²)
YScale = sqrt(a21² + a22² + a23²)
ZScale = sqrt(a31² + a32² + a33²)

The rotation matrix:
a11/XScale a12/XScale a13/XScale 0a21/YScale a22/YScale a23/YScale 0a31/ZScale a32/ZScale a33/ZScale 0    0          0          0      1
Now, calculating the rotation quaternion is a little more involved, so I'll link you to this FAQ.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
thanks for the great answer :)

rate++

This topic is closed to new replies.

Advertisement