Jump to content
  • Advertisement
Sign in to follow this  

World Matrix - Eular rotations simple and SHOULD work... but it doesn't

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

I'm trying to undo D3DXMatrixRotationX, (and y and z that were multiplied in xyz order) to fill the values of window alowing a user to move around an object in world space now according to this the following function should work I thought... (scaling and translation work fine but rotation gives strange values) It's probably a stupid mistake but I can't see it...
 * sets up this window's values
 * @param mat the matrix the get the values from
void MatrixSetupWindow::setMatrix(LPD3DXMATRIX mat)
  D3DXVECTOR3 vScale, vTranslation, vRotation;
  D3DXMATRIX matRot;
  float fAngle;

  D3DXMatrixDecompose(&vScale, &qRotation, &vTranslation, mat);


  D3DXMatrixRotationQuaternion(&matRot, &qRotation);

  vRotation.y = asin(matRot._31);
  vRotation.x = asin(matRot._23);
  vRotation.z = asin(matRot._12);
  m_avwXRot->setValue(vRotation.x * 180 / D3DX_PI);
  m_avwYRot->setValue(vRotation.y * 180 / D3DX_PI);
  m_avwZRot->setValue(vRotation.z * 180 / D3DX_PI);

[Edited by - Coder on September 23, 2004 10:49:50 PM]

Share this post

Link to post
Share on other sites
Can anyone tell me what I'm doing wrong? I've gone over it a few times and apparently I'm blind because it looks to me like it should work... but it doesn't.

Share this post

Link to post
Share on other sites
What you're doing doesn't work because matRot is the combined XYZ rotation matrix. What you might try doing is multiplying the symbolic X, Y, and Z rotation matrices respectively and equating that to matRot to see if you get an equation you can solve for each axis theta. Unfortunately I've never actually done this before so I can't tell you if it would work. Luckily you can use basic identities to get everything in terms of either sin or cos, but I don't know if you'll get a solvable system.

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!