Sign in to follow this  
jdub

Noobie confused with quaternions

Recommended Posts

I'm having trouble with understanding what quaternions do. A book that I have that talks about them (Game Coding Complete) says that a Quaternion represents a rotation around an arbitrary axis such as (2.5 , 6.777 , -1). I took this to mean that you could take an object and rotate it around a quaternion a certain number of degrees X Y or Z. For example a planet spinning around the sun. But looking at how the book uses quaternions, I can see that a quaternion does not have a rotateX() or rotateY() function; Only a Rotate(). I must be wrong. Could someone explain to me how quaternion rotation actually works?

Share this post


Link to post
Share on other sites
Your statement from Game Coding Complete is correct. A quaternion can be created from an axis and an angle and is probably the easiest way to try and visualize them.

What you seem to be missing is that there is no x y and z in that explanation. You have an axis and an angle, and that's it.

Lets say you wanted to create a rotating Earth and lets assume that it rotates around the Y axis. This axis would be defined as (0.0, 1.0, 0.0). The angle would be the angle of rotation.

For more in depth information the Matrix and Quaternion FAQ is a great reference.

Share this post


Link to post
Share on other sites
Just to clear some things up:
Quote:
A book that I have that talks about them (Game Coding Complete) says that a Quaternion represents a rotation around an arbitrary axis such as (2.5 , 6.777 , -1).
It would be a little more accurate to say that a quaternion can be used to represent an arbitrary axis-angle rotation. By itself, a quaternion is simply a complex number of the form xi + yj + zk + w, and can have any value; however, in the context of computer graphics it is common to use the unit quaternions to represent rotations.
Quote:
I took this to mean that you could take an object and rotate it around a quaternion a certain number of degrees X Y or Z.
In the context of 3-d graphics, you don't really rotate anything 'around a quaternion'. Also, as the above poster mentioned, there's really no 'x, y, or z' involved.

What you can do is encode an axis and angle in a quaternion, and then apply certain operations that have the effect of rotating a vector about the specified axis by the specified angle.

A good first step in understanding all this would be to develop a good understanding of axis-angle rotations in general. Quaternions and matrices simply provide different ways of representing and manipulating these rotations, so once you've got axis-angle rotations figured out the rest should start to make more sense.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this