Jump to content
  • Advertisement

wtherapy

Member
  • Content count

    8
  • Joined

  • Last visited

Everything posted by wtherapy

  1. I am having a nightmare question these days with my Matrix -> TRS ( translation / rotation / scaling ) conversion and back ( working on a skeletal animation sys ). Given a SO(3) matrix, which should equivalently produce a unit quaternion ( with the real part positive ), I cannot successfully convert the matrix to a quaternion and then, converting back the quaternion, to obtain the original matrix back. Code for conversion is straighforward, copy-pasted from Internet and also determined by me on the paper.   The matrix is:   -0.99064791 , 2.6822096e-007, -0.13643673, 0.13169301, -0.26139921, -0.95620453, 0.035664752, 0.96523124, -0.25895494   row major.   I assume there are people around that have competent code for this kind of conversion. Can someone convert this matrix to a unit quaternion, then convert it back to a matrix and confirm they get back the same matrix?   Cristian.
  2. Sorry, but the matrix presented was column-ordered, however, this would make no difference. Good point, JoeJ. I just made the following test:   float vMat[] =  { -0.99064791 ,     0.13169301  ,   0.035664752 ,     0, 2.6822096e-007  ,   -0.26139921 ,     0.96523124 ,  0, -0.13643673 ,    -0.95620453 ,    -0.25895494, 0, 0.00000000 ,     0.00000000 ,     0.00000000,       1.0000000   };   Matrix4F mat; mat.LoadLineOrdered(vMat);   Vector3F sx = mat*Vector3F::UNIT_X; Vector3F sy = mat*Vector3F::UNIT_Y; Vector3F sz = mat*Vector3F::UNIT_Z;   Vector3F tsz = sx^sy; //cross product float fAngle = tsz*sz;   based on the assumption that, on a right-handed coordinate sys, Z = X x Y ( cross product ), it should verify that fAngle = 1. However, after checking, turned out that fAngle is -1. Indeed, the matrix includes a mirroring. Strange that the matrix comes from a POD file exported by PowerVR in 3DMax. Any idea on what to do in this kind of situations? My best guess at the moment is to alter the scaling component of the TRS ( since scaling is computed as a length of a vector, taking the positive value ), to reflect the mirroring component. Anyone have a better idea ( which component of the scaling should have the sign inverted )?
  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!