#### Archived

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

# 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.

## 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 on other sites
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 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

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 15
• 13
• 9
• 12
• 10
• ### Forum Statistics

• Total Topics
631442
• Total Posts
3000087
×