Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

TimOtholt

Gamasutra Quaternion Library Fubar?

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

Ugh, I''m trying to use Nick Bobbic''s Quaternion library from Gamasutra in a Q3 mod I''m working on. Basically, I create a Quat from some euler angles. I then convert the resulting quat to a matrix. I print the matrix on the screen. In my test case, I create a quat with a 45 degree rotation (in radians of course). When I convert the quat to a matrix (using the library), the resulting matrix appears fubar: Here is my test methodology: QuatDumpToScreen(&quat1); gluQuatToMat_EXT(&quat1, matrix); gluMatToQuat_EXT(matrix, &quat2); QuatDumpToScreen(&quat2); Well, the two quats that get written to the screen aren''t the same. The sign bits are messed up, such that one the first quat represents a 45 degree rotation (which is correct), then converting to a matrix and back forms a quat with a -45 degree rotation. Anyone notice this buggy behavior with this quat library? Tim

Share this post


Link to post
Share on other sites
Advertisement
Hi there,

a quaternion in it''s representation is a vector plus an angle.

If the vector gets flipped then the angle has to get flipped, too.

So technically speaking:

(cos(alpha),[0,0,1]*sin(alpha)) == (cos(-alpha),[0,0,-1]*sin(-alpha))

is equivalent, I think.

Share this post


Link to post
Share on other sites
quote:
Original post by NextS
Hi there,

a quaternion in it''s representation is a vector plus an angle.

If the vector gets flipped then the angle has to get flipped, too.

So technically speaking:

(cos(alpha),[0,0,1]*sin(alpha)) == (cos(-alpha),[0,0,-1]*sin(-alpha))

is equivalent, I think.


What you say makes total sense. Unfortuantely, it''s not what I''m seeing. =(



I basically convert an euler angle (roll = 0, pitch = 0, yaw = 45), to a quaternion:

x = 0.0
y = 0.0
z = 0.382683
w = 0.923879

Then I convert the quat to a matrix, and back, and I get this new quaternion:

x = 0
y = 0
z = 0.382683
w = -0.923879

I know they aren''t the same. One is a -45 degree rotation, the other is a +45 degree rotation.

Man, this quat stuff is difficult to visualize. =)

Tim

Share this post


Link to post
Share on other sites

  • 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!