Search code examples
3drotationquaternionsangle

What's a quaternion rotation?


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)


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)