Definitions

# Rotation representation (mathematics)

In geometry a rotation representation expresses the orientation of an object (or coordinate frame) relative to a coordinate reference frame. This concept extends to classical mechanics where rotational (or angular) kinematics is the science of describing the purely rotational motion of an object.

According to Euler's rotation theorem the general displacement of a rigid body (or coordinate frame) with one point fixed is described by a rotation about some axis. Furthermore, such a rotation may be uniquely described by a minimum of three parameters. However, for various reasons, there are several ways to represent such a rotation. Many of these definitions use more than the necessary minimum of three parameters, although any such representation still has only three degrees of freedom.

An example where rotation representation is used is in computer vision, where an automated observer needs to track a target. Let's consider a rigid body, with an orthogonal right-handed triad $hat\left\{mathbf\left\{u\right\}\right\}$, $hat\left\{mathbf\left\{v\right\}\right\}$ and $hat\left\{mathbf\left\{w\right\}\right\}$ of unit vectors fixed to its body (the object coordinate system). The basic problem is to specify the orientation of this triad, and hence the rigid body, in terms of the reference coordinate frame (in our case the camera coordinate system).

## Rotation matrix (or direction cosine matrix)

It is clear that specifying the coordinates (scalar components) of a basis for our new (rotated) set of coordinate axes in terms of the original (non-rotated) coordinate axes, will completely describe the rotation. The three unit vectors $hat\left\{mathbf\left\{u\right\}\right\}$, $hat\left\{mathbf\left\{v\right\}\right\}$ and $hat\left\{mathbf\left\{w\right\}\right\}$ which form the basis for our new system each consists of 3 coordinates, yielding a total of 9 parameters. These parameters can be written as the elements of a $3times3$ matrix $mathbf\left\{A\right\}$, called the rotation matrix or direction cosine matrix (DCM).


mathbf{A} = left[{begin{array}{ccc} hat{mathbf{u}}_x & hat{mathbf{v}}_x & hat{mathbf{w}}_x hat{mathbf{u}}_y & hat{mathbf{v}}_y & hat{mathbf{w}}_y hat{mathbf{u}}_z & hat{mathbf{v}}_z & hat{mathbf{w}}_z end{array}} right]

Each of the elements is the cosine of the angle between a rotated unit basis vector and one of the reference axes, and this is the reason why $mathbf\left\{A\right\}$ is often called the direction cosine matrix. The elements of the DCM are not all independent - as Euler's rotation theorem dictates, the DCM has only three degrees of freedom. The DCM has the following properties:

• A is a real, orthogonal matrix.
• The eigenvalues of A are $\left\{1, e^\left\{pm itheta\right\} \right\}$, or

$\left\{1, cos\left(theta\right)+isin\left(theta\right), cos\left(theta\right)-isin\left(theta\right)\right\}.$

• The determinant (being the product of the eigenvalues) of A is +1.

The angle $theta$ which appears in the eigenvalue expression corresponds to the angle of the Euler axis and angle representation. The eigenvector corresponding with the eigenvalue of 1 is the accompanying Euler axis, since the axis is the only (nonzero) vector which remains unchanged by left-multiplying (rotating) it with the rotation matrix.

Two successive rotations represented by matrices $mathbf\left\{A\right\}_1$ and $mathbf\left\{A\right\}_2$ are easily combined as follows: $mathbf\left\{A\right\}_text\left\{total\right\} = mathbf\left\{A\right\}_2mathbf\left\{A\right\}_1$ (Note the order, since the vector being rotated is multiplied from the right). The ease by which vectors can be rotated using a DCM, as well as the ease of combining successive rotations, make the DCM a very useful and popular way to represent rotations, even though it is less concise than other representations.

## Euler axis and angle (rotation vector)

From Euler's rotation theorem we know that any rotation can be expressed as a single rotation about some axis. The axis is the unit vector (unique except for sign) which remains unchanged by the rotation. The magnitude of the angle is also unique, with its sign being determined by the sign of the rotation axis.

The axis can be represented as a three-dimensional unit vector $hat\left\{mathbf\left\{e\right\}\right\} = \left[e_x e_y e_z\right]^T$ , and the angle by a scalar $theta ,$.

