# affine decomp

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

## Recommended Posts

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)

##### Share on other sites
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.

##### Share on other sites
thanks for the great answer :)

rate++

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 17
• 14
• 10
• 9
• 11
• ### Forum Statistics

• Total Topics
634094
• Total Posts
3015498
×