Conversion between quaternions and Euler angles
From Wikipedia, the free encyclopedia
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 cos(βx), cos(βy) and cos(βz) are the "direction cosines" locating the axis of rotation (Euler's Theorem).
Similarly for Euler angles, we use the Tait-Bryan angles (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).
[edit] Rotation matrices
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
[edit] Conversion
By comparing the terms in the two matrices, we get
For Euler angles we get:
[edit] Singularities
One must be aware of singularities in the Euler angle parametrization when the pitch approaches (north/south pole). These cases must be handled specially.