Since the axis is normalized, it has only two degrees of freedom. The angle adds the third degree of freedom to this rotation representation.

A similar but more concise way to express rotation is by using a rotation vector, a non-normalized three-dimensional vector the direction of which specifies the axis, and the length of which is $theta ,$:

$v = theta hat\left\{mathbf\left\{e\right\}\right\}$

If the rotation angle $theta$ is zero, the axis is not uniquely defined. Combining two successive rotations, each represented by an Euler axis and angle, is not straightforward. It is usual to convert to direction cosine matrix (DCM) or quaternion notation, calculate the product, and then convert back to Euler axis and angle.

## Euler angles

The idea behind Euler angles is to split the complete rotation of the coordinate system into three simpler constitutive rotations, in such a way that the complete rotation matrix is the product of three simpler matrices. Notice that the outer matrix will represent a rotation around one of the axis of the reference frame, and the inner matrix represents a rotation around one of the moving frame axis. The middle matrix represent a rotation around an intermediate axis called line of nodes.

Unfortunately, the definition of Euler angles is not unique and in the literature many different conventions are used. These conventions depend on the axes about which the rotations are carried out, and their sequence (since rotations are not commutative).

The convention being used is usually indicated by specifying the axes about which the consecutive rotations (before being composed) take place, referring to them by index (1,2,3) or letter (X,Y,Z). The engineering and robotics communities typically use 3-1-3 Euler angles. Notice that after composing the independent rotations, they do not rotate about the axis anymore. The most external matrix rotates the other two, leaving the second rotation matrix over the line of nodes, and the third one in a frame comoving with the body. There are 3x3x3 = 27 possible definitions for Euler Angle rotations, but not all of them represent real decompositions.

The Euler angles are never expressed in terms of the external frame, or in terms of the co-moving rotated body frame, but in a mixture. Other angle conventions (e.g., Tait-Bryan angles, Fick angles, Helmholtz angles, roll-pitch-yaw, dip-slip-rake, azimuth-elevation-skew) are used to avoid this problem.

## Quaternions

Quaternions (Euler symmetric parameters) have proven very useful in representing rotations due to several advantages above the other representations mentioned in this article.

A quaternion representation of rotation is written as a normalized four dimensional vector $hat\left\{mathbf\left\{q\right\}\right\} = \left[q_1 q_2 q_3 q_4\right]^T$. In terms of the Euler axis $hat\left\{mathbf\left\{e\right\}\right\} = \left[e_x e_y e_z\right]^T$ and angle $theta$ this vector's elements are expressed as follow:

$begin\left\{array\right\}\left\{lcl\right\} q_1 &=& e_xsin\left(theta/2\right) q_2 &=& e_ysin\left(theta/2\right) q_3 &=& e_zsin\left(theta/2\right) q_4 &=& cos\left(theta/2\right) end\left\{array\right\}$

The above definition follows the convention as used in (Wertz 1980) and (Markley 2003). An alternative definition used in some publications defines the "scalar" term as the first quaternion element, with the other elements shifted down one position. (Coutsias 1999), (Schmidt 2001)

Inspection shows that the quaternion parametrization obeys the following constraint:

$q_1^2 + q_2^2 + q_3^2 + q_4^2 = 1.$

The last term (in our definition) is often called the scalar term, which has its origin in quaternions when understood as the mathematical extension of the complex numbers, written as

$a + b i + c j + d k.$ with $\left\{a,b,c,d\right\} in mathbb\left\{R\right\}$,

and where $\left\{i,j,k\right\}$ are the hypercomplex numbers satisfying

$begin\left\{array\right\}\left\{lclclcl\right\} i^2 &=& j^2 &=& k^2 &=& -1 ij &=& -ji &=& k&& jk &=& -kj &=& i&& ki &=& -ik &=& j&& end\left\{array\right\}$

Quaternion multiplication is performed in the same manner as multiplication of complex numbers, except that the order of elements must be taken into account, since multiplication is not commutative. In matrix notation we can write quaternion multiplication as

