Archived

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

Quaternions

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

Is there anyone out there that can give me a basic undersanding on how quaternions work. I´ve tried a myriad of places but they describe it using just math. I simply want to know how to make a rotation around an arbitrary axis (for my camera). PS I´m really stupid so I could use some "simple" help. [edited by - shakazed on September 10, 2002 12:20:06 PM] [edited by - shakazed on September 10, 2002 12:20:45 PM]

Share this post


Link to post
Share on other sites
www.gametutorials.com has a sample opengl programming to show quartenions.

maybe you dont get it by reading, maybe an example of a running program would help.

the sample is just a ball rotating around a moving axis.

Share this post


Link to post
Share on other sites
Lets try this, I didn''t know what a quaternion was a week ago, so I''m no expert.

First, lets define some vectors:
- p is the position of the camera.
- v is the position of the target that the camera is looking at.
- u is the position of the target that the camera should rotate toward.
- v'' = v - p; the offset vector of the target that the camera is looking at.
- u'' = u - p; the offset vector of the target that the camera should rotate toward.
- A = v'' x u''; the crossproduct of v'' and u'', the arbitrary axis to rotate around, should also be normalized.

Secondly, lets define the rotation:
- t is the rotation from v toward u.

Next, lets define some quaternions:
- qv = (x(v''), y(v''), z(v''), 1); the v'' vector as a quaternion.
- qt = (x(A)*sin(t/2), y(A)*sin(t/2), z(A)*sin(t/2), cos(t/2)); the quaternion for the rotation operation.
- qr = qt * qv * inverse(qt); the result of the rotation.

Finally, extract the new position from the resulting quaternion, qr.

Share this post


Link to post
Share on other sites