# Rotations and Translations in 3D

Current Documentation
View previous documentation
View legacy documentation
All documentation versions

Deprecated in Current Release

# Translations

Let $$\mathbf{X}=\left[\begin{array}{ccc}X&Y&Z\end{array}\right]^{\top}$$ be a point in $$\mathbb{R}^3$$ and let $$\mathbf{X}’=\left[\begin{array}{ccc}X’&Y’&Z’\end{array}\right]^{\top}$$ be $$\mathbf{X}$$ after a translation by $$\left[\begin{array}{ccc}\Delta X&\Delta Y&\Delta Z\end{array}\right]^{\top}$$. Translations may be represented by a single $$4\times4$$ matrix acting on a $$4\times1$$ homogeneous coordinate.

$$\begin{bmatrix}X’\\Y’\\Z’\\1\end{bmatrix}=\begin{bmatrix}1&0&0&\Delta X\\0&1&0&\Delta Y\\0&0&1&\Delta Z\\0&0&0&1\end{bmatrix}\begin{bmatrix}X\\Y\\Z\\1\end{bmatrix}=\begin{bmatrix}X+\Delta X\\Y+\Delta Y\\Z+\Delta Z\\1\end{bmatrix}$$

A translation can be inverted by applying the negative of the translation terms

$$\begin{bmatrix}X\\Y\\Z\\1\end{bmatrix}=\begin{bmatrix}1&0&0&\Delta X\\0&1&0&\Delta Y\\0&0&1&\Delta Z\\0&0&0&1\end{bmatrix}^{-1}\begin{bmatrix}X’\\Y’\\Z’\\1\end{bmatrix}=\begin{bmatrix}1&0&0&-\Delta X\\0&1&0&-\Delta Y\\0&0&1&-\Delta Z\\0&0&0&1\end{bmatrix}\begin{bmatrix}X’\\Y’\\Z’\\1\end{bmatrix}$$

# Rotations

In $$\mathbb{R}^3$$, the rotation of points about the origin are described by a $$3\times3$$ matrix $$\mathbf{R}$$. Valid rotation matrices obey the following properties:

$$\mathrm{det}\left(\mathbf{R}\right) = +1$$

$$\mathbf{R}^{-1}=\mathbf{R}^{\top}$$

From these properties, both the columns and rows of $$\mathbf{R}$$ are orthonormal.

The rotation is applied by left-multipling the points by the rotation matrix.

$$\begin{bmatrix}X’\\Y’\\Z’\end{bmatrix}=\begin{bmatrix}R_{11}&R_{12}&R_{13}\\R_{21}&R_{22}&R_{23}\\R_{31}&R_{32}&R_{33}\end{bmatrix}\begin{bmatrix}X\\Y\\Z\end{bmatrix}=\begin{bmatrix}R_{11}X+R_{12}Y+R_{13}Z\\R_{21}X+R_{22}Y+R_{23}Z\\R_{31}X+R_{32}Y+R_{33}Z\end{bmatrix}$$

Rotations of 3D homogeneous may be defined by a $$4\times4$$ matrix

$$\begin{bmatrix}X’\\Y’\\Z’\\1\end{bmatrix}=\begin{bmatrix}R_{11}&R_{12}&R_{13}&0\\R_{21}&R_{22}&R_{23}&0\\R_{31}&R_{32}&R_{33}&0\\0&0&0&1\end{bmatrix}\begin{bmatrix}X\\Y\\Z\\1\end{bmatrix}$$

Rotation of axes are defined by the inverse (transpose) of the rotation matrix transforming points by the same amount. A rotation of axes is also referred to as a pose. Unless specified, the rest of this page uses implies rotation to be a rotation of points about the origin.

## Basic Rotations

A non-rotation is described by an identity matrix

$$\mathbf{R}_{0}(\theta)=\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}$$

The right-handed rotation of points about the the $$X$$, $$Y$$, and $$Z$$ axes are given by:

$$\mathbf{R}_{X}(\theta)=\begin{bmatrix}1&0&0\\0&\cos\theta&-\sin\theta\\0&\sin\theta&\cos\theta\end{bmatrix}$$

$$\mathbf{R}_{Y}(\theta)=\begin{bmatrix}\cos\theta&0&\sin\theta\\0&1&0\\-\sin\theta&0&\cos\theta\end{bmatrix}$$

$$\mathbf{R}_{Z}(\theta)=\begin{bmatrix}\cos\theta&-\sin\theta&0\\\sin\theta&\cos\theta&0\\0&0&1\end{bmatrix}$$

The inverse of these rotations are given by:

$$\mathbf{R}^{-1}_{X}(\theta)=\mathbf{R}_{X}(-\theta)=\begin{bmatrix}1&0&0\\0&\cos\theta&\sin\theta\\0&-\sin\theta&\cos\theta\end{bmatrix}$$