$tilde\left\{mathbf\left\{q\right\}\right\}otimesmathbf\left\{q\right\} = left\left[\left\{begin\left\{array\right\}\left\{rrrr\right\}$

`   q_4 &  q_3 & -q_2 &  q_1`
`  -q_3 &  q_4 &  q_1 &  q_2`
`   q_2 & -q_1 &  q_4 &  q_3`
`  -q_1 & -q_2 & -q_3 &  q_4`
end{array}} right] left[{begin{array}{c} tilde{q}_1 tilde{q}_2 tilde{q}_3 tilde{q}_4 end{array}} right].

Combining two consecutive quaternion rotations is therefore just as simple as using DCMs. Remember that two successive DCM rotations, $mathbf\left\{A\right\}_1$ followed by $mathbf\left\{A\right\}_2$, are combined as follows:

$mathbf\left\{A\right\}_3 = mathbf\left\{A\right\}_2mathbf\left\{A\right\}_1.$

We can represent this quaternion parameters in a similarly concise way. Please note the inverse ordering of quaternion multiplication when compared to DCM multiplication.

$mathbf\left\{q\right\}_3 = mathbf\left\{q\right\}_1 otimes mathbf\left\{q\right\}_2.$

Quaternions are a very popular parametrization due to the following properties:

• More compact than the DCM representation and less susceptible to round-off errors
• The quaternion elements vary continuously over the unit sphere in $mathbb\left\{R\right\}^4$, (denoted by $S^3$) as the orientation changes, avoiding discontinuous jumps (inherent to three-dimensional parameterizations)
• Expression of the DCM in terms of quaternion parameters involves no trigonometric functions
• It is simple to combine two individual rotations represented as quaternions using a quaternion product

Like DCM's, quaternions must sometimes be re-normalized due to rounding errors, to make sure that they correspond to valid rotations. The computational cost of re-normalizing a quaternion, however, is much less than for normalizing a $3times 3$ DCM.

## Rodrigues parameters

Rodrigues parameters (also called Gibbs vector) can be expressed in terms of Euler axis and angle as follows:

$mathbf\left\{g\right\} = hat\left\{mathbf\left\{e\right\}\right\}tan\left(theta/2\right).$

The Gibbs vector is undefined for $180^circ$ rotations, which is undesirable for global attitude representation.

Modified Rodriguez parameters (MRPs) can be expressed in terms of Euler axis and angle by:

$mathbf\left\{p\right\} = hat\left\{mathbf\left\{e\right\}\right\}tan\left(theta/4\right).$

The modified Rodrigues parametrization shares many characteristics with the rotation vector parametrization, including the occurrence of discontinuous jumps in the parameter space when incrementing the rotation.

## Cayley-Klein parameters

See definition at Wolfram Mathworld

## Conversion formulae between representations

### DCM → Euler angles

The Euler angles $\left(phi,theta,psi\right)$ can be extracted from the rotation matrix $mathbf\left\{A\right\}$ by inspecting the combined DCM (rotation matrix) in analytical form.

Using the x-convention, the 3-1-3 Euler angles $phi$, $theta$ and $psi$ (around the $Z$,$X$ and again the $Z$-axis) can be obtained as follows:

$begin\left\{array\right\}\left\{lcl\right\} phi &=& arctan\left(A_\left\{31\right\},A_\left\{32\right\}\right), theta &=& arccos\left(A_\left\{33\right\}\right), psi &=& -arctan\left(A_\left\{13\right\},A_\left\{23\right\}\right). end\left\{array\right\}$

Note that $arctan\left(a,b\right)$ is equivalent to $arctan\left(a/b\right)$ where we also take into account the quadrant in which the point $\left(a,b\right)$ is in.

### DCM → Euler axis/angle

If the Euler angle $theta$ is not a multiple of $pi$, the Euler axis $hat\left\{mathbf\left\{e\right\}\right\} = \left[e_1 e_2 e_3\right]^T$ and angle $theta$ can be computed from the elements of the rotation matrix $mathbf\left\{A\right\}$ as follow:

