Jump to content
• Advertisement

# Extracting Position and rotation from a DXMATRIXmatrix

This topic is 5476 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 would like to extract a position XYZ and Rotation (angles axyz) from a DXMATRIX. I checked the MSDN but couldnt find anything like GetVectorPosFromMatrix or GetRotationFromMatrix. I think to extract position xyz I would have to do D3DXMATRIX m; D3DXMatrixIdentity(&m); D3DXMatrixTranslation(&m, 2,3,4); // Here I set translation just for test // And ot retieve XYZ translation I have to access matrix components. Am I right? see below float x = m._41; float y = m._42; float z = m._43; Is it correct? Or Directx has already some function to get XYZ position from a matrix? And last I also would like to extract rotation xyz from same matrix. So basically I am trying to get an orientation from matrix "m" in the form of two (xyz) vectors. one for position second for rotation? How can I get this info? [Edited by - papa on September 23, 2004 8:18:38 AM]

#### Share this post

##### Share on other sites
Advertisement
I don't use DirectX, but depending on whether its transformation matrices are row- or column-oriented, you probably have grabbed the correct elements for x, y, z translation. Its either what you have or m._14, m._24, m._34.

As for determining a sequence of rotations that match the orientation portion of the matrix (the upper 3x3 portion is rotation + scale), I will point you to Dave Eberly's site, below. He has some nice documentation on different rotation representations.

Magic Software

If you want *one* rotation, then you are going to have to map the 3x3 upper left portion of the matrix into a quaternion. Dave's documents should discuss how to extract a quaternion from a rotation matrix. If you don't understand quaternions, check out the articles here and at gamasutra.com (free registration), and also do a search in the forum archives here.

#### Share this post

##### Share on other sites
Ok Thank you "grhodes_at_work" for these links. I am sure it will be quite easy to figure it out but still I would prefer use DX function calls then mess with matrix internal variables to make my code cleaner but if cant find it well I guess I will have to write my own functions :)

#### Share this post

##### Share on other sites

• Advertisement
• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• Advertisement

• ### Popular Now

• 15
• 22
• 17
• 46
• Advertisement
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!