Quaternions are people from the planet Quatern. They are a very reclusive race and don’t like even being talked about, let alone having examples made of them.
Thanks Kaycee! But I think its the world axis is what I want the object to be rotated about So if you can still help me out much appreciated Thank You.
[This message has been edited by ELIMT (edited 12-05-2001).]
I know exactly what you’re talking about. I’m doing a class project right now where I’m trying to walk the viewpoint around a sphere centered at the origin. Quaternions are definitely the way to go. Try searching around on the net for some code that implements a trackball and quaternions. I found two files (I don’t have them here or I’d post them) trackball.c and trackball.h that have a nice implementation of the idea. Essentially you pass in two points, then the code finds an axis of rotation and a rotation angle (you can just give it these parameters yourself if you want). The rotation axis and angle are then converted to quaternion notation. The beauty of quaternions is that you can just add rotation to rotation without worrying about the order you apply them. So the code will have an ‘add quaternion’ function that will combine your previous rotation to the new one, and then a function that takes the resulting quaternion and makes a single rotation matrix out of it. This single rotation matrix is what you want to use when transforming your scene. Instead of using glRotate you will use glMultMatrix() with the new rotation matrix as the parameter. It works for me!