• Advertisement
Sign in to follow this  

Matrix to quat and back

This topic is 3768 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 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

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement