How do we convert from quaternions to a Rotation Matrix or Rotation Vectors? The key to this is writing quaternion multiplication as a matrix multiplication.

Let , and we can define and ^\bigoplus as:

These two symbols map the quaternion to a matrix. Then, quaternion multiplication can be written in the form of a matrix:

The left side is matrix multiplication and the right side is quaternion multiplication. Similarly, for , we also get:

Then, consider the problem of using a quaternion to rotate a spatial point. According to the previous section, we have:

\mathbf{p}' = \mathbf{q}\mathbf{p}\mathbf{q}^{-1} = \mathbf{q}^{+}\mathbf{p}^{+}\mathbf{q}^{-1} = \mathbf{q^{+}\mathbf{q}^{-1^\bigoplus}\mathbf{p}}

Substituting the matrix corresponding to two symbols, we get:

Since and are both imaginary quaternions, so in fact that the bottom right corner of the matrix gives the transformation formula from quaternion to rotation matrix:

In order to obtain the conversion formula of the quaternion to the rotation vector, we take the trace on both sides of the above formula:

Also obtained by the form:

so:

For the rotation matrix, if we replace with the imaginary part of in the formula, it’ easy to know the imaginary part of is not moving when it is rotated; that is, it constitutes exactly the rotation axis. So we get the rotation matrix just by the normalizing ‘s imaginary part. In summary, the conversion formula from quaternion to rotation vector can be written as:

To convert from other representations, we just need to reverse the above steps.