In order to advance a simulation forward in time, a numerical integration scheme is needed to evaluate the continuous part of the dynamics, which is specified by a differential equation. For translational dynamics, this is usually of the form

where is the position, and is the velocity. The acceleration, defined as , is a function of the position and velocity. Under the assumption that acceleration is constant, the differential equations have a closed-form solution, giving the update formula

where and .

In this article, we will derive an analogous result for rotational dynamics — the numerical integration scheme for the differential equations describing rotational motion under the assumption of constant angular acceleration.

The assumption of constant acceleration is not always appropriate for translational dynamics, particularly for systems like springs that have rapidly varying acceleration. For rotational dynamics, a proper discussion of the appropriateness of constant angular acceleration is best left to a dedicated article, as it would involve the details of rigid body dynamics, which is not the concern of this article.

## Translational and Rotational Analogies in 3D

Whereas translational motion describes the change in an object’s position over time, rotational motion describes the change in an object’s orientation. Positions are described relative to an origin by a displacement vector, with the null vector describing the origin. In an analogous fashion, orientations are described relative to a standard orientation by a rotation, with the identity rotation describing the standard.

Rotations in 3D can be quantified by:

- an axis and an angle;
- by virtue of being linear maps: a rotation matrix — a real 3-by-3 matrix with determinant 1 and inverse coinciding with its transpose;
- a unit quaternion.

We will assume that the reader is already familiar with rotations and their various descriptions.

In 3-dimensional space, the space of rotations also possesses a 3-dimensional structure. This is not the case in general — for example, in 2D the space of rotations is 1-dimensional. Because of this, there are many analogies between translational and rotational dynamics in 3D.

Translational | Rotational |
---|---|

position, | rotation matrix, , or unit quaternion, |

velocity, | angular velocity, |

acceleration, | angular acceleration, |

mass, | moment of inertia tensor, |

momentum, | angular momentum, |

force, | torque, |

The aim of this article is not to discuss how accelerations are produced by forces, nor how angular accelerations are produced by torques, and therefore we will be focusing on the top half of this table.

The main reason that rotational motion is more complicated than translational motion is that the space of rotations is not a linear space — it is `curved’. In a linear space, a constant velocity moves you along a straight line; in the space of rotations, a constant angular velocity moves you along a curve.

## The Rotational Equations

The key piece of information missing from the table above is the relation between the angular velocity, , and the time derivative of the rotation, (or ).

For rotation matrices this is

where is an anti-symmetric matrix describing the linear map , called the cross-product matrix,

For the mathematically literate, is an element of the Lie algebra , the tangent space to at the identity. The conversion is an isomorphism between our physical space and , which is possible as they are of the same dimension. Under this identification, the cross product coincides with the matrix commutator, which is the Lie bracket for the algebra. The time derivative is a tangent vector at , which is given by the pushforward of by right translation.

The quaternionic version of this is

where is interpreted as an imaginary quaternion and the multiplication is quaternionic. The identification of vectors with imaginary quaternions is analogous to the identification of vectors with anti-symmetric matrices, as the imaginary quaternions form the tangent space to the unit quaternions at the identity, 1. The factor of comes from the property that each rotation is described by *two* unique unit quaternions, whereas there is only one rotation matrix.

## Integrating the Rotational Equations

The easy part of the integration is the angular velocity, which, assuming constant angular acceleration gives

However the other equation is not so straightforward.

In the special case that , the angular velocity is constant and the solution is given by the exponential map

But when and varies with time, this becomes much more complicated. The solution can be written as an infinite series via the Magnus expansion,

For constant angular acceleration, we can compute the first few of these terms by hand,

This series is guaranteed to converge as long as the angle rotated per time-step is less than (which is about 127 degrees). Typically the first one or two terms are plenty. Note that we have given in vector form, but for use in the matrix exponential the sum should be converted to the cross-product matrix form. We can also reverse-engineer the quaternion version from this,

where is now an imaginary quaternion.

### A Geometric Interpretation

We can think of the Magnus expansion as a polynomial in with values in , the tangent space to at the identity. In other words it is a path in the tangent space that begins at the null vector and ends at some vector .

The exponential map maps this tangent space to the manifold, , in a way that identifies the null vector with the identity. Therefore it `wraps’ the path around the manifold so the starting point is the identity, , and the end point is .

The act of multiplying this path with the current rotation on the right is called right translation. It `moves’ the path across the manifold so that the starting point is now at , and the end point is the new rotation . Therefore the integration moves us along paths that are constrained to rotation group.

## Evaluating the Exponential Map

For both matrices and quaternions, the exponential map is defined by the series

However, for the case that is an anti-symmetric matrix, the exponential map corresponds to the conversion from axis-angle to rotation matrix (the length of the associated vector is the angle, the direction is the axis). The analogous statement applies for the quaternionic version: the exponential map acting on imaginary quaternions corresponds to the axis-angle to unit quaternion conversion,

However, performing such a conversion involves evaluating trig functions, which are expensive. Instead, we can truncate the series expansion of the exponential map to get an approximation. This is appropriate as we will be evaluating it with , so the higher powers will be negligible.

For an imaginary quaternion, . This means the quaternion exponential map to third-order is

The full exponential map produces unit quaternions from imaginary quaternions, so we should also build a normalization into this approximation,

This approximation is good for small rotations per time-step. The error is less than 1% for rotations up to 90 degrees per time-step. For faster rotations, the full exponential map should be applied.

Unfortunately, rotation matrices are not so easily (ortho)normalizable, and so you’re best off using the full axis-angle to rotation matrix conversion to implement the exponential map for matrices. For this reason the quaternion description is preferable to rotation matrices.

## Conclusion

We have derived a method for time-stepping rotational dynamics that expresses each update as a rotation. The update rotation is determined in vector form (axis-angle) by truncating the Magnus expansion and then converted to the underlying algebraic representation (rotation matrix/unit quaternion) by applying the exponential map.

For the quaternion version, we also approximated the exponential map in a way that avoids evaluating trig functions while preserving normalization, so the resulting quaternion is always a valid rotation.

I have a question regarding the equation q’=exp(.5*w*dt)*q. Specifically, how is it possible to compute q’ as the dimensions for w and q do not agree. i.e. w is a 3 element vector and q is a 4 element vector.

Thanks.

LikeLike

Every 3-vector can be interpreted as a purely imaginary quaternion (i.e. the 3-vector w becomes the quaternion (0,w_x,w_y,w_z)). It is common to do this implicitly without any special notation.

LikeLike