PDA

View Full Version : Question about using quaternions



varieux
06-03-2009, 05:12 AM
Hi folks,

I've been struggling with how to use quaternions for rotation.

I found a boiler-plate routine that converts [x,y,z,w]
to a rotation matrix.

I had thought that by altering the angle "w" linearly,
e.g. based on the position of the mouse pointer on
the display, I could cause a linear rotation to occur
about the axis [x y z], which I've preset to [0 1 0].

However this has proved to be. The rotation is not linear at all.

I set w to be proportional to the mouse's x value, and
then I normalize [x y z w].

What I observe unfortunately is that rotation slows down
toward 180 degrees in either direction.

Can anyone explain why this happens?

Thanks.

ZbuffeR
06-03-2009, 06:16 AM
Only unit quaternions can be used for representing orientations.
So if you mess with one component, you will have to adjust others too.

marek-knows.com
06-07-2009, 07:36 AM
I created a video tutorial showing how to implement quaternion rotation on my website here: http://www.marek-knows.com/downloadSection.php?Topic=Math&pg=1#Math8

If you want to do smooth rotations have a look at SLERP http://en.wikipedia.org/wiki/Slerp