Physics Library
 An open source physics library
Encyclopedia | Forums | Docs | Random |  
Login
create new user
Username:
Password:
forget your password?
Main Menu
Sections

Meta

Talkback

Downloads

Information
Euler angles: direction cosine matrix to Euler angles (Topic)

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

B     B   A
 v =   CA  v,
(1)

and intrinsic moving-axis Euler sequences. For a generic intrinsic i-j-k sequence,

BC   =  C (γ)C  (β)C (α).
   A     k     j    i
(2)

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

C − →  the Euler angles.

It is instead

(C,  sequence, convention, branch  policy) −→  (α, β,γ).

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

CCT  =  I,
(3)

and

detC  = +1.
(4)

In floating point software these equalities are tested with tolerances.

A useful orthogonality residual is

𝜖    = ∥∥CCT   − I∥∥ ,
ortho
(5)

together with the determinant error

𝜖det = |detC −  1|.
(6)

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

M  = U ΣV T

is a singular value decomposition of the measured matrix, a nearest proper orthogonal matrix in the Frobenius norm is

       ⌊                ⌋
        1  0      0
C =  U ⌈0  1      0     ⌉ V T.
        0  0  det(U V T)
(7)

Euler extraction should then be performed on C, not directly on an arbitrary nonorthogonal M.

3 A practical extraction workflow

PIC

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:

  1. identify the passive/active convention and DCM map direction;
  2. select the Euler sequence;
  3. verify that the matrix is a valid proper rotation matrix;
  4. extract the middle angle from the sequence-specific sine or cosine structure;
  5. determine whether the orientation is near a sequence singularity;
  6. away from singularity, recover the outer angles with atan2;
  7. at singularity, apply an explicit and documented branch policy;
  8. wrap the reported angles into the chosen principal ranges;
  9. 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:

123,   132,  213,   231,   312,  321.

Their middle angle is naturally placed on the principal branch

  π-       π-
− 2 ≤ β  ≤ 2 .
(8)

On this branch,

cosβ ≥  0.
(9)

One DCM element carries ± sin β, while a pair of other elements carries a common factor cos β.

The singular configurations occur when

cosβ =  0,
(10)

or

       π
β =  ± -.
       2
(11)

4.2 Proper Euler sequences

The six proper Euler sequences repeat the first axis as the third:

121,   131,  212,   232,   313,  323.

A standard middle-angle branch is

0 ≤ β  ≤ π.
(12)

On this branch,

sin β ≥  0.
(13)

The repeated-axis diagonal element carries cos β, while a pair of off-diagonal elements carries the common factor sin β.

The singular configurations occur when

sin β =  0,
(14)

or

β =  0    or     β = π.
(15)

PIC

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

y =  rsin λ,     x = r cosλ,

with r > 0, then

λ = atan2 (y,x)
(16)

recovers the correct quadrant.

Using

arctan(y∕x )

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

C =  BC   = C (ϕ )C (𝜃)C (ψ ).
        A     1    2     3
(17)

The passive DCM is

     ⌊                                   ⌋
           c𝜃cψ           c𝜃sψ       − s𝜃
C =  ⌈s s c  − c s    s s s +  c c   s c ⌉ .
       ϕ 𝜃 ψ    ϕ ψ    ϕ 𝜃 ψ    ϕ ψ   ϕ 𝜃
      cϕs𝜃cψ + sϕsψ   cϕs 𝜃s ψ − sϕcψ  cϕc𝜃
(18)

Here

cϕ = cosϕ,     sϕ = sinϕ,

and similarly for the other angles.

6.1 Middle angle

The element

C13 =  − sin 𝜃
(19)

gives

𝜃 = − arcsin(C13)
(20)

on the principal branch.

A more robust principal-branch form is obtained from

C2  + C2  =  cos2𝜃.
  11    12
(21)

Since cos 𝜃 0 on π∕2 𝜃 π∕2,

          (      ∘  ---------)
𝜃 = atan2  − C13,   C2 +  C2   .
                     11    12
(22)

6.2 Yaw

Away from singularity,

C11 = c𝜃cψ,     C12 = c𝜃sψ.

Because the common factor c𝜃 is positive in the interior of the principal branch,

ψ = atan2 (C12, C11).
(23)

6.3 Roll

Likewise,

C23 =  sϕc𝜃,    C33 = cϕc𝜃,

so

ϕ = atan2 (C23, C33).
(24)

Thus the nonsingular extraction map is

ψ = atan2 (C12, C11),
(25)

          (      ∘  ---------)
                     2     2
𝜃 = atan2  − C13,   C11 + C12  ,
(26)

ϕ = atan2 (C23, C33).
(27)

7 Detailed derivation for intrinsic 3-1-3

For the proper Euler sequence

     B
C =   CA  = C3(γ )C1 (β)C3 (α ).
(28)

The full matrix is

     ⌊ c c  − c s s    c c s  + c s   s  s ⌋
     ⌈  α γ    β α γ    α β γ    γ α   β  γ⌉
