# Axis–angle representation

(Redirected from Axis angle)
A visualization of a rotation represented by an Euler axis and angle.

In mathematics, the axis–angle representation of a rotation parameterizes a rotation in a three-dimensional Euclidean space by two values: a unit vector $\mathbf{\hat{e}}$ indicating the direction of an axis of rotation, and an angle θ describing the magnitude of the rotation about the axis. The rotation occurs in the sense prescribed by the right-hand rule. The rotation axis, a locus of points that do not move, is sometimes called the Euler axis.

It is one of many rotation formalisms in three dimensions. These formalisms describe rotations around the origin, a fixed point. Alternatively, one can understand such rotations as transformations of vectors, not points; in other words, translations are ignored. The axis–angle representation evolves from Euler's rotation theorem, which implies that any rotation or sequence of rotations of a rigid body in a three-dimensional space is equivalent to a pure rotation about a single fixed axis.

## Rotation vector

The axis–angle representation is equivalent to the more concise rotation vector, also called the Euler vector. In this case, both the rotation axis and the angle are represented by a Euclidean vector codirectional with the rotation axis whose magnitude is the rotation angle θ:

$\mathbf{e} = \theta \mathbf{\hat{e}}$

In other words, the rotation vector is a product of the vector ê and a scalar θ. It is used for the exponential and log maps involving this representation.

## Uses

The axis–angle representation is convenient when dealing with rigid body dynamics. It is useful to both characterize rotations, and also for converting between different representations of rigid body motion, such as homogeneous transformations[clarification needed] and twists.

When a rigid body rotates around a fixed axis, its axis–angle data are a constant rotation axis and the rotation angle continuously dependent on time.

## Example

Say you are standing on the ground and you pick the direction of gravity to be the negative z direction. Then if you turn to your left, you will travel $\tfrac{\pi}{2}$ radians (or 90°) about the z axis. In axis-angle representation, this would be

$\langle \mathrm{axis}, \mathrm{angle} \rangle = \left( \begin{bmatrix} a_x \\ a_y \\ a_z \end{bmatrix},\theta \right) = \left( \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix},\frac{\pi}{2}\right)$

The above example can be represented as a rotation vector with a magnitude of $\tfrac{\pi}{2}$ pointing in the z direction.

$\begin{bmatrix} 0 \\ 0 \\ \frac{\pi}{2} \end{bmatrix}$

## Rotating a vector

Further information: Rodrigues' rotation formula

Rodrigues' rotation formula (named after Olinde Rodrigues) is an efficient algorithm for rotating a Euclidean vector, given a rotation axis and an angle of rotation. In other words, the Rodrigues' formula provides an algorithm to compute the exponential map from so(3) to SO(3) without computing the full matrix exponent (the rotation matrix).

If v is a vector in $\mathbb{R}^3$ and ω is a unit vector describing an axis of rotation about which we want to rotate v by an angle θ (in a right-handed sense), the Rodrigues' formula to obtain the rotated vector is:

$\mathbf{v}_\mathrm{rot} = (\cos\theta) \mathbf{v} + (\sin\theta) (\boldsymbol{\omega} \times \mathbf{v}) + (1 - \cos\theta) (\boldsymbol{\omega} \cdot \mathbf{v}) \boldsymbol{\omega}.$

For the rotation of a single vector this is more efficient than converting ω and θ into a rotation matrix to rotate the vector.

## Relationship to other representations

Further information: Charts on SO(3)

There are many ways to represent a rotation. It is useful to understand how different representations relate to one another, and how to convert between them.

### Exponential map from so(3) to SO(3)

The exponential map is used as a transformation from axis-angle representation of rotations to rotation matrices.

$\exp\colon \mathfrak{so}(3) \to \mathrm{SO}(3)$

Essentially, by using a Taylor expansion you can derive a closed form relationship between these two representations. Given a unit vector $\mathbf{\omega} \in \mathfrak{so}(3) = \Bbb{R}^{3}$ representing the unit rotation axis, and an angle, $\theta \in \Bbb{R}$, an equivalent rotation matrix R is given as follows, where where K is the cross product matrix of ω.

That is, $\mathbf{K} \mathbf{v} = \mathbf{\omega}\times\mathbf{v}$ for all vectors $\mathbf{v} \in \Bbb{R}$:

$R = \exp(\theta \mathbf{K}) = \sum_{k=0}^\infty\frac{(\theta \mathbf{K})^k}{k!} = I + \mathbf{K} \theta + \frac{1}{2!}(\theta \mathbf{K})^2 + \frac{1}{3!}(\theta \mathbf{K})^3 + \cdots$

