Matrix to quat and back

Started by
2 comments, last by NiteLordz 16 years, 5 months ago
i have a 4x4 matrix class defined as such: rows[0] = vec4(m00, m01, m02, m03); rows[1] = vec4(m10, m11, m12, m13); rows[2] = vec4(m20, m21, m22, m23); rows[3] = vec4(m30, m31, m32, m33); i can not get my quat class to function properly going from quat to matrix and then back to matrix. i am testing by first creating my rotation, like i do for all other rotations in my engine. i then take that matrix and convert to a quat. i am assuming that quatToMatrix should return the original rotation matrix. mine do not. can someone help please. if it helps i can post my two functions, quatToMatrix and matrixToQuat functions if that helps. thanks to all
Code makes the man
Advertisement
It would help to post your code, and some example results.

There could be any of a number of issues (handedness problem, scale in matrix, translation in matrix etc. etc.)
Rotation is represented by a 3x3 matrix and you are using a 4x4. Would that be the problem?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
i am using a 4x4 matrix, as it is my base matrix class for use in my engine. what i am doing is, trying to do skinned mesh. where i get the rotation keys from the model, in this case ms3d file, and then convert them into a 4x4 matrix class so that i can send to the vertex shader to do the transformation.

however, i figured out what my problem with teh quat class was, so now

mat4 rotation = rotateXYZ( PI, PI, PI );

quat q = matrixToQuat( rotation );

mat4 rotation2 = quatToMatrix( q );

i now have the conversion proper, so that rotation == rotation2

so the problem in my skinning code is elsewhere.
Code makes the man

This topic is closed to new replies.

Advertisement