C  =  − cαsγ − cβcγsα  cαcβcγ − sαsγ  cγsβ  .
            sαsβ           − cαsβ      cβ
(29)

7.1 Middle angle

The repeated-axis diagonal element is

C33 = cosβ.
(30)

Therefore

β = arccos(C33)
(31)

on 0 β π.

Because

  2     2       2
C 31 + C 32 = sin β,
(32)

and sin β 0 on the principal branch,

           (∘  ----------   )
β =  atan2     C231 + C232,C33  .
(33)

7.2 First outer angle

Away from sin β = 0,

C31 = sαs β,    C32 =  − cαsβ.

Hence

α = atan2 (C31,− C32).
(34)

7.3 Third outer angle

Likewise,

C13 = sβs γ,    C23 = sβc γ,

so

γ = atan2(C13, C23).
(35)

8 A visual comparison of the 3-2-1 and 3-1-3 element patterns

PIC

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,

C =  BCA,

and the intrinsic sequence is

i- j-k,    C = Ck (γ)Cj(β )Ci(α).

The listed middle-angle formulas use the common principal branch

− π-≤ β  ≤ π-.
  2        2

Sequence First angle α Middle angle β Third angle γ




1-2-3 atan2(C32,C33) atan2(    ∘ ---------)
 C31,  C232 + C233 atan2(C21,C11)
1-3-2 atan2(C23,C22) atan2(      ∘ --2-----2)
 − C21,  C 22 + C 23 atan2(C31,C11)
2-1-3 atan2(C31,C33) atan2(                 )
 − C  ,∘C2---+-C2-
     32     31    33 atan2(C12,C22)
2-3-1 atan2(C13,C11) atan2(    ∘ ---------)
 C12,  C211 + C213 atan2(C32,C22)
3-1-2 atan2(C21,C22) atan2(    ∘ --2-----2)
 C23,  C 21 + C 22 atan2(C13,C33)
3-2-1 atan2(C12,C11) atan2(                 )
 − C  ,∘C2---+-C2-
     13     11    12 atan2(C23,C33)

Each row is valid away from its Tait Bryan singularity

|β | = π-.
      2
(36)

10 Extraction formulas for all six proper Euler sequences

For proper Euler sequences, the middle-angle principal branch is

0 ≤ β  ≤ π.

Sequence First angle α Middle angle β Third angle γ




1-2-1 atan2(C12,C13)atan2(∘  ---------    )
    C212 + C213,C11 atan2(C21,C31)
1-3-1 atan2(C13,C12) atan2(                )
 ∘  -2-----2-
    C12 + C 13,C11atan2(C31,C21)
2-1-2 atan2(C21,C23) atan2(∘  ---------    )
    C221 + C223,C22atan2(C12,C32)
2-3-2 atan2(C23,C21)atan2(∘  -2-----2-    )
    C21 + C 23,C22 atan2(C32,C12)
3-1-3 atan2(C31,C32)atan2(                )
 ∘C2---+-C2--,C
     31    32  33 atan2(C13,C23)
3-2-3 atan2(C32,C31) atan2(∘  ---------    )
    C231 + C232,C33atan2(C23,C13)

Each row is valid away from

β =  0    and     β =  π.
(37)

11 How the table can be checked rather than memorized

Every extraction row can be verified in three steps.

First, multiply

C = Ck (γ)Cj(β )Ci(α).
(38)

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

C^ = C
(39)

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

     π
|β | =--,
      2

the first and third rotation axes become collinear.

For proper Euler sequences, this occurs at

β = 0

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

ϕ = 0

when

|cos 𝜃| < 𝜀.

At either singular endpoint, a consistent yaw can be recovered from

ψ = atan2 (− C21, C22).
(40)

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

γ = 0

at singularity.

At

β = 0,

the observable combination is

α + γ,

and

α = atan2 (C12,C11)
(41)

under the chosen γ = 0 gauge.

At

β =  π,

the observable combination is

α − γ,

and the same gauge gives

α = atan2 (C12, C11).
(42)

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

  ′  ′  ′
(α ,β ,γ ) = (α + π, π − β,γ + π ),
(43)

with outer angles wrapped by integer multiples of 2π as needed.

A proper Euler triple has the alternate representation

(α′,β′,γ′) = (α +  π,− β,γ + π ).
(44)

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

− π < α ≤ π,     − π < γ ≤  π.
(45)

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

     ⌊                                 ⌋
       0.663414    0.556670   0.500000
C =  ⌈− 0.735024   0.609923   0.296198 ⌉ .
      − 0.140077  − 0.564014  0.813798
(46)

For the intrinsic passive 3-2-1 convention,

ψ  = atan2(0.556670, 0.663414 ) = 40∘.
(47)

The pitch is

          (           √ ----------------------)
𝜃 = atan2  − 0.500000,  0.6634142 + 0.5566702   = − 30∘.
(48)

The roll is

ϕ =  atan2(0.296198, 0.813798 ) = 20∘.
(49)

Therefore

              ∘     ∘   ∘
(ψ, 𝜃,ϕ) = (40 ,− 30 ,20 ).
(50)

