## Positive rotation direction

According to the “Right Hand Rule”, the positive direction for rotations is clockwise in the axis direction.

## Euler angles

Euler angles are a commonly used representation of spatial orientation. Euler angles are in fact a composition of rotation from the Local Geodetic Coordinates System. This orientation is defined by the sequence of the three rotations around the Local Frame X, Y and Z axes.

Euler angles are widely used because they are easy to understand. The three parameters : Roll, Pitch and Yaw define rotations around the fixed frame's axes :

• Roll (φ) : Rotation around X axis defined between [-π ; π] ;
• Pitch (θ) : Rotation around Y axis defined between [-π/2 ; π/2] ;
• Yaw (ψ) : Rotation around Z axis defined between [-π ; π].

Gimbal Lock effect

As Euler angles suffer from a singularity called "Gimbal lock”, when Pitch approaches ± π/2,we do not advise to use Euler angles if the device has to be used in a wide range of orientations. Quaternions and rotation matrices do not have any singularity.

## Quaternions

Quaternions are an extension of complex numbers as defined here :

$$Q = q_{0} + i \cdot q_{1} + j \cdot q_{2} + k \cdot q_{3}$$

Where i, j, k are imaginary numbers.

We also can define the complex conjugate of Q :

$$\overline Q = q_{0} - i \cdot q_{1} - j \cdot q_{2} - k \cdot q_{3}$$

And the norm of Q :

$$\| Q \| = \sqrt{Q \cdot \overline Q}$$

Particular quaternions such as |Q| = 1 can represent a complete definition of the 3D orientation without any singularity.

Quaternions algebra do not require a lot of computational resources, they are therefore very efficient for orientation representation.

The inverse rotation of Q is defined by its complex conjugate.

## Rotation matrix (Direction Cosine Matrix)

The Direction Cosine Matrix (DCM) is a rotation matrix that transforms one coordinate reference frame to another. Rotation matrices are a complete representation of a 3D orientation, thus there is no singularity in that model.

A DCM locates three unit vectors that define a coordinate frame. Here the DCM transforms the body coordinate frame to the Local NED coordinates. The DCM is the combination of the three rotation matrices RM(φ), RM(θ) and RM(ψ) respectively around Local Geodetic (NED) X, Y and Z axes :

$$DCM = RM_{\psi} \cdot RM_{\theta} \cdot RM_{\varphi}$$
$$DCM = \begin{pmatrix} \cos \psi & - \sin \psi & 0 \\ \sin \psi & \cos \psi & 0 \\ 0 & 0 & 1 \end{pmatrix} \cdot \begin{pmatrix} \cos \theta & 0 & \sin \theta \\ 0 & 1 & 0 \\ - \sin \theta & 1 & \cos \theta \\ \end{pmatrix} \cdot \begin{pmatrix} 1 & 0 & 0 \\ 0 & \cos \varphi & - \sin \varphi \\ 0 & \sin \varphi & \cos \varphi \end{pmatrix}$$
$$DCM = \begin{pmatrix} \cos \theta \cdot \cos \psi & \sin \varphi \cdot \sin \theta \cdot \cos \psi - \cos \varphi \cdot \sin \psi & \cos \varphi \cdot \sin \theta \cdot \cos \psi + \sin \varphi \cdot \sin \psi \\ \cos \theta \cdot \sin \psi & \sin \varphi \cdot \sin \theta \cdot \sin \psi + \cos \varphi \cdot \cos \psi & \cos \varphi \cdot \sin \theta \cdot \sin \psi - \sin \varphi \cdot \cos \psi \\ \ - \sin \theta & \sin \varphi \cdot \cos \theta & \cos \varphi \cdot \cos \theta \end{pmatrix}$$

As for any rotation matrix, the inverse rotation equals to the transposed matrix:

$$DCM^{-1} = DCM^{T}$$

In order to transform a vector expressed in the Body coordinate system into the NED frame, user will use the DCM as expressed below:

$$V_{NED} = DCM \cdot V_{body}$$

Reciprocally:

$$V_{body} = DCM^{T} \cdot V_{NED}$$

## Other useful conversion formulas

Some other conversion formulas can be useful for many users, and are listed below:

### Quaternions to DCM

It may be useful to compute a DCM based on the quaternions parameters :

$$DCM = \begin{pmatrix} 2 \cdot q_{0}^{2} + 2 \cdot q_{1}^{2} - 1 & 2 \cdot q_{1} \cdot q_{2} - 2 \cdot q_{0} \cdot q_{3} & 2 \cdot q_{0} \cdot q_{2} + 2 \cdot q_{1} \cdot q_{3} \\ 2 \cdot q_{1} \cdot q_{2} + 2 \cdot q_{0} \cdot q_{3} & 2 \cdot q_{0}^{2} + 2 \cdot q_{2}^{2} - 1 & 2 \cdot q_{2} \cdot q_{3} - 2 \cdot q_{0} \cdot q_{1} \\ 2 \cdot q_{1} \cdot q_{3} - 2 \cdot q_{0} \cdot q_{2} & 2 \cdot q_{2} \cdot q_{3} + 2 \cdot q_{0} \cdot q_{1} & 2 \cdot q_{0}^{2} + 2 \cdot q_{3}^{2} - 1 \end{pmatrix}$$

### Quaternions to Euler

Here is quaternions translated into Euler angles.

$$\varphi = \tan^{-1}{\left( \dfrac{2 \cdot q_{2} \cdot q_{3} + 2 \cdot q_{0} \cdot q_{1}}{2 \cdot q_{0}^{2} + 2 \cdot q_{3}^{2} - 1}\right)}$$
$$\theta = \sin^{-1}{\left( 2 \cdot q_{1} \cdot q_{3} - 2 \cdot q_{0} \cdot q_{2}\right)}$$
$$\psi = \tan^{-1}{\left( \dfrac{2 \cdot q_{1} \cdot q_{2} + 2 \cdot q_{0} \cdot q_{3}}{2 \cdot q_{0}^{2} + 2 \cdot q_{1}^{2} - 1}\right)}$$

### DCM to Euler

Finally, DCM matrixis converted into Euler angles.

$$\varphi = \tan^{-1}{\left( \dfrac{DCM_{32}}{DCM_{33}}\right)}$$
$$\theta = \sin^{-1}{\left( DCM_{31} \right)}$$
$$\psi = \tan^{-1}{\left( \dfrac{DCM_{21}}{DCM_{11}}\right)}$$