$begin\left\{array\right\}\left\{lcl\right\} theta &=& arccosleft\left(\left(A_\left\{11\right\}+A_\left\{22\right\}+A_\left\{33\right\}-1\right)/2right\right), e_1 &=& \left(A_\left\{32\right\}-A_\left\{23\right\}\right)/\left(2sintheta\right), e_2 &=& \left(A_\left\{13\right\}-A_\left\{31\right\}\right)/\left(2sintheta\right), e_3 &=& \left(A_\left\{21\right\}-A_\left\{12\right\}\right)/\left(2sintheta\right). end\left\{array\right\}$

Alternatively, the following method can be used:

Eigen-decomposition of the DCM yields the eigenvalues $1$, and $costheta pm isintheta$. The Euler axis is the eigenvector corresponding to the eigenvalue of $1$, and the $theta$ can be computed from the remaining eigenvalues.

The Euler axis can be also found using Singular Value Decomposition since it is the normalized vector spanning the null-space of the matrix $I-A$.

### DCM → quaternion

When computing a quaternion from the DCM parametrization there is a sign ambiguity, since $mathbf\left\{q\right\}$ and $-mathbf\left\{q\right\}$ represent the same rotation.

One way of computing the quaternion $mathbf\left\{q\right\} = \left[q_1 q_2 q_3 q_4\right]^T$ from the rotation matrix $mathbf\left\{A\right\}$ is as follows:

$begin\left\{array\right\}\left\{lcl\right\} q_4 &=& pmfrac\left\{1\right\}\left\{2\right\}sqrt\left\{1+A_\left\{11\right\}+A_\left\{22\right\}+A_\left\{33\right\}\right\}, q_1 &=& frac\left\{1\right\}\left\{4q_4\right\}\left(A_\left\{32\right\}-A_\left\{23\right\}\right), q_2 &=& frac\left\{1\right\}\left\{4q_4\right\}\left(A_\left\{13\right\}-A_\left\{31\right\}\right), q_3 &=& frac\left\{1\right\}\left\{4q_4\right\}\left(A_\left\{21\right\}-A_\left\{12\right\}\right). end\left\{array\right\}$

There are three other mathematically equivalent ways to compute $mathbf\left\{q\right\}$. Numerical inaccuracy can be reduced by avoiding situations in which the denominator (in this case $q_4$) is close to zero. For small angles $q_4 approx 1$. One of the other three methods looks as follows:

$begin\left\{array\right\}\left\{lcl\right\} q_1 &=& pmfrac\left\{1\right\}\left\{2\right\}sqrt\left\{1+A_\left\{11\right\}-A_\left\{22\right\}-A_\left\{33\right\}\right\}, q_2 &=& frac\left\{1\right\}\left\{4q_1\right\}\left(A_\left\{12\right\}+A_\left\{21\right\}\right), q_3 &=& frac\left\{1\right\}\left\{4q_1\right\}\left(A_\left\{13\right\}+A_\left\{31\right\}\right), q_4 &=& frac\left\{1\right\}\left\{4q_1\right\}\left(A_\left\{23\right\}-A_\left\{32\right\}\right). end\left\{array\right\}$

### Euler angles → DCM

We will consider the Euler Angle x-convention for the following algorithm.

The DCM of the complete rotation, $mathbf\left\{A\right\}$, is the matrix product of the three matrices for the individual rotations. The first rotation's matrix is on the right and the last on the left, since we left-multiply the orientation vector by the rotation matrix.

$mathbf\left\{A\right\} = mathbf\left\{A\right\}_3mathbf\left\{A\right\}_2mathbf\left\{A\right\}_1.$

If we use the general convention instead of the x-convention, the order of multiplication is reversed (this can be proven by writing out the equations).

The axes of the rotation depend on the specific convention being used. For rotations about the $X$, $Y$ and $Z$ axes with angles $phi$, $theta$ and $psi$, the individual matrices are as follows:

$begin\left\{array\right\}\left\{lcl\right\} mathbf\left\{A\right\}_X &=& left\left[begin\left\{array\right\}\left\{ccc\right\} 1 & 0 & 0 0 & cosphi & sinphi 0 & -sinphi & cosphi end\left\{array\right\} right\right], mathbf\left\{A\right\}_Y &=& left\left[begin\left\{array\right\}\left\{ccc\right\} costheta & 0 & -sintheta 0 & 1 & 0 sintheta & 0 & costheta end\left\{array\right\} right\right], mathbf\left\{A\right\}_Z &=& left\left[begin\left\{array\right\}\left\{ccc\right\} cospsi & sinpsi & 0 -sinpsi & cospsi & 0 0 & 0 & 1 end\left\{array\right\} right\right]. end\left\{array\right\}$

