Quaternions with

unit norm are also useful in representing

rotations around the origin in 3D. The unit norm restriction is necessary because rotations in 3D have only 3

degrees of freedom (whereas quaternions have 4).

Quaternions possess the following advantages over 3×3 rotation matricies in representing 3D rotations:

One can easily convert unit-norm quaternions to rotation matricies. Given that *q* = [ *a* *b* *c* *d* ] is a unit quaternion (i.e. *a*^{2} + *b*^{2} + *c*^{2} + *d*^{2} = 1), the rotation matrix representing that quaternion is denoted *M*(*q*) and is defined by

| *a*^{2}+*b*^{2}-*c*^{2}-*d*^{2} 2*bc*-2*ad* 2*bd*+2*ac* |
*M*(*q*) = | 2*bc*+2*ad* *a*^{2}-*b*^{2}+*c*^{2}-*d*^{2} 2*cd*-2*ab* |
| 2*bd*-2*ac* 2*cd*+2*ab* *a*^{2}-*b*^{2}-*c*^{2}+*d*^{2} |

The composition of two rotations represented by the unit-norm quaternion

*p* followed by

*q* is represented by the

quaternion product *q**p*. In other words, the result of a 3-vector

*v* rotated by a quaternion

*p* and then rotated by quaternion

*q* is

*M*(*q*)(*M*(*p*)*v*) = (*M*(*q*)*M*(*p*))*v* = *M*(*q**p*)*v*.

This means that instead of multiplying two 3×3 matricies to get the composite rotation, you can just multiply the two quaternions.

Two interpolate between two quaternions, you must interpolate linearly over the surface of the unit hypersphere in four dimensions. This process is called spherical linear interpolation. The quaternion so interpolated *t* of the way from *p* to *q* is given by the vector *r* using the formula

*r* = (*p*sin((1-*t*)φ) + *q*sin(*t*φ)) / sin(φ).

Here 0

__<__*t*__<__1, and cos(φ) =

*p*·

*q* (regular old

dot product between two 4-vectors). φ represents the angle between the 4-vectors

*p* and

*q*.

Finally, one can obtain the angle θ and axis *u* of rotation from the unit norm quaternion *q* using the following formulae:

cos(θ/2) = a
sin(θ/2) =
(*b*^{2} + *c*^{2} + *d*^{2})^{1/2}

*u* = [ *b* *c* *d* ] / (*b*^{2} + *c*^{2} + *d*^{2})^{1/2}