Quaternions part 2

In the previous post, we introduced quaternions and discussed some of their basic properties. Quaternions are often used in 3D applications such as graphics and robotics to perform smooth rotations.

In this post we describe how to use quaternions to represent points in 3D and how to use quaternion operations to perform rotations about an arbitrary axis.

Suppose we have a point PP with coordinates (px,py,pz)(p_x, p_y, p_z). We would like to rotate PP about the axis u=(ux,uy,uz)u=(u_x,u_y, u_z) by an angle of θ\theta. Let us denote the rotated point by PP'.

Rotation

To calculate the coordinates of PP', we first represent the point PP with the following quaternion:

p=pxi+pyj+pzk. p = p_xi + p_yj + p_zk.

We then use the rotation axis and angle to form the following unit quaternion:
q=cos(θ/2)+sin(θ/2)(uxi+uyj+uzk). q = cos(\theta/2) + sin(\theta/2)(u_xi + u_yj + u_zk).
Finally, we calculate pp' by forming the product:
p=qpq, p' = qpq^*,
where qq^* is the conjugate of qq (see the previous post for details). On inspecting the components of pp', we should find that the real part is zero. The three complex components px,py,pzp'_x, p'_y, p'_z give us the coordinates for PP'.