Euler Angles: Direction Cosine Matrix to Euler Angles
A direction cosine matrix is a global, nonsingular representation of a three-dimensional orientation.
Euler Angles are local coordinates for that same orientation, and extracting them from a direction
cosine matrix is an inverse-coordinate problem.
The phrase “convert a DCM to Euler angles” is therefore incomplete until an Euler
sequence, a passive or active convention, angle ranges, and a singularity policy have all been
specified.
PhysicsLibrary uses the passive coordinate map
and intrinsic moving-axis Euler sequences. For a generic intrinsic i-j-k sequence,
This article develops a systematic inverse procedure for both Euler families, derives
the important intrinsic 3-2-1 and 3-1-3 cases in detail, gives extraction formulas for
all twelve standard sequences, explains branch selection and singularity handling, and
develops software checks appropriate for physics, navigation, mechanics, robotics, and
simulation.
1 Why the inverse problem is sequence dependent
A DCM contains the orientation itself. Euler angles contain coordinates of that orientation in a
selected chart.
Consequently, the same matrix C can be assigned one Euler triple under a 3-2-1 convention,
another under a 3-1-3 convention, and still others under the remaining ten standard
sequences.
The inverse problem is therefore not
It is instead
This distinction is essential in software. A numerically correct atan2 formula used with the wrong
sequence still returns the wrong physical interpretation.
2 The DCM should be a proper rotation matrix
Before Euler extraction, the supplied matrix should satisfy
and
In floating point software these equalities are tested with tolerances.
A useful orthogonality residual is
together with the determinant error
If the matrix comes from noisy measurements rather than exact attitude propagation, it may need
to be projected back onto the rotation group before Euler angles are extracted.
If
is a singular value decomposition of the measured matrix, a nearest proper orthogonal matrix in
the Frobenius norm is
Euler extraction should then be performed on C, not directly on an arbitrary nonorthogonal
M.
3 A practical extraction workflow
Figure. A robust DCM-to-Euler workflow. Sequence selection, singularity detection,
branch handling, angle wrapping, and DCM reconstruction are all part of the inverse
transformation.
The core steps are:
- identify the passive/active convention and DCM map direction;
- select the Euler sequence;
- verify that the matrix is a valid proper rotation matrix;
- extract the middle angle from the sequence-specific sine or cosine structure;
- determine whether the orientation is near a sequence singularity;
- away from singularity, recover the outer angles with atan2;
- at singularity, apply an explicit and documented branch policy;
- wrap the reported angles into the chosen principal ranges;
- reconstruct the DCM and compare it with the input.
The reconstruction check is one of the most effective convention diagnostics available.
4 Two Euler families, two middle-angle structures
The twelve standard sequences divide into two families.
4.1 Tait Bryan sequences
The six Tait Bryan sequences use three different axes:
Their middle angle is naturally placed on the principal branch
On this branch,
One DCM element carries ± sin β, while a pair of other elements carries a common factor
cos β.
The singular configurations occur when
or
4.2 Proper Euler sequences
The six proper Euler sequences repeat the first axis as the third:
A standard middle-angle branch is
On this branch,
The repeated-axis diagonal element carries cos β, while a pair of off-diagonal elements carries the
common factor sin β.
The singular configurations occur when
or
Figure. Common principal branches for the two Euler families. The red endpoints are
coordinate singularities; the physical orientation itself remains well defined there.
5 Why atan2 is preferred
If
with r > 0, then
recovers the correct quadrant.
Using
instead loses quadrant information and fails when x = 0.
For Euler extraction, the outer-angle formulas are therefore written with atan2.
The middle angle can also be written with atan2 rather than only arcsin or arccos. This has two
practical advantages:
- it uses both sine-like and cosine-like information;
- it reduces the need to clamp a single matrix element before applying an inverse
trigonometric function.
When arcsin or arccos is used in floating point code, its argument should still be clamped to the
interval [−1, 1] to protect against roundoff.
6 Detailed derivation for intrinsic 3-2-1
For aerospace yaw-pitch-roll,
and
The passive DCM is
Here
and similarly for the other angles.
6.1 Middle angle
The element
gives
on the principal branch.
A more robust principal-branch form is obtained from
Since cos 𝜃 ≥ 0 on −π∕2 ≤ 𝜃 ≤ π∕2,
6.2 Yaw
Away from singularity,
Because the common factor c𝜃 is positive in the interior of the principal branch,
6.3 Roll
Likewise,
so
Thus the nonsingular extraction map is
7 Detailed derivation for intrinsic 3-1-3
For the proper Euler sequence
The full matrix is
7.1 Middle angle
The repeated-axis diagonal element is
Therefore
on 0 ≤ β ≤ π.
Because
and sin β ≥ 0 on the principal branch,
7.2 First outer angle
Away from sin β = 0,
Hence
7.3 Third outer angle
Likewise,
so
8 A visual comparison of the 3-2-1 and 3-1-3 element patterns
Figure. The DCM elements used for two important inverse maps. The pattern is
sequence-specific: 3-2-1 uses one set of rows and columns, while 3-1-3 uses another.
The comparison illustrates a general lesson:
Do not memorize one “DCM-to-Euler” formula and then change the angle names.
The matrix elements themselves depend on the sequence.
9 Extraction formulas for all six Tait Bryan sequences
For the following table,
and the intrinsic sequence is
The listed middle-angle formulas use the common principal branch
| Sequence | First angle α | Middle angle β | Third angle γ |
|
|
|
|
| 1-2-3 | atan2(−C32,C33) | atan2 | atan2(−C21,C11) |
| 1-3-2 | atan2(C23,C22) | atan2 | atan2(C31,C11) |
| 2-1-3 | atan2(C31,C33) | atan2 | atan2(C12,C22) |
| 2-3-1 | atan2(−C13,C11) | atan2 | atan2(−C32,C22) |
| 3-1-2 | atan2(−C21,C22) | atan2 | atan2(−C13,C33) |
| 3-2-1 | atan2(C12,C11) | atan2 | atan2(C23,C33) |
Each row is valid away from its Tait Bryan singularity
10 Extraction formulas for all six proper Euler sequences
For proper Euler sequences, the middle-angle principal branch is
| Sequence | First angle α | Middle angle β | Third angle γ |
|
|
|
|
| 1-2-1 | atan2(C12,−C13) | atan2 | atan2(C21,C31) |
| 1-3-1 | atan2(C13,C12) | atan2 | atan2(C31,−C21) |
| 2-1-2 | atan2(C21,C23) | atan2 | atan2(C12,−C32) |
| 2-3-2 | atan2(C23,−C21) | atan2 | atan2(C32,C12) |
| 3-1-3 | atan2(C31,−C32) | atan2 | atan2(C13,C23) |
| 3-2-3 | atan2(C32,C31) | atan2 | atan2(C23,−C13) |
Each row is valid away from
11 How the table can be checked rather than memorized
Every extraction row can be verified in three steps.
First, multiply
Second, identify:
- one entry carrying ± sin β for a Tait Bryan sequence, or the repeated-axis diagonal
carrying cos β for a proper Euler sequence;
- one pair proportional to (cos α, sin α);
- one pair proportional to (cos γ, sin γ).
Third, reconstruct the matrix from the extracted angles and verify
to numerical precision.
This is safer than trusting a table copied from a source that may use an active matrix, an opposite
map direction, an extrinsic convention, or a different angle order.
12 Singularities are failures of coordinates, not of orientation
At an Euler singularity the DCM remains a valid proper rotation matrix.
What fails is the independent recovery of all three Euler coordinates.
For Tait Bryan sequences, at
the first and third rotation axes become collinear.
For proper Euler sequences, this occurs at
or
The outer angles then appear only through a sum or difference.
Therefore a singular extractor must not attempt to divide by the vanishing common factor and
pretend that both outer angles remain independently observable.
13 Example singular policy for 3-2-1
For 3-2-1, suppose the software chooses to report
when
At either singular endpoint, a consistent yaw can be recovered from
The returned triple is then one representative of an infinite family of equivalent singular
triples.
Another implementation may instead preserve yaw continuity and solve for roll. Neither policy
changes the physical DCM. The important requirement is that the chosen gauge be explicit and
repeatable.
14 Example singular policy for 3-1-3
For 3-1-3, suppose the software chooses
at singularity.
At
the observable combination is
and
under the chosen γ = 0 gauge.
At
the observable combination is
and the same gauge gives
The equality of these two implementation formulas is a consequence of the chosen gauge; the
underlying coupled combinations are different.
15 Multiple Euler triples for the same orientation
Euler coordinates are not globally unique.
Away from singularity, a Tait Bryan triple has the alternate representation
with outer angles wrapped by integer multiples of 2π as needed.
A proper Euler triple has the alternate representation
The standard principal middle-angle ranges select one representative from these equivalent
branches.
In addition, every outer angle may be shifted by integer multiples of 2π.
Thus DCM-to-Euler extraction is not only an inverse trigonometric operation; it is also a
branch-selection operation.
16 Angle wrapping
A common outer-angle wrap is
A software wrap function should define explicitly how it treats the endpoint ±π.
Discontinuous wrapping can cause apparent angle jumps even when the physical orientation
changes smoothly.
For plotting or operator displays, an unwrapped angle history may be preferable.
For state propagation and estimation, the orientation itself should generally be propagated with a
DCM or quaternion rather than by repeatedly wrapping Euler coordinates.
17 Numerical example: 3-2-1
Consider
For the intrinsic passive 3-2-1 convention,
The pitch is
The roll is
Therefore
Reconstructing
returns the original matrix to the shown numerical precision.
18 Numerical example: 3-1-3
Now consider
For intrinsic passive 3-1-3,
The middle angle is
The third angle is
Thus
Again, the reconstructed matrix agrees with the input.
19 A reconstruction residual
After extracting angles, define
One simple reconstruction metric is
where ∥⋅∥F is the Frobenius norm.
For a well-conditioned nonsingular case and a valid DCM, this residual should be near floating
point roundoff.
A large residual usually indicates one of the following:
- wrong Euler sequence;
- active/passive transpose confusion;
- wrong DCM map direction;
- incorrect sign in an elementary rotation matrix;
- swapped first and third angles;
- a singular branch formula used away from its intended branch;
- a matrix that is not actually a proper rotation matrix.
20 Near-singular conditioning
Even before the exact singularity is reached, Euler extraction can become poorly conditioned.
For Tait Bryan sequences, the outer-angle formulas rely on a factor proportional to
For proper Euler sequences, they rely on
Thus a useful sequence-conditioning indicator is
for Tait Bryan coordinates, and
for proper Euler coordinates.
These are not complete matrix condition numbers, but they expose the coordinate geometry
directly.
As the relevant quantity approaches zero, small DCM perturbations can produce large changes in
the outer Euler coordinates.
21 Software threshold selection
A practical extractor usually defines a singularity threshold such as
for Tait Bryan sequences, where cmid is the recovered magnitude of cos β, or
for proper Euler sequences.
The threshold should not be chosen only from machine epsilon.
It should reflect:
- expected DCM noise;
- numerical precision;
- acceptable angle sensitivity;
- estimator or sensor quality;
- downstream use of the reported Euler angles.
For a display-only channel, switching to the singular branch earlier may be acceptable. For a
high-accuracy estimator, the orientation should usually remain in a nonsingular state
representation and Euler angles should be treated only as derived outputs.
22 Euler angles should not be used as ordinary vector components
If
and
then in general
is not the finite relative attitude.
The correct relative DCM is formed first.
If
and
are two attitudes relative to the same frame A, then
Euler coordinates of that relative attitude are obtained only afterward by applying the selected
extraction map to B2C
B1.
23 Relation to quaternion-based attitude software
A quaternion and DCM can both represent the same orientation without Euler coordinate
singularities.
A common software architecture is therefore
The Euler angles are derived outputs, not the propagated attitude state.
Near an Euler singularity the quaternion and DCM remain well behaved even though the displayed
Euler coordinates become nonunique or rapidly varying.
This is not a failure of the attitude estimator. It is a property of the chosen Euler chart.
24 Implementation pattern
A sequence-aware extraction routine should conceptually perform the following operations.
- Accept C and an explicit sequence identifier.
- Verify or repair orthogonality and determinant.
- Compute the sequence-specific middle-angle sine/cosine quantities.
- Test the appropriate singularity measure.
- If nonsingular, use the corresponding row of the extraction table.
- If singular, apply the sequence’s documented singular policy.
- Wrap the output into the selected principal ranges.
- Reconstruct C.
- Verify the reconstruction residual.
- Return the angles together with diagnostic information such as singularity status or
branch selection.
A production API should avoid silently changing sequence, convention, or branch policy.
25 Verification battery
Before accepting a DCM-to-Euler implementation, test at least the following.
- identity:
- Positive and negative single-axis rotations for every axis used by the sequence.
- A generic nonsingular orientation with all three angles nonzero.
- DCM to Euler to DCM round trip.
- Euler to DCM to Euler round trip on the selected principal branch.
- Angles close to but not exactly at the sequence singularity.
- Exact singular configurations.
- Equivalent nonprincipal Euler triples that produce the same DCM.
- Input DCM transpose, to ensure active/passive errors are detectable.
- A slightly nonorthogonal noisy matrix, if the implementation includes an SO(3)
projection step.
- Angle wrapping across ±π.
- Relative-attitude construction followed by Euler extraction.
For all twelve sequences, a useful automated regression test is
with
required to remain near floating point roundoff for nonsingular test cases.
26 Common pitfalls
- Using the right formula for the wrong sequence. The angle names may look
familiar while the matrix elements are wrong.
- Using an active formula on a passive DCM. The result is typically transposed
or sign reversed.
- Using arctan(y∕x) instead of atan2(y,x). Quadrant information is lost.
- Ignoring the principal branch. Inverse trigonometric functions return one branch,
while the orientation has multiple Euler representations.
- Ignoring singularity. At the singularity the outer angles are not independently
observable.
- Treating a noisy matrix as exactly orthogonal. The inverse trigonometric
arguments may become inconsistent or exceed their mathematical ranges by small
amounts.
- Skipping reconstruction. A DCM rebuild is cheap and catches many convention
errors.
- Subtracting Euler triples to obtain relative attitude. Finite Euler coordinates
are not ordinary vector components.
27 Connection to the surrounding Euler series
The preceding entries develop Euler sequence composition, Tait Bryan angles, proper Euler angles,
intrinsic 3-2-1, and intrinsic 3-1-3.
This article reverses that direction:
becomes
The next topic, Euler-angle singularities, gimbal lock, and nonuniqueness, develops the geometric
reason that no three-parameter Euler chart can provide a globally unique nonsingular coordinate
system for all of SO(3).
28 References and further reading
References
[1] D. M. Henderson, Euler Angles, Quaternions, and Transformation Matrices: Working
Relationships, JSC-12960, NASA Johnson Space Center, 1977. NASA Technical Reports
Server
[2] J. K. Moore, Learn Multibody Dynamics, chapters “Orientation of Reference Frames”
and “Angular Kinematics.” Licensed CC BY 4.0. Learn Multibody Dynamics
[3] J. Diebel, “Representing Attitude: Euler Angles, Unit Quaternions, and Rotation
Vectors,” Stanford University, 2006. Online PDF
License
Unless otherwise noted, this PhysicsLibrary entry is intended for release under the Creative
Commons Attribution ShareAlike 4.0 International license.