Because K is skew-symmetric, and the sum of the squares of its above-diagonal entries is 1, the characteristic polynomial P(t) of K is P(t) = det(K – t I) = –(K3 + K). Since by the Hamilton-Cayley theorem we have P(K) = 0, this implies that K3 = –K. As a result, K4 = –K2, K5 = K, K6 = K2, K7 = –K. This pattern continues indefinitely, and so all higher powers of K can be expressed in terms of K and K2. Thus from the above equation we get:

$R = I + \left(\theta - \frac{\theta^3}{3!} + \frac{\theta^5}{5!} - \cdots\right) \mathbf{K} + \left(\frac{\theta^2}{2!} - \frac{\theta^4}{4!} + \frac{\theta^6}{6!} - \cdots\right) \mathbf{K}^2$
$R = I + \sin(\theta) \mathbf{K} + (1-\cos(\theta)) \mathbf{K}^2.$

This is an advanced derivation, compared to the geometric one in the article Rodrigues' rotation formula.

Due to the existence of the above mentioned exponential map, the unit vector ω representing the rotation axis, and the angle θ are sometimes called the exponential coordinates of the rotation matrix R.

### Log map from SO(3) to so(3)

Let K continue to denote the 3×3 matrix that effects the cross product with the rotation axis ω: K(v) = ω × v for all vectors v in what follows:

To retrieve the axis–angle representation of a rotation matrix calculate the angle of rotation:

$\theta = \arccos\left( \frac{\mathrm{trace}(R) - 1}{2} \right)$

and then use it to find the normalized axis:

$\mathbf{\omega} = \frac{1}{2 \sin(\theta)} \begin{bmatrix} R(3,2)-R(2,3) \\ R(1,3)-R(3,1) \\ R(2,1)-R(1,2) \end{bmatrix}$

Note, also that the Matrix logarithm of the rotation matrix R is:

$\log R = \left\{ \begin{matrix} 0 & \mathrm{if} \; \theta = 0 \\ \frac{\theta}{2 \sin(\theta)} (R - R^\top) & \mathrm{if} \; \theta \ne 0 \; \mathrm{and} \; \theta \in (-\pi, \pi) \end{matrix}\right.$

Except when R has eigenvalues equal to −1. In this case the log is not unique. However, even in the case where $\theta = \pi$ the Frobenius norm of the log is:

$\| \log(R) \|_F = \sqrt{2} | \theta |$

Note that given rotation matrices A and B:

$d_g(A,B) := \| \log(A^\top B)\|_F$

is the geodesic distance on the 3D manifold of rotation matrices. Note that for small rotations, the above computation of $\theta$ may be numerically imprecise as the derivative of arccos goes to infinity as theta approaches zero. In that case, the off-axis terms will provide better information about $\theta$ since, for small angles, $R \approx \mathbf{I} + \mathbf{K}.$ (This is because these are the first two terms of the Taylor series for $\exp(\mathbf{K}).$)

This formulation also has numerical problems at $\theta=\pi$. There, the off-axis terms don't give information about the rotation axis (which is still defined up to a sign ambiguity). In that case, we must reconsider the above formula.

$R = I + \mathbf{K} \sin(\theta) + \mathbf{K}^2 (1-\cos(\theta))$

At $\theta=\pi$ we have

$R = I + 2 \mathbf{K}^2 = I + 2(\mathbf{\omega} \otimes \mathbf{\omega} - I) = 2 \mathbf{\omega} \otimes \mathbf{\omega} - I$

and so let

$B:=\mathbf{\omega} \otimes \mathbf{\omega} = \frac{1}{2}(R+I)$

so the diagonal terms of B are the squares of the elements of ω and the signs (up to sign ambiguity) can be determined from the signs of the off-axis terms of B.

### Unit quaternions

the following expression transforms axis–angle coordinates to versors (unit quaternions):

$Q = \left(\cos\left(\frac{\theta}{2}\right), \mathbf{\omega} \sin\left(\frac{\theta}{2}\right)\right)$

Given a versor $q = s + \mathbf{x}$ represented with its scalar s and vector x, the axis–angle coordinates can be extracted using the following:

$\theta = 2\,\arccos(s)\,$
$\mathbf{\omega} = \left\{ \begin{matrix} \frac{x}{ \sin( \theta/2 ) } , & \mathrm{if} \; \theta \neq 0 \\ 0, & \mathrm{otherwise} \end{matrix} \right.$

A more numerically stable expression of the rotation angle uses the atan2 function:

$\theta = 2\,\operatorname{atan2}(\|\mathbf{x}\|,s)\,,$

where |x| is the Euclidean norm of the 3-vector x.