|
Euler Angles and quaternions are two common descriptions of three dimensional orientation.
Euler angles are intuitive because they build an orientation from a sequence of elementary rotations. In aerospace applications, yaw, pitch, and roll are especially familiar. Quaternions are less intuitive geometrically, but they are compact, compose efficiently, propagate naturally from angular velocity, and avoid the coordinate singularity of an Euler angle chart.
The main difficulty in converting between them is not the algebra. It is convention management.
This article uses the PhysicsLibrary passive frame convention and develops the intrinsic moving axis - - yaw, pitch, roll sequence.
Let
The intrinsic sequence is:
- rotate the frame by yaw
about the original axis;
- rotate by pitch
about the new moving axis;
- rotate by roll
about the final moving axis.
Under the PhysicsLibrary passive convention, the resulting frame transformation from coordinates into coordinates is
 |
(1) |
The matching unit quaternion is
 |
(2) |
The quaternion and DCM therefore use the same written order.
PhysicsLibrary uses Hamilton multiplication,
with reversed products changing sign.
Quaternion components are displayed scalar first:
 |
(3) |
The canonical passive attitude quaternion maps coordinate components according to
 |
(4) |
For a positive frame rotation through angle about a positive unit axis
,
 |
(5) |
The corresponding elementary passive DCM is denoted
.
The reverse frame quaternion and DCM satisfy
 |
(6) |
 |
(7) |
Three angle orientation sequences are commonly divided into two families.
- Proper Euler sequences repeat one axis. Examples include
- - and - - .
- Tait Bryan sequences use three different axes. Examples include
- - and - - .
The aerospace yaw, pitch, roll sequence treated here is a Tait Bryan sequence.
There are six Tait Bryan sequences and six proper Euler sequences. Conversion formulas depend on which one is selected. A formula for - - must not be applied to - - data merely because the same three angles appear.
An intrinsic sequence uses moving axes. After the first elementary rotation, the next rotation axis moves with the frame.
An extrinsic sequence uses axes fixed in the reference frame.
The intrinsic sequence
with angles
is geometrically equivalent to an extrinsic sequence about fixed axes
with angles
This equivalence does not mean finite rotations commute. It means the same final orientation can be described from two different axis viewpoints.
PhysicsLibrary uses intrinsic moving axis language for the aerospace sequence unless an article explicitly states otherwise.
For roll,
 |
(8) |
For pitch,
 |
(9) |
For yaw,
 |
(10) |
The intrinsic - - frame sequence is therefore represented by
 |
(11) |
Although yaw occurs first in the moving axis geometric construction, its elementary quaternion appears at the right of the final passive product. This is the same order as the associated DCM product.
The following illustration shows the intrinsic moving axis - - sequence.
Figure. The intrinsic - - yaw, pitch, roll frame sequence. Step 1 applies a positive frame yaw about the original axis. Step 2 applies a positive frame pitch about the intermediate moving axis. Step 3 applies a positive frame
roll about the final moving axis. Under the PhysicsLibrary passive convention,
and
The passive elementary axis matrix is
 |
(12) |
The passive elementary axis matrix is
 |
(13) |
The passive elementary axis matrix is
 |
(14) |
Each is the transpose of the familiar positive active elementary rotation matrix for the same axis and angle.
Introduce
and
Multiplying
gives
 |
(15) |
This matrix maps coordinates from the initial frame into the final frame .
Introduce the half angle abbreviations
 |
(16) |
 |
(17) |
 |
(18) |
For compactness in the multiplication below, write
and similarly for and .
Then
and
Multiplying
gives
 |
(19) |
with
 |
(20) |
 |
(21) |
 |
(22) |
 |
(23) |
The scalar component is the same as in the corresponding active quaternion. The three vector components have the opposite sign because the passive frame quaternion is the conjugate of the active rotor representing the same final orientation.
Let
be the Hamilton quaternion that actively rotates a physical vector through the same geometric orientation while the coordinate frame remains fixed.
Then
 |
(24) |
Thus if
then
 |
(25) |
Similarly,
 |
(26) |
This is why many published Euler to quaternion formulas have the same scalar term but the opposite three vector signs from the PhysicsLibrary formulas.
The preceding PhysicsLibrary article defines
Substituting equations (21) through (24) into the quaternion generated DCM must reproduce equation (16).
This provides an important implementation check because the Euler product, quaternion product, and matrix product are three independently useful ways of describing the same passive frame transformation:
 |
(27) |
For the principal nonsingular branch, choose
 |
(28) |
From equation (16),
Therefore
 |
(29) |
When
,
and
Thus
 |
(30) |
Likewise,
and
so
 |
(31) |
These formulas are often the clearest route from a quaternion to Euler angles: first generate the passive DCM using Q09, then extract the angles from the declared DCM sequence.
Using the passive quaternion generated DCM,
and
Therefore the principal - - angles can be recovered from the PhysicsLibrary passive quaternion by
 |
(32) |
 |
(33) |
 |
(34) |
These are the passive PhysicsLibrary versions of the familiar active yaw, pitch, roll extraction formulas.
Let
The passive quaternion formula reduces to
and
Therefore
 |
(35) |
The matching DCM is
 |
(36) |
This agrees with the positive passive frame rotation used as a convention diagnostic in Q07 through Q09.
Let
Then
 |
(37) |
The DCM becomes
 |
(38) |
For
,
Let
Then
 |
(39) |
The DCM becomes
 |
(40) |
For
,
Take
The passive quaternion is obtained from equations (21) through (24). Numerically,
Substitution gives approximately
 |
