Convert Matrix to Quaternion

Started by
12 comments, last by Jan K 15 years, 8 months ago
Hi,

check is your matrix isn't reflection (reflection: det(A) = -1, rotation: det(A) = 1).

M.
Advertisement
Oh, my god, i think i solved it.

It seems my look-at matrix was incorrect. When i negate the 3rd column (the z-vector), everything (regarding quaternions) works, as expected. It seems i accidentally used a false sign in that function, but in all my code that used that matrix i just picked a look-at vector that corrected the problem. It was only the matrix-to-quaternion conversion code, that could not convert that matrix correctly. Damn.

Thanks for all your help and suggestions!
Jan.
Quote:Original post by Jan K
Oh, my god, i think i solved it.

It seems my look-at matrix was incorrect. When i negate the 3rd column (the z-vector), everything (regarding quaternions) works, as expected. It seems i accidentally used a false sign in that function, but in all my code that used that matrix i just picked a look-at vector that corrected the problem. It was only the matrix-to-quaternion conversion code, that could not convert that matrix correctly. Damn.

Thanks for all your help and suggestions!
Jan.


see also:
http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm

For this method matrix on input must be so called special orthogonal matrix (no reflection), while the matrix you posted didn't satisfy this property. I recommend you to guard this condition with good old assertion. This way you would be able find problem with that lookAt much more quickly.
Thank you very much, that is indeed a good idea, i will add an assert in my code. If i only had known earlier ;-) Well, that's the process of learning new things, sometimes it's a bit harder...

Jan.

This topic is closed to new replies.

Advertisement