Question

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)

Was it helpful?

Solution

A quaternion has 4 components, which can be related to an angle θ and an axis vector n. The rotation will make the object rotate about the axis n by an angle θ.

For example, if we have an cube like

 ______
|\  6  \
| \_____\     z
|5 |    | : y ^
 \ | 4  |    \|
  \|____|     +--> x

Then a rotation of 90° about the axis (x=0, y=0, z=1) will rotate the "5" face from the left to the front.

 ______
|\  6  \
| \_____\      z
|3 |    | :  x ^
 \ | 5  |     \|
  \|____|  y<--+

(Note: This is the axis/angle description of rotation, which is what OP confuses. For how quaternion is applied to rotation, see http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation)

OTHER TIPS

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 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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top