# softmatter:Quaternions

Quaternions are a mathematical construct that can be used to represent rotations of a rigid body while avoiding the singularities that arise from Euler angles. The quaternion concept was first proposed by Sir William Rowan Hamilton and its application to rigid body rotation elucidated by Arthur Cayley. Because quaternions do not commute under multiplication, they are also much more useful for interpolating the motion of rigid body between two different orientations.

## Definition

A quaternion can be defined as an extension of the complex set [1]:

$\mathbf{q}=q_0+q_1\mathbf{i}+q_2\mathbf{j}+q_3\mathbf{k}$
$\mathbf{i}^2=\mathbf{j}^2=\mathbf{k}^2=-1$

Addition of quaternions proceeds component-wise. However, by virtue of the complex variables i, j, and k, multiplication of quaternions is not commutative. The non-commutation of quaternions corresponds to the non-commutation of rotation operations.

## Rigid Body Rotation

### Rotation Matrix

The rotation matrix relates the orientation of a rigid body to space-fixed coordinates. A unit quaternion maps to the rotation matrix by

$\mathbf{A}= \begin{pmatrix} q_0^2+q_1^2-q_2^2-q_3^2& 2q_1q_2-2q_0q_3& 2q_0q_2+2q_1q_3 \\ 2q_0q_3+2q_1q_2& q_0^2-q_1^2+q_2^2-q_3^2& 2q_2q_3-2q_0q_1 \\ 2q_1q_3-2q_0q_2& 2q_0q_1+2q_2q_3& q_0^2-q_1^2-q_2^2+q_3^2 \\ \end{pmatrix}$

subject to a normalization constraint

$q_0^2+q_1^2+q_2^2+q_3^2=1$

Note that q0 = 1, q1 = q2 = q3 = 0 makes the rotation matrix equal to the identity matrix (i.e. the rigid body is in its initial orientation).

### Integration

The motion of a rigid body can be broken into two modes: rotation and translation. The sum of the forces acting on a rigid body determines the change in position (translation) of the center of mass while the sum of the torques yields the change in orientation (rotation). Integrating the center of mass position is identical to integration methods described elsewhere (i.e. Verlet Algorithm, Leapfrog Algorithm) with the addition of an extra summing of forces step. These schemes have been adapted to the integration of the rigid body orientation [2],[3] and obey the quaternion equation of motion:

$\mathbf{\dot{q}}= \begin{pmatrix} \dot{q_0}\\ \dot{q_1}\\ \dot{q_2}\\ \dot{q_3} \end{pmatrix} =\frac{1}{2} \begin{pmatrix} q_0 &-q_1 &-q_2 &-q_3\\ q_1 &q_0 &-q_3 &q_2\\ q_2 &q_3 &q_0 &-q_1\\ q_3 &-q_2 &q_1 &q_0 \end{pmatrix} \begin{pmatrix}0\\ \omega_x^b\\ \omega_y^b\\ \omega_z^b \end{pmatrix}$

## References

• [1] Wikipedia Entry on Quaternions
• [2] Fincham, D. "Leapfrog Rotational Algorithms." Molecular Simulation (8) 165-178, 1992.
• [3] Omelyan, I.P. "Algorithm for numerical integration of the rigid-body equations of motion." Physical Review E (58) 1169-1172, 1998.