(41) |
Converting this quaternion to a DCM and then applying equations (30) through (32) recovers the original roll, pitch, and yaw values to numerical roundoff.
This round trip is an important software verification case because all three angles are nonzero.
Euler angles are local coordinates on the orientation manifold rather than a global one to one orientation representation.
For the intrinsic - - sequence, the singularity occurs when
 |
(42) |
At these pitch angles,
The formulas
and
lose independent information because both numerator and denominator pairs collapse.
For
the matrix depends on the combination
For
it depends on the combination
Thus yaw and roll cannot be determined independently at the singular configuration.
The physical orientation remains perfectly well defined. Only the chosen Euler coordinate chart becomes singular.
Unit quaternions do not have this gimbal lock singularity.
Near
small attitude perturbations can produce large numerical changes in the individual yaw and roll angles.
For estimation, simulation, and control, it is therefore usually preferable to propagate and update attitude with quaternions or DCMs and convert to Euler angles primarily for display, operator interfaces, or applications in which the sequence is physically meaningful.
A robust software conversion should also clamp the argument of into the interval when small floating point errors place it just outside that range.
Because
and
represent the same orientation, they must produce the same Euler angles on the same extraction branch.
Every expression in equations (33) through (35) is quadratic in quaternion components. Replacing all four components by their negatives leaves those expressions unchanged.
Therefore
 |
(43) |
up to the ordinary nonuniqueness and branch choices of Euler Angle coordinates.
Even away from gimbal lock, Euler angle triples are not globally unique.
Angles are periodic. Adding to an elementary rotation angle does not change the physical orientation.
There are also alternative triples associated with different branches of the inverse trigonometric functions.
For the principal - - representation, PhysicsLibrary normally chooses
 |
(44) |
 |
(45) |
 |
(46) |
with an explicit singularity policy at
.
When converting between quaternions and Euler angles in software:
- Declare the Euler sequence explicitly. Do not write only “yaw pitch roll” without defining the product.
- Declare whether the Euler rotations are intrinsic moving axis rotations or extrinsic fixed axis rotations.
- Declare the quaternion frame direction. PhysicsLibrary uses
for
coordinates.
- Declare Hamilton multiplication separately from scalar first or scalar last storage.
- Verify the three pure axis cases.
- Verify at least one case with all three Euler angles nonzero.
- Verify quaternion to DCM to Euler and Euler to quaternion to DCM round trips.
- Treat gimbal lock explicitly rather than allowing division or
behavior to define the result accidentally.
- Compare physical orientation rather than raw Euler triples when testing for equality.
- Using the old active PhysicsLibrary formulas.
The current house convention uses passive frame quaternions. A positive elementary frame rotation has a negative quaternion vector part.
- Using the active product order for the passive intrinsic sequence.
PhysicsLibrary uses
- Using the wrong DCM order.
The matching matrix is
- Mixing intrinsic and extrinsic descriptions.
An intrinsic - - sequence is equivalent to an extrinsic - - description with reversed angle order, not to the same verbal sequence about fixed axes.
- Copying quaternion extraction formulas from an active source.
The PhysicsLibrary passive formulas have different signs in the terms that are linear in .
- Confusing component storage with quaternion semantics.
Scalar first versus scalar last storage does not determine Euler sequence, frame direction, or active versus passive interpretation.
- Ignoring gimbal lock.
At
yaw and roll are not independently recoverable.
- Assuming Euler angles are unique.
Different triples can represent the same physical orientation.
- Comparing
and as different attitudes.
They produce the same DCM and the same Euler orientation.
The preceding article, quaternions and direction cosine matrices, establishes
and gives the passive quaternion generated matrix.
The present article combines that DCM relation with an intrinsic moving axis - - sequence to derive yaw, pitch, roll conversion in both directions.
The separate examples entry, Quaternions and Euler Angles: Examples, Exercises, and Solutions, should use the same passive formulas developed here.
The next main article, quaternion kinematics and angular velocity, derives the differential equations that propagate the passive frame quaternion from body or reference resolved angular velocity.
Euler angle conversion formulas are particularly sensitive to frame direction, sequence order, intrinsic versus extrinsic language, and active versus passive interpretation. A formula should therefore be accompanied by its defining matrix or quaternion product.
Henderson provides an important aerospace reference for Euler angle, quaternion, and transformation matrix relationships. Moore provides an openly licensed modern treatment of reference frame orientation. Sommer and coauthors provide a useful convention analysis for Hamilton versus flipped quaternion multiplication and passive frame transformations.
- 1
- D. M. Henderson, Euler Angles, Quaternions, and Transformation Matrices: Working Relationships, JSC-12960, NASA Johnson Space Center, Mission Planning and Analysis Division, 1977. Engineering reference. NASA Technical Reports Server search https://ntrs.nasa.gov/search?q=JSC-12960
- 2
- J. K. Moore, Learn Multibody Dynamics, chapter “Orientation of Reference Frames.” Distributed under CC BY 4.0. Learn Multibody Dynamics https://moorepants.github.io/learn-multibody-dynamics/orientation.html
- 3
- H. Sommer, I. Gilitschenski, M. Bloesch, S. Weiss, R. Siegwart, and J. Nieto, “Why and How to Avoid the Flipped Quaternion Multiplication,” Aerospace, vol. 5, no. 3, article 72, 2018. Published under CC BY 4.0. Publisher article https://www.mdpi.com/2226-4310/5/3/72
- 4
- W. R. Hamilton, Elements of Quaternions, 2nd ed., edited by C. J. Joly, Longmans, Green, and Co., 1899. Public domain historical source. Internet Archive scan https://archive.org/details/elementsofquater01hamiuoft
Unless otherwise noted, this PhysicsLibrary entry is intended for release under the Creative Commons Attribution ShareAlike 4.0 International license.
|