Jump to content
  • Advertisement
Sign in to follow this  
YaniMan

Gettint datas from a transformation matrix

This topic is 4845 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

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 this post


Link to post
Share on other sites
Advertisement
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.

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!