Jump to content
  • Advertisement
Sign in to follow this  

Get rotation angles from D3DXMATRIX

This topic is 5472 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 have an orientation quaternion from which I extracted the rotation matrix and now I need to get rotation in XYZ euler angles. Is there any way to do it using dx9 math lib? or any other simple way? The code I wrote is:
void GetRotation( D3DXVECTOR3 *angles_out, D3DXQUATERNION *qrot )
D3DXQuaternionNormalize(qrot, qrot); 
// Get rotation matrix from this quat
D3DXMatrixRotationQuaternion( &rot, qrot);

// Here finally I need to extract euler angles from "rot" matrix and put it 
// into 3D vector(xyz) "angles_out". 

Any ideas how to do this?

Share this post

Link to post
Share on other sites
Check the docs at Magic Software. Dave does discuss extracting Euler angles from a rotation matrix. Not DX specific, but doesn't need to be. The only consideration might be the row-wise vs. column-wise orientation, e.g., you might have to take the transpose of the rotation part before applying Dave's formulas.

Share this post

Link to post
Share on other sites
it is possible to transform a point by a matrix
like this but I am not sure what I should do then.


D3DXVec3TransformCoord(&X, &X, &rot); // trnasform 3D point by rotation matrix
D3DXVec3TransformCoord(&Y, &Y, &rot); // trnasform 3D point by rotation matrix
D3DXVec3TransformCoord(&Z, &Z, &rot); // trnasform 3D point by rotation matrix

at this statge I think I rotated each axis by "rot" matrix. but still I dont know how to combine those three 3D vectors into 1 3D vector (xyz) with correct euler angles.

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.

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!