Reconstructing

 ^         ∘        ∘      ∘
C  = C1 (20  )C2 (− 30 )C3(40 )
(51)

returns the original matrix to the shown numerical precision.

18 Numerical example: 3-1-3

Now consider

    ⌊                              ⌋
      0.95193   0.20876   − 0.22414
C = ⌈ 0.07803   0.54236    0.83652 ⌉ .
      0.29620  − 0.81380   0.50000
(52)

For intrinsic passive 3-1-3,

α = atan2(0.29620, 0.81380 ) = 20∘.
(53)

The middle angle is

          ( ∘ -------2--------------2        )      ∘
β = atan2     0.29620  + (− 0.81380 ) ,0.50000   = 60  .
(54)

The third angle is

                                    ∘
γ = atan2 (− 0.22414, 0.83652 ) = − 15 .
(55)

Thus

(α, β,γ) = (20∘,60 ∘,− 15∘).
(56)

Again, the reconstructed matrix agrees with the input.

19 A reconstruction residual

After extracting angles, define

^C = Ck (γ)Cj(β )Ci(α).
(57)

One simple reconstruction metric is

      ∥∥     ^∥∥
𝜖C =  ∥C − C ∥F ,
(58)

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

|cosβ |.

For proper Euler sequences, they rely on

|sinβ |.

Thus a useful sequence-conditioning indicator is

 − 1
κTB ∼  |cosβ |
(59)

for Tait Bryan coordinates, and

κ−PE1∼  |sin β|
(60)

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

cmid < 𝜀sing
(61)

for Tait Bryan sequences, where cmid is the recovered magnitude of cos β, or

smid < 𝜀sing
(62)

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

     ⌊   ⌋
       α1
e1 = ⌈ β1⌉
       γ
        1

and

     ⌊α  ⌋
     ⌈  2⌉
e2 =   β2  ,
       γ2

then in general

e  − e
 2    1
(63)

is not the finite relative attitude.

The correct relative DCM is formed first.

If

B1
  CA

and

B
 2CA

are two attitudes relative to the same frame A, then

              (     )T
B2CB1 =  B2CA  B1CA    .
(64)

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

IMU  or estimator  −→  q −→  C  −→  Euler display angles.

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.

  1. Accept C and an explicit sequence identifier.
  2. Verify or repair orthogonality and determinant.
  3. Compute the sequence-specific middle-angle sine/cosine quantities.
  4. Test the appropriate singularity measure.
  5. If nonsingular, use the corresponding row of the extraction table.
  6. If singular, apply the sequence’s documented singular policy.
  7. Wrap the output into the selected principal ranges.
  8. Reconstruct C.
  9. Verify the reconstruction residual.
  10. 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.

  1. identity:

    C  = I.
  2. Positive and negative single-axis rotations for every axis used by the sequence.
  3. A generic nonsingular orientation with all three angles nonzero.
  4. DCM to Euler to DCM round trip.
  5. Euler to DCM to Euler round trip on the selected principal branch.
  6. Angles close to but not exactly at the sequence singularity.
  7. Exact singular configurations.
  8. Equivalent nonprincipal Euler triples that produce the same DCM.
  9. Input DCM transpose, to ensure active/passive errors are detectable.
  10. A slightly nonorthogonal noisy matrix, if the implementation includes an SO(3) projection step.
  11. Angle wrapping across ±π.
  12. Relative-attitude construction followed by Euler extraction.

For all twelve sequences, a useful automated regression test is

                    ^
C − →  (α,β,γ ) − → C
(65)

with

     |        |
max  ||Cij − C^ij||
 i,j
(66)

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:

Euler angles −→  DCM

becomes

DCM   − → Euler angles.

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.


"Euler angles: direction cosine matrix to Euler angles" is owned by bloftin.
(view preamble)
View style:
Other names:  direction cosine matrix to Euler angles
Keywords:  Euler angles, direction cosine matrix, DCM, inverse Euler transformation, attitude extraction, 3-2-1, 3-1-3, passive transformation, intrinsic rotation, branch selection, gimbal lock, singularity, numerical attitude

Attachments:
example of Euler angles: direction cosine matrix to Euler angles (Example) by bloftin

Cross-references: system, composition, vector, identity, relative attitude, magnitude, metric, quaternion, operator, operation, observable, function, Tait Bryan sequences, detection, norm, determinant, matrix, mechanics, formulas, Euler Angles, representation, direction cosine matrix
There is 1 reference to this object.

This is version 1 of Euler angles: direction cosine matrix to Euler angles, born on 2026-08-31, modified 2026-08-31.
Object id is 1136, canonical name is EulerAnglesDirectionCosineMatrixToEulerAngles.
Accessed 19 times total.

Classification:
Physics Classification45.40.-f (Dynamics and kinematics of rigid bodies)
 02.40.Yy (Geometric mechanics )
 06.30.Gv (Velocity, acceleration, and rotation)
Pending Errata and Addenda
None.
Discussion
Style: Expand: Order:

No messages.

Interact
rate | post | correct | update request | add example | add (any)