### Euler angles → quaternion

We will consider the x-convention 3-1-3 Euler Angles for the following algorithm.

We can compute the quaternion $mathbf\left\{q\right\} = \left[q_1 q_2 q_3 q_4\right]^T$ from the Euler angles $\left(phi,theta,psi\right)$ as follows:

$begin\left\{array\right\}\left\{lcl\right\} q_1 &=& -cosleft\left(\left(phi-psi\right)/2right\right)sin\left(theta/2\right), q_2 &=& sinleft\left(\left(phi-psi\right)/2right\right)sin\left(theta/2\right), q_3 &=& -sinleft\left(\left(phi+psi\right)/2right\right)cos\left(theta/2\right), q_4 &=& cosleft\left(\left(phi+psi\right)/2right\right)cos\left(theta/2\right). end\left\{array\right\}$

Warning: The above formulae are wrong. Consider Euler angles rotation $\left(0,0,phi\right)$. The above gives $q_3 = -sinleft\left(phi/2right\right)$ instead of $q_3 = sinleft\left(phi/2right\right)$

### Euler axis/angle → DCM

The DCM corresponding to an Euler axis $hat\left\{mathbf\left\{e\right\}\right\} = \left[e_1 e_2 e_3\right]^T$ and angle $theta$ can be computed as follows:

$mathbf\left\{A\right\} = mathbf\left\{I\right\}_3costheta + \left(1-costheta\right)hat\left\{mathbf\left\{e\right\}\right\}hat\left\{mathbf\left\{e\right\}\right\}^T - mathbf\left\{mathcal\left\{E\right\}\right\}sintheta$

with $mathbf\left\{I\right\}_3$ the $3times3$ identity matrix, and

$mathbf\left\{mathcal\left\{E\right\}\right\} = left\left[begin\left\{array\right\}\left\{ccc\right\} 0 & -e_3 & e_2 e_3 & 0 & -e_1 -e_2 & e_1 & 0 end\left\{array\right\} right\right].$

### Euler axis/angle → quaternion

Given the Euler axis $hat\left\{mathbf\left\{e\right\}\right\}$ and angle $theta$, the quaternion $mathbf\left\{q\right\} = \left[q_1 q_2 q_3 q_4\right]^T$ can be computed by

$begin\left\{array\right\}\left\{lcl\right\} q_1 &=& hat\left\{e\right\}_1sin\left(theta/2\right), q_2 &=& hat\left\{e\right\}_2sin\left(theta/2\right), q_3 &=& hat\left\{e\right\}_3sin\left(theta/2\right), q_4 &=& cos\left(theta/2\right). end\left\{array\right\}$

### Quaternion → DCM

The DCM corresponding to the quaternion $mathbf\left\{q\right\} = \left[q_1 q_2 q_3 q_4\right]^T$ can be computed as follows:

$mathbf\left\{A\right\} = \left(q_4^2 - check\left\{mathbf\left\{q\right\}\right\}^Tcheck\left\{mathbf\left\{q\right\}\right\}\right)mathbf\left\{I\right\}_3 + 2check\left\{mathbf\left\{q\right\}\right\}check\left\{mathbf\left\{q\right\}\right\}^T - 2q_4mathbf\left\{mathcal\left\{Q\right\}\right\}$

with $mathbf\left\{I\right\}_3$ the $3times3$ identity matrix, and

$check\left\{mathbf\left\{q\right\}\right\} = left\left[begin\left\{array\right\}\left\{c\right\} q_1q_2q_3end\left\{array\right\} right\right], mathbf\left\{mathcal\left\{Q\right\}\right\} = left\left[begin\left\{array\right\}\left\{ccc\right\} 0 & -q_3 & q_2 q_3 & 0 & -q_1 -q_2 & q_1 & 0 end\left\{array\right\} right\right]$

which gives

