# Gettint datas from a transformation matrix

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

## Recommended Posts

Hi! I vould like to get datas from the transformation matrix, such as position (ok, it's simple), scaling (separated by the 3 axis) and rotation (angles, vectors). So, i have the model: (Direct3D) class mdl { D3DXMATRIX m; D3DXVECTOR3 pos; D3DXVECTOR3 forward; D3DXVECTOR3 up; D3DXVECTOR3 scaling; ... }; It's okay, when i want to get the matrix from the vectors (i know, the scaling isn't a vector, but i decided to store it this way), but i want it reverse (sorry about the poor language knowledge). I want to get the other datas from the matrix. With D3DXMatrixDecompose it is possible to separate each transformation into separate matrices, this way i can get the simplier datas, but how can i get the rotation? Thx for help

##### Share on other sites
I think the following will work. Assuming that the matrix represents the sequence scale->rotate->translate:

1. Extract translation directly as t = (m41, m42, m43).

2. Extract the orientation basis vectors as:

x = (m11, m12, m13)
y = (m21, m22, m23)
z = (m31, m32, m33)

3. Take the lengths of the basis vectors to find the scale factors.

4. Divide the basis vectors by their lengths to normalize them.

5. Use the appropriate algorithm to convert the basis to a quaternion, axis-angle pair, Euler angle triple, or other rotation representation of your choice.

• ### What is your GameDev Story?

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

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634136
• Total Posts
3015757
×