• Advertisement

Archived

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

Quaternions(again)

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

From looking at the forum I''m sure everyones sick of quaternions, but my question is simple: if quaternions are used to "represent a transformation" such as rotation in the form of 4 numbers w,x,y,z then how do I set these values for a transformation (or alter them) and then how do I use these values to do the transformations (I only need to end up with an angle and a vector for the opengl rotatef function.) I dont intend to understand how they actually work, at the moment, just to resolve my frustration about my failing 3d program. The "why"s and "how"s of it will be resolved some day, but can somone just answer these hopefully more straight forward questions. The help really will be appreciated, thanks.

Share this post


Link to post
Share on other sites
Advertisement
axis (X,Y,Z) angle (A) to quaternion (w,x,y,z) :

normalize (X,Y,Z) (X^2+Y^2+Z^2==1)
w = cos(A/2)
(x,y,z) = (X,Y,Z)*sin(A/2)

quaternion to axis/angle
A = 2*acos(w)
(X,Y,Z) = (x,y,z)/sqrt(1-w^2) // irrelevant if A == 0

quaternion to transformation matrix (will be faster than glRotate, use glMatrixMultiply). You might need to use the transposed of the following matrix though (element ordering...)

| 1-2yy-2zz 2xy+2wz 2xz-2wy 0 |
| 2xy-2wz 1-2xx-2zz 2yz+2wx 0 |
| 2xz+2wy 2yz-2wx 1-2xx-2yy 0 |
| 0 0 0 1 |
[code]

Edited by - Fruny on February 25, 2002 5:41:13 PM

Share this post


Link to post
Share on other sites
Thank you so much. I''ve been looking for that answer for quite a while, that''s just I wanted. Thanx again.

Share this post


Link to post
Share on other sites

  • Advertisement