Euler Angles



Table of Contents

Rotation is used for describing the pose in a base frame and is expressed as a rotation matrix that has been introduced in previous articles. Actually, there are several ways to numerically express the rotation, except for the rotation matrix, including Euler angles, axis-angle, and unit quaternions. Of course, one representation can be directly or indirectly transformed into another representation. Next, this article will introduce Euler angles and their relationship to the rotation matrix.

Rotation matrix

Rotation matrix was introduced previously, which is constructed by parameters derived from Denavit Hartenberg Convention. Consequently, a rotation can be expressed as a sequence of three elementary rotations, $Rot(x, \alpha), Rot(y, \beta)$ and $Rot(z, \gamma)$. Thus, intuitively, the minimal representation of rotations is only three independent parameters, rather than 9 parameters in the rotation matrix. According to the property of rotation, $RR^T=I$, three independent parameters is enough to represent a rotation, such as Euler angles1.

Euler angles

There are many ways to represent rotations resulting in a rotation matrix, such as ZYX Euler angles (intrinsic rotation), XYZ Euler angles (extrinsic rotation), and so on2. ZYX Euler angles are also known as Tait-Bryan angles (or yaw-pitch-roll) and are used for flying vehicles, while XYZ Euler angles are often used for robotics, also called Cardan angles. They have a similar construction, so XYZ Euler angles are taken as an example here and are collected as

$$ [\alpha, \beta, \gamma]^T $$

where $\alpha, \beta$ and $\gamma$ rotate around $x, y$ and $z$ axes, respectively.

Euler angles to rotation matrix

From the Euler angles, the rotation can be naturally expressed as

$$ \begin{aligned} R &= Rot(x, \alpha)Rot(y, \beta)Rot(z, \gamma) \\ &= \begin{bmatrix}\cos\beta\cos\gamma& -\cos\beta\sin\gamma& \sin\beta \\ \cos\alpha\sin\gamma + \cos\gamma\sin\alpha\sin\beta& \cos\alpha\cos\gamma-\sin\alpha\sin\beta\sin\gamma& -\cos\beta\sin\alpha \\ \sin\alpha\sin\gamma - \cos\alpha\cos\gamma\sin\beta& \cos\gamma\sin\alpha+\cos\alpha\sin\beta\sin\gamma& \cos\alpha\cos\beta \end{bmatrix} \end{aligned} $$

Rotation matrix to Euler angles

Thus, assuming $\beta \in (-\pi/2, \pi / 2)$ and $\cos\alpha \neq 0$, then $\tan\alpha = -R_{23} / R_{33}$ according to the definition of $\tan\alpha = \sin\alpha / \cos\alpha$, where $R_{ij}$ is the element at $i$th row and $j$th column of rotation matrix $R$.

Hint:

$$\frac{-R_{23}}{R_{33}} = \frac{-(-\cos\beta\sin\alpha)}{\cos\alpha\cos\beta} = \frac{\sin\alpha}{\cos\alpha} = \tan\alpha$$

when $\cos \alpha \neq 0$ and $\cos \beta \in (0, 1]$ because of $\beta \in (-\pi / 2, \pi/2)$.

In order to accurately infer the angle $\alpha$, the function $atan2(\sin \alpha, \cos\alpha)$ is a good choice, which returns the angle between $-\pi$ and $\pi$ based on $\sin\alpha$, $\cos \alpha$ and their signs ($+$ or $-$). So, $\alpha$ is derived as $atan2(-R_{23}, R_{33})$. Similarly, $\tan\beta = R_{13} / \sqrt{R^2_{11} + R^2_{12}}$ and $\tan \gamma = -R_{12} / R_{11}$ ($R_{11} \neq 0$). In the end, the inverse solution from a rotation matrix to Euler angles is

$$ \begin{bmatrix} \alpha \\ \beta \\ \gamma \\ \end{bmatrix} = \begin{bmatrix} atan2(-R_{23}, R_{33}) \\ atan2(R_{13}, \sqrt{R^2_{11} + R^2_{12}}) \\ atan2(-R_{12}, R_{11}) \end{bmatrix}. $$

We have to notice that the above result is derived from an assumption that $\cos \beta > 0$. The above transformation from rotation matrix to Euler angles cannot deal with $\beta$ belonging to $[-\pi, -\pi/2]$ or $[\pi/2, \pi]$. Especially, $\beta = \pm \pi /2$ causes the other axes to overlap, which is called Gimbal lock.


  1. 2.4.5 Representation of Rotations. Robot Dynamics Lecture Notes. ↩︎

  2. Euler angles ↩︎