views:

73

answers:

2

Is quaternion rotation just a vector with X,Y,Z which the object will rotate towards, and a roll which turns the object on its axis?

Is it that simple?

Meaning if you have X=0, Z=0 and Y=1 the object will face upwards?
And if you have Y=0, Z=0 and X=1 the object will face to the right?

(assuming X right, Y up and Z depth)

+6  A: 
KennyTM
leftways or rightways?
clamp
@clamp: Depends on if the system is left-handed or right-handed.
KennyTM
@Kenny: the OP said "Y up and Z depth".
LarsH
@LarsH: Put your head below the z-axis, and view the whole thing in a mirror. :)
KennyTM
+2  A: 

A quaternion in general is an extension of a complex number into 4 dimensions. So no, they are not just x, y, and z, and an angle, but they're close. More below...

Quaternions can be used to represent rotation, so they're useful for graphics:

Unit quaternions provide a convenient mathematical notation for representing orientations and rotations of objects in three dimensions. Compared to Euler angles they are simpler to compose and avoid the problem of gimbal lock. Compared to rotation matrices they are more numerically stable and may be more efficient.

So what are the 4 components and how do they relate to the rotation?

The [unit quaternion] point (w,x,y,z) represents a rotation around the axis directed by the vector (x,y,z) by an angle alpha = 2 cos-1 w = 2 sin-1 sqrt(x2+y2+z2).

So back to your question,

Meaning if you have X=0, Z=0 and Y=1 the object will face upwards?

No... the object will rotate around this <0,1,0> vector, i.e. it will rotate around the y axis, turning counterclockwise as seen from above, if your graphics system uses right-hand rotation. (And if we plug in w = sqrt(1 - (0 + 1 + 0)), your unit quaternion is (0,0,1,0), and it will rotate by angle 2 cos-10, = 2 * 90 degrees = 180 degrees or 2 pi radians.)

And if you have Y=0, Z=0 and X=1 the object will face to the right?

This will rotate around the vector <1,0,0>, the x axis, so it will rotate counterclockwise as seen from the positive x direction (e.g. right). So the top would turn forward (180 degrees, so it would rotate until it faced downward).

LarsH