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. a2 + b2 + c2 + d2 = 1), the rotation matrix representing that quaternion is denoted M(q) and is defined by

       | a2+b2-c2-d2  2bc-2ad    2bd+2ac   |
M(q) = |  2bc+2ad   a2-b2+c2-d2  2cd-2ab   |
       |  2bd-2ac    2cd+2ab   a2-b2-c2+d2 |
The composition of two rotations represented by the unit-norm quaternion p followed by q is represented by the quaternion product qp. 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(qp)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 = (psin((1-t)φ) + qsin(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) = (b2 + c2 + d2)1/2

u = [ b c d ] / (b2 + c2 + d2)1/2