In this rigid body dynamics, GNC (guidance, navigation, and control), and physics tutorial, we provide a clear explanation of Euler angles. In this tutorial, we focus on the so-called Z-X’-Z” Euler angles, and in the second part of this tutorial, we will focus on the Yaw-Pitch-Roll Euler angles. The YouTube tutorial accompanying this post is given below.
Mechanism of Euler Angles
Before we start with explanations, we need to explain the main motivation for creating this tutorial. There are a large number of books on robotics, dynamics, and aerospace topics that cover Euler angles. However, in these books, Euler angles are not properly and clearly graphically explained. Equations are immediately introduced without providing students with the necessary graphical and intuitive understanding of Euler angles. Due to this, in this tutorial, we dedicate special attention to the graphical understanding of Euler angles.
Euler angles are used in many applications. Generally speaking, we use Euler angles to represent the orientation of a rigid body in space. In aerospace applications, orientation is also called attitude. What is the orientation of a rigid body? The orientation of the rigid body is a sequence of rotations with respect to some fixed or translating frame that is used to uniquely define the current rotational state (orientation) of the body. For example, let us assume that we have a body that can rotate with respect to its center of mass. Then, let us arbitrarily rotate this body. Its orientation is a set of mathematical parameters that uniquely describe the current state of rotation of the body with respect to the fixed or inertial frame.
There are several approaches for selecting parameters that describe the orientation of a rigid body. One of the approaches is to use the Euler angles. Euler angles are three angles that are used to sequentially rotate three axes of a rigid body. By using Euler angles we can mathematically describe any rotational state or orientation of a rigid body. That is, Euler angles are used to mathematically represent, or better to say, define the orientation of a rigid body with respect to some coordinate system that is used as the reference.
In addition to three Euler angles, we need additional three parameters to completely define the position and orientation of a rigid body in space. The position of a rigid body in the space is described by three parameters. They are
In the sequel, we thoroughly explain the concept of Euler angles. However, we suggest that you first watch the following video tutorial that graphically explains three Euler angles and three sequential rotations produced by Euler angles.
Next, we thoroughly explain the Euler angles and induced rotations. The graph given below explains the Euler angle convention.
This figure shows a 3D cube that is sequentially rotated 3 times. The initial coordinate system
- In the first rotation, we rotate the cube around the
axis. The rotation angle is . This rotation defines a new coordinate system . - Then, we rotate the cube around the
axis. The angle or rotation is . This rotation defines a new coordinate system . - Finally, we rotate the cube around
axis. The angle or rotation is . This rotation defines the final coordinate system . We performed three sequential rotations.
The angles
Let us introduce the following notation for the coordinate systems in order to simplify the mathematical notation in the sequel:
- The coordinate system
is denoted by . - The coordinate system
is denoted by . - The coordinate system
is denoted by . - The coordinate system
is denoted by .
The Euler angles with the new notation for coordinate systems are shown in the figure below.
Here, we should mention the following. The coordinate system
Next, let us introduce the following notation. Let
(1)
For example, let us assume that the 3D cube is a unit cube. Then, a vertex or a corner of the cube in the coordinate system
(2)
The point determined by this vector is shown in the figure below.
A similar notation is valid for
(3)
We want to address the following problem. We are given the angles of rotation
Let us illustrate this problem with an example. Consider the figure shown below.
To solve this problem, we need to use rotation matrices that are explained in our previous tutorials, given here, here, and here. Let us now look at the rotation
(4)
where
(5)
Next, by using the same logic, from Fig. 2. above, we obtain
(6)
where
(7)
Finally, by using the same logic, from Fig. 2 above, we have
(8)
where
(9)
By combining the equations (4), (6), and (8) we obtain
(10)
The last expression can be written compactly as follows
(11)
where
(12)
The matrix
(13)
where
The equation (11) solves our problem. The Python code given below is used to compute the direction cosine matrix
# -*- coding: utf-8 -*-
"""
Demonstration of rotation matrices and
direction cosine matrix in Python
by using the SymPy library
- Symbolic Python Toolbox
Author: Aleksandar Haber
"""
from sympy import *
init_printing()
theta1=symbols('theta1')
theta2=symbols('theta2')
theta3=symbols('theta3')
Rtheta1=Matrix([[cos(theta1), -sin(theta1), 0],
[sin(theta1), cos(theta1),0],
[0, 0, 1]
])
Rtheta2=Matrix([[1, 0, 0],
[0, cos(theta2), -sin(theta2)],
[0, sin(theta2), cos(theta2)]
])
Rtheta3=Matrix([[cos(theta3), -sin(theta3), 0],
[sin(theta3), cos(theta3),0],
[0, 0, 1]
])
# determine the direction cosine matrix
M=Rtheta1*Rtheta2*Rtheta3
# print(M)
# double check the orthogonality
simplify(M.T*M)
simplify(M.T*M -eye(3))
# generate the latex script
print_latex(M)