$$\mathbf{R}^{-1}_{Y}(\theta)=\mathbf{R}_{Y}(-\theta)=\begin{bmatrix}\cos\theta&0&-\sin\theta\\0&1&0\\\sin\theta&0&\cos\theta\end{bmatrix}$$

$$\mathbf{R}^{-1}_{Z}(\theta)=\mathbf{R}_{Z}(-\theta)=\begin{bmatrix}\cos\theta&\sin\theta&0\\-\sin\theta&\cos\theta&0\\0&0&1\end{bmatrix}$$

The rotation of axes by $$\theta$$ radians is equivalent to a rotation of points by $$-\theta$$ radians. The choices of rotation of bases or rotation of points and handedness of the rotation(s) should be specified to all relevant parties to avoid ambiguities in meaning.

## Chaining Rotations

Rotations may be combined in sequence by matrix-multiplying their rotation matrices. When performing sequences of rotations, later rotations are left-multiplied. For example a transform is defined by first rotating by $$\mathbf{R}_1$$, then by $$\mathbf{R}_2$$, and finally by $$\mathbf{R}_3$$, the single rotation $$\mathbf{R}$$ that describes the sequence of rotations is

$$\mathbf{R}=\mathbf{R}_3\mathbf{R}_2\mathbf{R}_1$$

# Rotation-Translation Combinations

## Rotation-Translation Matrices

A rotation about the origin followed by a translation may be described by a single $$4\times4$$ matrix

$$\begin{bmatrix}\mathbf{R}&\mathbf{t}\\\mathbf{0}^{\top}&1\end{bmatrix}$$

where $$\mathbf{R}$$ is the $$3\times3$$ rotation matrix, $$\mathbf{t}$$ is the $$3\times1$$ translation, and $$\mathbf{0}$$ is the $$3\times1$$ vector of zeros.

Since the last row of the $$4\times4$$ rotation-translation matrix is always $$\begin{bmatrix}0&0&0&1\end{bmatrix}$$, they are sometimes shorthanded to a $$3\times4$$ augmented matrix

$$\left[\begin{array}{c|c}\mathbf{R}&\mathbf{t}\end{array}\right]=\left[\begin{array}{ccc|c}R_{11}&R_{12}&R_{13}&t_{1}\\R_{21}&R_{22}&R_{23}&t_{2}\\R_{31}&R_{32}&R_{33}&t_{3}\end{array}\right]$$

Note that when using this shorthand, matrix math is technically being broken as you cannot matrix multiply a $$3\times4$$ matrix with a $$3\times4$$ matrix. It is the implicit last row that is always the same that allows us to get away with this shorthand.

## Rotation-Translation Inverse

The inverse of a rotation-translation matrix is given by

$$\left[\begin{array}{c|c}\mathbf{R}&\mathbf{t}\end{array}\right]^{-1}=\left[\begin{array}{c|c}\mathbf{R}^{-1}&-\mathbf{R}^{-1}\mathbf{t}\end{array}\right]=\left[\begin{array}{c|c}\mathbf{R}^{\top}&-\mathbf{R}^{\top}\mathbf{t}\end{array}\right]$$

## Chaining Rotation-Translations

Just like pure rotation matrices, later rotation-translation transforms are left multiplied. Given transform $$\left[\begin{array}{c|c}\mathbf{R}_1&\mathbf{t}_1\end{array}\right]$$ followed by $$\left[\begin{array}{c|c}\mathbf{R}_2&\mathbf{t}_2\end{array}\right]$$, the resultant transform is

$$\left[\begin{array}{c|c}\mathbf{R}_2&\mathbf{t}_2\end{array}\right]\left[\begin{array}{c|c}\mathbf{R}_1&\mathbf{t}_1\end{array}\right]=\left[\begin{array}{c|c}\mathbf{R}_2\mathbf{R}_1&\mathbf{R}_2\mathbf{t}_1+\mathbf{t}_2\end{array}\right]$$

## Rotations About an Arbitrary Point

A rotation about an arbitrary point may broken up into 3 transforms: a translation so that the arbitrary point becomes the origin, followed by the rotation about the origin, and finally a translation back to the arbitrary point.

$$\left[\begin{array}{c|c}\mathbf{I}&\mathbf{t}\end{array}\right]\left[\begin{array}{c|c}\mathbf{R}&\mathbf{0}\end{array}\right]\left[\begin{array}{c|c}\mathbf{I}&-\mathbf{t}\end{array}\right]=\left[\begin{array}{c|c}\mathbf{R}&\mathbf{t}-\mathbf{R}\mathbf{t}\end{array}\right]$$

# Key Considerations

• Specify if the meaning is a rotation/translation of points or a rotation/translation of axes.
• When working with rotation matrix decompositions, specify the handedness of the rotation.
• When writing a rotation matrix or a rotation-translation matrix parameters out as a list, specify the order (rows-first or columns-first).