Conversion between quaternions and Euler angles

This is an old revision of this page, as edited by Woohookitty (talk | contribs) at 05:10, 3 July 2005 (Singularities: Stubsensor cleanup project; please see the article_discrepancy section if you wish to). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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.

A unit quaternion can be described as:

where

Similarly for Euler angles, we use:

  • 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

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

 

Conversion

By comparing the terms in the two matrices, we get

 

where   is a notational shortcut for  , and   for  . And for Euler angles we get:

 

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.