Problem with Quaternion Rotation

Started by
0 comments, last by TonyZahn 20 years, 7 months ago
Yes I know... another post about Quaternions... My problem is this: I''m trying to update my codebase to use quaternions for object orientation instead of Matrices so I don''t have to spend time keeping my matrices orthogonal (sp?). Everything is working fine until I try to map one quaternion onto another. According to the code I''ve got , to rotate p by q, you do qp(~q) (I may have that backwards, the code''s at home). Anyway, the default value for my quaternion class is X = Y = Z = 0.0; W = 1.0; This yields the identity matrix, which is just what I want. When I multiply this by another quaternion (say a rotation around the Z axis), nothing happens because the 0s cancel out everything else. I''m a little lost as to what I''m doing wrong, everything I''ve read about quaternions says you do it this way, but none of them say what do when your values are 0. Anyone have any suggestions as to what I''m missing here? I''ve read everything I can find about quaternions and apparently I''m just not getting it.
Advertisement
Shouldn't do:

If q1 = (w,x,y,z) = (1,0,0,0)
And q2 = anything

w = (q2.w*q1.w) - (q2.x*q1.x) - (q2.y*q.y) - (q2.z*q1.z);
x = (q2.w*q1.x) + (q2.x*q1.w) + (q2.y*q.z) - (q2.z*q1.y);
y = (q2.w*q1.y) + (q2.y*q1.w) + (q2.z*q.x) - (q2.x*q1.z);
z = (q2.w*q1.z) + (q2.z*q1.w) + (q2.x*q.y) - (q2.y*q1.x);

q2 * q1 = q2

As you'd expect.

[edited by - JuNC on August 28, 2003 9:54:56 AM]

This topic is closed to new replies.

Advertisement