Euler Angles

Euler Parameters (Quaternions) representation

A four-element vector with three imaginary and one real component is known as Quaternion. These hypercomplex numbers are optimum for numerical stability and memory load. The Euler parameters are a four-dimensional vector that can be used to represent the orientation of a rigid body. The Euler parameters are defined as:

$$ q = \begin{bmatrix} q_0 \\ q_1 \\ q_2 \\ q_3 \end{bmatrix} $$
where $q_0$ is the scalar part and $q_1$, $q_2$, and $q_3$ are the vector part. It could be written as:
$$ q = q_0 + q_1i + q_2j + q_3k $$
where $i$, $j$, and $k$ are the imaginary unit vectors and
$$ i^2 = j^2 = k^2 = ijk = -1 $$
$$ \mathbb{q} = (q_0 , \mathbf{q}_v) $$
where $ \mathbf{q}_v = (q_1 , q_2 , q_3) $ is the vector part of the quaternion. The quaternion is a unit quaternion if $ \mathbb{q} \cdot \mathbb{q}^* = 1 $, where $ \mathbb{q}^* $ is the conjugate of $ \mathbb{q} $.

It is noticeable that some authors may use left-handed quaternions witch is defined by:

$$ \mathbf{q} = iq_1 + jq_2 + kq_3 + q_0 \\ ijk = 1 $$
This representation has no fundamental implications but will change the details of formulation.

Quaternions do not have any singularity such as Euler angles. However, due to the lack of independence of components, it may present difficulties in the application of the filter equations. The quaternion is not unique, and the mirror quaternion will result in the same rotation. This is a purely mathematical representation and based upon single rotation theta around vector e with angle. It could not be used for visualization.

Quaternion also, can be used to describe the axis-angle representation by:

$$ \mathbf{q} = \begin{bmatrix}q_w \\ q_x \\ q_y \\ q_z\end{bmatrix} = \begin{bmatrix} \cos\frac{\theta}{2} \\ v_x \sin\frac{\theta}{2} \\ v_y \sin\frac{\theta}{2} \\ v_z \sin\frac{\theta}{2} \end{bmatrix} = \begin{bmatrix} \cos\frac{\theta}{2} \\ \mathbf{v} \sin\frac {\theta}{2} \end{bmatrix} $$
Also, the quaternion can be expressed in $4 \times 4$ skew-symmetric matrix form
$$ Q = \begin{bmatrix} q_0 & -q_1 & -q_2 & -q_3 \\ q_1 & q_0 & -q_3 & q_2 \\ q_2 & q_3 & q_0 & -q_1 \\ q_3 & -q_2 & q_1 & q_0 \end{bmatrix} $$
The quaternion represents the attitude of frame $A$ relative to frame $B$ defined by the following equation:
$$ {}^{A}_{B}\mathbf{q}={}^{B}_{A}\mathbf{q}^* $$

where $ {}^{A}_{B}\mathbf{q} $ is the quaternion that represents the attitude of frame $ A $ relative to frame $ B $.

$ {}^{B}_{A}\mathbf{q}^* $ is the conjugate of the quaternion that represents the attitude of frame $ A $ relative to frame $ B $. The $ \mathbf{q}^* $ (conjugate of the quaternion $ \mathbf{q} $) gives the inverse rotation.

The relationship between quaternions and Euler angles based on $zyx$ sequence can be calculated using the following:

$$ \mathbf{q} = \begin{bmatrix} \cos\frac{\theta_x}{2} \cos\frac{\theta_y}{2} \cos\frac{\theta_z}{2} + \sin\frac{\theta_x}{2} \sin\frac{\theta_y}{2} \sin\frac{\theta_z}{2} \\ \sin\frac{\theta_x}{2} \cos\frac{\theta_y}{2} \cos\frac{\theta_z}{2} - \cos\frac{\theta_x}{2} \sin\frac{\theta_y}{2} \sin\frac{\theta_z}{2} \\ \cos\frac{\theta_x}{2} \sin\frac{\theta_y}{2} \cos\frac{\theta_z}{2} + \sin\frac{\theta_x}{2} \cos\frac{\theta_y}{2} \sin\frac{\theta_z}{2} \\ \cos\frac{\theta_x}{2} \cos\frac{\theta_y}{2} \sin\frac{\theta_z}{2} - \sin\frac{\theta_x}{2} \sin\frac{\theta_y}{2} \cos\frac{\theta_z}{2} \end{bmatrix} $$
where $ \theta_x $, $ \theta_y $, and $ \theta_z $ are the Euler angles.

Also, the Euler angles can be calculated using the following: