Physics Library
 An open source physics library
Encyclopedia | Forums | Docs | Random  

[parent] example of composition of rotations and quaternion order

(Example)

Composition of Rotations and Quaternion Order: Examples, Exercises, and Solutions

This entry is the self study companion to the PhysicsLibrary article composition of rotations and quaternion order. All exercises are stated first. Complete worked solutions follow afterward.

The central passive frame composition rule is

CqA =  CqB BqA.
(1)

The corresponding passive direction cosine matrix rule is

C C  = C C  BC  .
   A      B    A
(2)

Reading the quaternion chain from right to left gives the coordinate map

A −→  B  −→  C.

Quaternion multiplication is associative but generally not commutative:

(q3q2)q1 = q3(q2q1),
(3)

but

q2q1 ⁄= q1q2
(4)

in general.

1 Convention summary

PhysicsLibrary uses Hamilton multiplication,

ij = k,    jk =  i,     ki = j,

with reversed products changing sign.

For a positive frame rotation through angle 𝜃 about unit axis u, the elementary passive quaternion is

qP(^u, 𝜃) = cos 𝜃-− ^u sin 𝜃-.
              2        2
(5)

For a unit frame quaternion,

(BqA )−1 = (BqA )∗ = AqB.

For an intrinsic moving axis i-j-k sequence with angles α,β,γ,

BqA = qPk (γ)qPj (β)qPi (α).
(6)

2 Exercises

  1. Reading a frame chain.

    Suppose

    B
 qA

    maps coordinates from frame A into frame B, and

    C
 qB

    maps coordinates from frame B into frame C.

    Write the direct quaternion that maps coordinates from A into C. Then write the corresponding passive direction cosine matrix product.

  2. Two passive 90 ∘ frame rotations.

    Define

    qx =  1√ −-i,    qy = 1√−-j.
        2               2

    Compute

    qyqx

    and

    qxqy.

    Show explicitly that the two products are different.

  3. vector demonstration of noncommutativity.

    Using the quaternions in Exercise 2 and the initial pure quaternion

    v = k,

    evaluate the two transformations

    (q q )v(q q )∗
  y x    y x

    and

    (qxqy)v(qxqy)∗.

    Interpret the results as two different sequences of positive passive frame rotations.

  4. Reverse a frame chain.

    Given

    Cq  =  Cq  Bq  ,
  A      B   A

    derive an expression for Aq C in terms of the inverse or conjugate quaternions.

  5. Two rotations about the same axis.

    Let

            α         α
q1 = cos--−  ksin --
        2         2

    and

             β-        β-
q2 = cos 2 − k sin 2.

    Compute q2q1 and show that the result is a passive frame rotation by α +β about +z.

    Do q1 and q2 commute?

  6. A rotation followed by its inverse.

    Let

            𝜃-  ^    𝜃-
q = cos 2 − u sin 2.

    Show that

     ∗      ∗
q q = qq =  1.

    Interpret this result as a frame transformation followed by its reverse.

  7. Associativity in a three frame chain.

    Suppose

    A  −→  B − →  C −→  D.

    Show that

    D      D   C   B
  qA =  qC   qB  qA

    can be evaluated as either

     D   C    B
( qC  qB ) qA

    or

    Dq   (C q  Bq ).
   C    B   A

    Explain why associativity does not permit the factors themselves to be reordered.

  8. Active and passive composition.

    Let

    qP =  1√−-i,    qP =  1√−-j
 x       2       y       2

    be positive passive 90∘ frame quaternions.

    Construct the corresponding positive active rotors qxA and q yA.

    Compare

    qPy qPx

    with the conjugate of

     A A
qxqy .

    Explain the relationship.

  9. Intrinsic versus extrinsic language.

    An orientation is described intrinsically as

    1 then 2 then 3

    with angles

    α, β,γ.

    Write the PhysicsLibrary passive quaternion product.

    Then state the equivalent extrinsic fixed axis sequence and its angle order.

  10. Aerospace intrinsic 3  -2  -1  .

    PhysicsLibrary defines the intrinsic aerospace sequence using

    ψ  = yaw,     𝜃 = pitch,     ϕ = roll.

    Write the passive quaternion product Bq A and the matching passive DCM product.

    Then simplify both products for the special case

    ϕ =  0,    𝜃 = 0.
  11. Quaternion and DCM chain consistency.

    Suppose

    BCA  =  C(BqA )

    and

    CCB  = C (CqB ).

    Use the passive frame chain to show that

      C       C    B
C(  qA) =  CB   CA.

    State the homomorphism identity represented by this result.

  12. Compose two arbitrary passive axis rotations.

    Let

    q1 = c1 − s1^u1

    and

    q2 = c2 − s2^u2,

    where

             𝜃i             𝜃i
ci = cos --,    si = sin --.
         2              2

    Use the scalar vector Hamilton product to derive the scalar and vector parts of

    qnet = q2q1.
  13. Small rotation commutator.

    For small passive rotation vectors 𝜃1 and 𝜃2, use

    q  ≈ 1 − 1-𝜃
 1       2  1

    and

             1
q2 ≈ 1 − -𝜃2.
         2

    Show, through second order, that

    q q − q q  ≈  1(𝜃  × 𝜃 ) .
 2 1   1 2    2   2    1

    Why do sufficiently small rotations appear to commute at first order?

  14. Debugging a reversed software product.

    A program stores

    B
 qA

    and

    C
 qB

    correctly, but computes the direct frame quaternion as

    q   =  Bq  Cq  .
 bad     A   B

    Identify the mistake.

    For the special case

    B             C
  qA = qx,      qB = qy

    from Exercise 2, compare the incorrect quaternion with the correct one.

  15. Navigation frame chain.

    Let I denote an inertial frame, N a local navigation frame, and B a body frame.

    Suppose

    NqI

    maps inertial coordinates into navigation coordinates and

    B
 qN

    maps navigation coordinates into body coordinates.

    1. Write Bq I.
    2. Write the reverse quaternion Iq B.
    3. Write the corresponding passive DCM chain.
    4. If a vector is known as Iv, write one quaternion expression that produces Bv directly.

3 Solutions

Solution 1: reading a frame chain

The first coordinate map is

A  −→  B

and the second is

B  −→  C.

Therefore the direct quaternion is

CqA =  CqB BqA.
(7)

The matching passive DCM chain is

C CA = C CB BCA.
(8)

The written factor order is the same for quaternions and DCMs.

Solution 2: two passive 90 ∘ frame rotations

First compute

       1-
qyqx =  2(1 − j)(1 − i)
       1
    =  -(1 − i − j + ji).
       2

Hamilton multiplication gives

ji = − k.

Thus

       1-
qyqx = 2 (1 − i − j − k ).
(9)

Now reverse the order:

       1
qxqy = -(1 − i)(1 − j)
       2
    =  1(1 − i − j + ij).
       2

Since

ij = k,

we obtain

       1
qxqy = --(1 − i − j + k ).
       2
(10)

The k component changes sign, so

qyqx ⁄= qxqy.

Solution 3: vector demonstration of noncommutativity

Consider first

q q .
 y x

The first passive x map sends

k −→  j.

The second passive y map leaves j unchanged because the vector is parallel to the y rotation axis.

Therefore

(qyqx)k (qyqx)∗ = j.
(11)

Now reverse the order.

The passive y map first sends

k −→  − i.

The following passive x map leaves i unchanged because it lies on the x rotation axis.

Hence

            ∗
(qxqy)k (qxqy) = − i.
(12)

Thus changing the order changes the final coordinate vector from

j

to

− i.

Solution 4: reverse a frame chain

Start with

CqA =  CqB BqA.

Invert both sides:

(C q )−1 = (Bq  )− 1(C q )−1.
    A         A       B

Using the reverse frame labels,

 C    −1   A
( qA )  =   qC,

(BqA )−1 = AqB,

and

(Cq  )−1 = Bq .
   B         C

Therefore

A      A   B
 qC =   qB  qC .
(13)

Because the frame quaternions are unit, each inverse may also be replaced by a conjugate.

Solution 5: two rotations about the same axis

Let

         α-              α-
cα = cos 2 ,    sα = sin 2,

and similarly for β.

Then

q =  c −  ks
 1    α     α

and

q =  c − ks  .
 2    β     β

Their product is

                                2
q2q1 = cβcα − cβksα − ksβcα + k  sβsα.

Since

k2 = − 1,

we obtain

q2q1 = (cβcα − sβsα)

        − k(sαcβ + cαsβ).

Using angle addition identities,

q2q1 = cos α-+-β-− k sin α-+-β.
             2             2
(14)

Thus the two frame rotation angles add.

Both quaternions lie in the same subalgebra generated by 1 and k, so

q2q1 = q1q2.
(15)

Rotations about the same axis are a special commuting case.

Solution 6: a rotation followed by its inverse

Because q is unit,

 − 1    ∗
q   = q .

Therefore

q∗q = qq∗ = 1.
(16)

Geometrically, the second frame transformation reverses the first exactly, so the net coordinate map is the identity.

Solution 7: associativity in a three frame chain

The full chain is

D      D   C   B
 qA =   qC  qB  qA.

Hamilton multiplication is associative, so

(Dq  Cq  )Bq  =  Dq  (Cq  Bq  ).
   C   B    A      C    B   A
(17)

Both groupings represent the same map

A  →  B →  C →  D.

Associativity permits moving parentheses. It does not permit exchanging factors. In general,

C   B      B   C
 qB  qA ⁄=   qA  qB.

Solution 8: active and passive composition

The positive active rotors are the conjugates:

              1 + i
qAx = (qPx )∗ = -√---,
                2

              1 + j
qAy = (qPy )∗ = -√---.
                2

Now consider the active product

 A A
qxqy .

Conjugating gives

(qAxqAy )∗ = (qAy )∗(qAx )∗.

Since

(qA )∗ = qP
  y      y

and

  A ∗    P
(qx)  = qx ,

we obtain

  A A ∗    P  P
(qxqy ) = qy qx .
(18)

Thus a passive frame composition is the inverse of the corresponding active composition describing the opposite geometric action.

The reversal arises from conjugating a product, not from changing Hamilton multiplication.

Solution 9: intrinsic versus extrinsic language

For an intrinsic moving axis

1 then 2 then 3

sequence, PhysicsLibrary writes

B      P     P    P
 qA = q3 (γ)q2 (β)q1 (α).
(19)

The same final orientation can be described extrinsically about fixed axes in the reversed axis order:

3 then 2 then 1
(20)

with angles

γ, β,α.
(21)

The equivalence concerns two descriptions of the same final orientation. It does not say that finite rotations may be reordered arbitrarily.

Solution 10: aerospace intrinsic 3  -2  -1

For intrinsic yaw, pitch, roll,

3 then 2 then  1,

the passive quaternion is

Bq  = qP (ϕ)qP(𝜃)qP (ψ ).
  A    1     2    3
(22)

The matching passive DCM is

B
  CA =  C1(ϕ)C2 (𝜃)C3(ψ).
(23)

If

ϕ =  0,    𝜃 = 0,

then

qP(0) = 1
 1

and

 P
q2 (0) = 1.

Therefore

BqA =  qP(ψ ) = cos ψ-− ksin ψ-.
        3          2         2
(24)

Likewise,

BC   = C  (ψ ).
   A     3
(25)

The sequence reduces to a single passive yaw frame rotation.

Solution 11: quaternion and DCM chain consistency

The quaternion chain is

C      C   B
 qA =   qB  qA.

Apply the quaternion to DCM mapping:

  C         C   B
C(  qA) = C(  qB  qA).

Under the PhysicsLibrary passive convention,

C (pq) = C (p)C(q).

Therefore

   C         C      B
C ( qA ) = C ( qB )C( qA)
        = C CB BCA.

Hence

   C      C
C ( qA) =   CA.
(26)

The homomorphism identity is

C (pq) = C (p)C(q).
(27)

Solution 12: compose two arbitrary passive axis rotations

Write

q1 = (c1,− s1^u1 )

and

q = (c ,− s ^u ).
2     2    2 2

The scalar vector Hamilton product gives

q2q1 = (anet,bnet).

The scalar part is

anet = c2c1 − (− s2^u2) ⋅ (− s1^u1)
     = c2c1 − s2s1u^2 ⋅ ^u1.

Therefore

anet = c2c1 − s2s1^u2 ⋅ ^u1.
(28)

The vector part is

bnet = c2(− s1^u1 ) + c1(− s2^u2)
       +  (− s2^u2 ) × (− s1^u1).

Thus

bnet =  − c2s1^u1 − c1s2^u2
        + s s (^u  × ^u ) .
           2 1  2     1
(29)

The cross product term is where the order sensitivity appears explicitly.

Solution 13: small rotation commutator

Use

       (         ) (        )
q q  ≈   1 − 1𝜃     1 −  1𝜃   .
 2 1         2  2        2 1

Retaining terms through second order gives

           1
q2q1 ≈ 1 − -(𝜃1 + 𝜃2)
          12
       +  -𝜃2𝜃1.
          4

Similarly,

           1
q1q2 ≈ 1 − -(𝜃1 + 𝜃2)
           2
       +  1𝜃 𝜃  .
          4 1  2

Subtract:

q2q1 − q1q2 ≈ 1-(𝜃2𝜃1 − 𝜃1𝜃2 ).
             4

For pure quaternions a and b,

ab  − ba =  2a × b.

Therefore

              1-
q2q1 − q1q2 ≈ 2 (𝜃2 × 𝜃1) .
(30)

The difference is second order in the small rotation magnitudes. If only first order terms are retained, it disappears, so the rotations appear to commute.

Solution 14: debugging a reversed software product

The correct direct map is

Cq  =  Cq  Bq  .
  A      B   A

The program computes

B   C
  qA  qB,

which reverses the required order.

For

BqA  = qx

and

Cq  =  q ,
  B     y

the correct quaternion is

                1
qcorrect = qyqx = --(1 − i − j − k).
                2
(31)

The incorrect product is

qbad = qxqy = 1-(1 − i − j + k).
              2
(32)

The changed sign of the k component represents a genuinely different orientation.

Solution 15: navigation frame chain

The known maps are

I − → N

and

N  −→  B.

Therefore

BqI =  BqN NqI.
(33)

The reverse quaternion is

Iq  = (Bq  )∗.
  B       I

Using product conjugation,

I       N   ∗ B    ∗  I   N
 qB =  ( qI) ( qN ) =  qN   qB.
(34)

The corresponding passive DCM chain is

B      B    N
  CI =   CN   CI.
(35)

Finally, if Iv is known directly, then

B     B   I  B   ∗
  v =  qI  v( qI) .
(36)

Substituting the chain explicitly gives

B    (B    N  )I  (B   N   )∗
 v =    qN  qI  v   qN   qI  .
(37)

This is the same composition pattern used in inertial navigation and rigid body attitude transformations.

4 Compact composition checks

The following identities provide useful self checks:



Situation PhysicsLibrary result


Frame chain A →  B →  C  Cq A = Cq B Bq A


Reverse chain Aq C = Aq B Bq C


Same axis angles add and products commute


Inverse pair q∗q = qq∗ = 1


Passive x  then y  , v = k  k → j


Passive y  then x  , v = k  k →−i


Quaternion to DCM map C(pq) = C(p)C(q)


5 Sources and exercise provenance

The exercises and solutions in this companion are newly written or rewritten for PhysicsLibrary under the passive frame convention.

Classical quaternion texts by Hamilton, Joly, and Hathaway discuss products of versors and successive rotations. Sommer and coauthors provide a modern discussion of Hamilton versus flipped multiplication and the interaction between active and passive attitude conventions.

References

[1]   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

[2]   C. J. Joly, A Manual of Quaternions, Macmillan and Co., London, 1905. Public domain historical source. Internet Archive scan

[3]   A. S. Hathaway, A Primer of Quaternions, 1896. Public domain historical source. Project Gutenberg edition

[4]   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

License

Unless otherwise noted, this PhysicsLibrary entry is intended for release under the Creative Commons Attribution ShareAlike 4.0 International license.


"example of composition of rotations and quaternion order" is owned by bloftin.
(view preamble)
View style:
See Also: quaternion series overview and article guide, Quaternions for Physics and Engineering: Orientation, Notation, and Conventions, quaternion definition and basic algebra, example of quaternion definition and basic algebra, quaternion product, example of quaternion product, quaternion conjugate, example of quaternion conjugate, quaternion norm, example of quaternion norm, quaternion inverse, example of quaternion inverse


This object's parent.

Cross-references: rigid body, conjugation, magnitudes, cross product, program, commutator, scalar, identity, commute, vector, unit, quaternion multiplication, quaternion, direction cosine matrix, composition, composition of rotations and quaternion order
There is 1 reference to this object.

This is version 2 of example of composition of rotations and quaternion order, born on 2026-08-23, modified 2026-08-26.
Object id is 1100, canonical name is ExampleOfCompositionOfRotationsAndQuaternionOrder.
Accessed 256 times total.

Classification:
Physics Classification: 02.40.Yy (Geometric mechanics )
 02.10.Hh (Rings and algebras)
 45.40.-f (Dynamics and kinematics of rigid bodies)

Pending Errata and Addenda

None.

Discussion

No messages.

Interact