# Conversion between quaternions and Euler angles

*158*pages on

this wiki

Spatial rotations in three dimensions can be parametrized using both Euler angles and unit quaternions. This article explains how to convert between the two representations. Actually this simple use of "quaternions" was first presented by Euler some seventy years earlier than Hamilton to solve the problem of "magic squares." For this reason the dynamics community commonly refers to quaternions in this application as "Euler parameters".

A unit quaternion can be described as:

where is a simple rotation angle and , , are the "direction cosines" locating the axis of rotation (Euler's Theorem).

Similarly for Euler angles, we use (in terms of flight dynamics):

- Roll - : rotation about the X-axis
- Pitch - : rotation about the Y-axis
- Yaw - : rotation about the Z-axis

where the X-axis points forward, Y-axis to the right and Z-axis downward and in the example to follow the rotation occurs in the order yaw, pitch, roll (about body-fixed axes).

## Rotation matrices Edit

The orthogonal matrix corresponding to a rotation by the unit quaternion **q** is given by

The orthogonal matrix corresponding to a rotation with Euler angles , is given by

## Conversion Edit

By comparing the terms in the two matrices, we get poo:

For Euler angles we get:

## Singularities Edit

One must be aware of singularities in the Euler angle parametrization when the pitch approaches (north/south pole). These cases must be handled specially.