# Extraction XYZ and YPR from D3DXMATRIX

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

## Recommended Posts

Hey all, I've been poking around with Direct3D for about a month now, and I'm wondering how you get the position (XYZ) and rotation (YPR) out of a compiled matrix. I have a rudimentary skeletal animation system which loads the mesh(es) and animation(s) out of a .x file, and then animates it. I've got an artist friend who's made a few models and given them to me to play with, but they're not all centered, so if I load two side by side one might be pointing left and the other one forward. What I want to do is get the root bone's transformation matrix, convert it to an identity matrix and copy the XYZ and YPR values into the world transformation matrix it uses, so everything starts pointing 'forward' and the root is centered at (0, 0, 0), although I don't know if it's a good idea to play with the positioning just yet. I've taken a quick peek into the SDK but I'm not finding the relevant information. I'm sure the information exists in it somewhere, but I can't find it. What I would greatly appreciate is if somebody could spell it all out for me (eg provide a simple function that takes a matrix and two D3DXVECTOR3 pointers and puts the apropriate information in them), because I'm a little new to this all. Thanks in advance, Todd

##### Share on other sites
D3DXMatrixDecompose is the function to use.

##### Share on other sites
Quote:
 Original post by DXnutD3DXMatrixDecompose is the function to use.
Thanks :)

Because I'm stupid, how do I go from the quaternion to YPR? Or is it already quat.y, quat.x, quat.z?

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 87
• 11
• 10
• ### Forum Statistics

• Total Topics
632973
• Total Posts
3009615
• ### Who's Online (See full list)

There are no registered users currently online

×