$mathbf\left\{mathcal\left\{A\right\}\right\} = left\left[begin\left\{array\right\}\left\{ccc\right\} 1-2q_2^2-2q_3^2 & 2\left(q_1*q_2-q_3*q_4\right) & 2\left(q_1*q_3+q_2*q_4\right) 2\left(q_1*q_2+q_3*q_4\right) & 1-2q_1^2-2q_3^2 & 2\left(q_2*q_3-q_1*q_4\right) 2\left(q_1*q_3-q_2*q_4\right) & 2\left(q_1*q_4+q_2*q_3\right) & 1-2q_1^2-2q_2^2 end\left\{array\right\} right\right]$

or equivelently

$mathbf\left\{mathcal\left\{A\right\}\right\} = left\left[begin\left\{array\right\}\left\{ccc\right\} -1+2q_1^2+2q_4^2 & 2\left(q_1*q_2-q_3*q_4\right) & 2\left(q_1*q_3+q_2*q_4\right) 2\left(q_1*q_2+q_3*q_4\right) & -1+2q_2^2+2q_4^2 & 2\left(q_2*q_3-q_1*q_4\right) 2\left(q_1*q_3-q_2*q_4\right) & 2\left(q_1*q_4+q_2*q_3\right) & -1+2q_3^2+2q_4^2 end\left\{array\right\} right\right]$.

### Quaternion → Euler angles

Given the quaternion $mathbf\left\{q\right\} = \left[q_1 q_2 q_3 q_4\right]^T$, the x-convention 3-1-3 Euler angles $\left(phi,theta,psi\right)$ can be computed by

$begin\left\{array\right\}\left\{lcl\right\} phi &=& arctan\left(\left(q_1q_3+q_2q_4\right),\left(q_2q_3-q_1q_4\right)\right), theta &=& arccos\left(-q_1^2-q_2^2+q_3^2+q_4^2\right), psi &=& -arctan\left(\left(q_1q_3-q_2q_4\right),\left(q_2q_3+q_1q_4\right)\right). end\left\{array\right\}$

Warning: The above formulae are wrong. Consider a rotation about the z-axis, i.e. $q_1 = q_2 =0$. Then we get $phi = theta = psi = 0$.

### Quaternion → Euler axis/angle

Given the quaternion $mathbf\left\{q\right\} = \left[q_1 q_2 q_3 q_4\right]^T$, define $check\left\{mathbf\left\{q\right\}\right\} = \left[q_1 q_2 q_3\right]^T$. Then the Euler axis $hat\left\{mathbf\left\{e\right\}\right\}$ and angle $theta$ can be computed by

$begin\left\{array\right\}\left\{lcl\right\} hat\left\{mathbf\left\{e\right\}\right\} &=& frac\left\{check\left\{mathbf\left\{q\right\}\right\}\right\}\left\{|check\left\{mathbf\left\{q\right\}\right\}|\right\}, theta &=& 2arccos\left(q_4\right). end\left\{array\right\}$

## References

• Evangelos A. Coutsias and Louis Romero, (1999) The Quaternions with an application to Rigid Body Dynamics, Department of Mathematics and Statistics, University of New Mexico.
• F. Landis Markley, (2003) Attitude Error Representations for Kalman Filtering, Journal of Guidance, Control and Dynamics.
• H. Goldstein, (1980) Classical Mechanics, 2nd. ed., Addison-Wesley. ISBN 0-201-02918-9
• James R. Wertz, (1980) Spacecraft Attitude Determination and Control, D Reidel Publishing Company. ISBN 90-277-1204-2
• J. Schmidt and H. Niemann, (2001) Using Quaternions for Parametrizing 3-D Rotations in Unconstrained Nonlinear Optimization, Vision, Modeling and Visualization (VMV01).
• Lev D. Landau and E. M. Lifshitz, (1976) Mechanics, 3rd. ed., Pergamon Press. ISBN 0-08-021022-8 (hardcover) and ISBN 0-08-029141-4 (softcover).
• Klumpp, A. R., Singularity-Free Extraction of a Quaternion from a Direction-Cosine Matrix, Journal of Spacecraft and Rockets, vol. 13, Dec. 1976, p. 754, 755.

Search another word or see Rotation representationon Dictionary | Thesaurus |Spanish