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

[parent] example of Axis Angle Representation and Unit Quaternion

(Example)

Axis Angle Representation and Unit Quaternion: Examples, Exercises, and Solutions

This companion entry is designed for self study after the PhysicsLibrary article Axis Angle Representation and Unit Quaternion. All exercises are stated first so that the reader can work through the entire set without encountering solutions accidentally. Complete solutions follow in a separate section.

The exercises progress from direct construction and extraction to convention interpretation, small attitude corrections, the quaternion exponential, and the half angle derivation.

1 Convention declaration

Unless otherwise stated, use Hamilton multiplication,

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

with reversed products changing sign.

Quaternion components are displayed scalar first:

                                 ⌊   ⌋
                                   qw
                                 | qx|
q = qw + qxi + qyj + qzk  ← →    |⌈ q |⌉ .
                                    y
                                   qz
(1)

The canonical PhysicsLibrary orientation quaternion is the passive coordinate map Bq A. If frame B is obtained from frame A by a positive frame rotation through angle 𝜃 about the unit axis u, then

B         𝜃-       𝜃-
 qA =  cos2 − ^u sin2 .
(2)

It maps vector coordinates from frame A into frame B according to

Bv = BqA  Av(BqA )∗.
(3)

For a unit quaternion written

q = qw + q,

define

s =  ∥q∥.

When s≠0, the corresponding passive axis angle pair can be extracted as

𝜃 = 2atan2 (s,qw),
(4)

^u =  − q.
       s
(5)

For a principal frame rotation with 𝜃 ∈ [0,π], one normally chooses the equivalent quaternion sign so that qw ≥ 0 before applying the extraction.

2 Exercises

Foundational exercises

  1. 90∘ about the z  axis.

    Construct the passive unit quaternion Bq A when frame B is obtained from frame A by a positive 90∘ frame rotation about +z.

    Give the result both as

    q = qw + qxi + qyj + qzk

    and as a scalar first column.

  2.    ∘
120 about the (1,1,1 )  axis.

    Construct the passive quaternion for a positive frame rotation of 120∘ about

            ⌊ 1⌋
     1--⌈  ⌉
^u =  √3   1  .
          1

    Verify directly that the quaternion has unit norm.

  3. A nontrivial normalized axis.

    Construct the passive quaternion for a positive frame rotation of 60∘ about

          ⌊  ⌋
        1
^u = 1-⌈ 2⌉ .
    3
        2

    Write the exact scalar first components.

  4. Recover an axis and angle.

    For the unit quaternion

        ⌊  √--   ⌋
        2 ∕2
    |    0   |
q = |⌈ − √2-∕2 |⌉ ,

         0
    (6)

    recover the principal positive frame rotation axis and angle.

  5. A    ∘
180 quaternion.

    For

        ⌊      ⌋
        0
    | − 1∕3 |
q = |⌈      |⌉ ,
      2 ∕3
      − 2∕3
    (7)

    find the passive frame rotation axis and angle. Explain what happens when the quaternion is replaced by −q.

Convention and interpretation exercises

  1. The q  versus − q  ambiguity.

    Let

             ∘          ∘
q = cos20  − k sin 20 .
    (8)

    Determine the positive frame axis and angle represented by q.

    Then express −q as an axis angle pair with angle in the interval [0, 2π] and show that it represents the same physical orientation.

  2. Zero, 2 π  , and 4π  .

    For a fixed unit frame rotation axis u, evaluate the passive quaternion for frame rotation angles

    0,    2 π,    4π.

    Which quaternions are equal? Which represent the same frame orientation?

  3. Passive frame map and active counterpart.

    Frame B is obtained from frame A by a positive 30∘ frame rotation about +z.

    First write Bq A. Then compute its inverse Aq B.

    Interpret Aq B both as

    1. the reverse passive coordinate map from B into A, and
    2. the usual positive active rotor associated with the same 30∘ geometry.
  4. The nonunit axis trap.

    A programmer attempts to construct the passive quaternion for a positive 90∘ frame rotation about the x axis but substitutes the vector (2, 0, 0) directly into

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

    without normalizing the axis.

    Compute the resulting quaternion and its norm. Explain the mistake and give the correct unit quaternion.

Engineering and derivation exercises

  1. Small attitude correction.

    An attitude estimator produces the small frame rotation vector

         ⌊       ⌋
        0.01
δ𝜃 = ⌈ − 0.02 ⌉ rad.

        0.03
    (9)

    Use the first order passive small angle approximation

         [      ]
         1
δq ≈  − 1 δ𝜃
        2

    to form the correction quaternion.

    Compute its norm to quantify the first order normalization error. Then give the normalized approximation.

  2. Engineering command axis.

    A spacecraft body frame is commanded to rotate by 15∘ about the unit axis

          ⌊    ⌋
         2
^u =  1⌈ − 1⌉ .
     3
         2

    Construct the exact passive command quaternion and give numerical component values to at least six significant digits.

  3. Derive the half angle for the passive map.

    Let u and v be perpendicular unit pure quaternions, and let

    q = cos ϕ − ^u sin ϕ.
    (10)

    Starting from

        ∗
qvq  ,

    prove that the coordinate vector is transformed through angle −2ϕ about u. Explain why this corresponds to a positive frame rotation of +2ϕ and therefore why a desired positive frame angle 𝜃 is encoded with quaternion phase ϕ = 𝜃∕2.

  4. Derive the passive quaternion exponential.

    Using only

      2
^u   = − 1

    and the power series definition of the exponential, prove

    exp(− ^u ϕ) = cosϕ − ^u sinϕ.
    (11)

    Then write the passive axis angle quaternion as an exponential.

  5. Principal representative from a negative scalar part.

    A normalized passive attitude quaternion is received as

        ⌊− 0.9238795 ⌋
    |            |
q = |      0     | .
    ⌈      0     ⌉
      0.3826834
    (12)

    First extract an axis angle pair using the quaternion exactly as supplied.

    Then choose the equivalent representative with nonnegative scalar part and extract the principal positive frame rotation with angle in [0,π].

    Explain why both quaternions describe the same frame orientation.

3 Solutions

Solution 1:   ∘
90 about the z  axis

Here

^u = k,     𝜃-=  45∘.
           2

The passive axis angle formula gives

                           √ --   √ --
BqA  = cos45 ∘ − k sin 45∘ =--2-−  --2k.
                            2      2
(13)

Thus

     √2--                                   √2--
qw =  ---,     qx = 0,    qy = 0,     qz = − ---.
      2                                      2

In scalar first column form,

      ⌊  √ --  ⌋
      |    2∕2 |
BqA = |    0   | .
      ⌈   √0-- ⌉
        −   2∕2
(14)

The negative vector component is the expected passive sign for a positive frame rotation about +z.

Solution 2: 120∘ about (1,1,1)

The half angle is

  ∘
60 .

Therefore

         1                √3--
cos60∘ = --,    sin60 ∘ = ---.
         2                 2

Multiplying the sine by the unit axis gives

√ --   ⌊ 1⌋     ⌊ 1⌋
--3-1--⌈  ⌉    1⌈  ⌉
 2 √ 3   1  =  2  1  .
         1        1

The passive quaternion is therefore

BqA  = 1-− 1-i − 1j − 1k.
       2   2     2    2
(15)

Its squared norm is

 B    2   1-  1-   1-  1-
∥  qA∥  = 4 + 4 +  4 + 4 = 1.

Hence the quaternion is unit.

Solution 3: 60∘ about (1,2,2)∕3

First verify the axis normalization:

∥∥   ⌊1⌋ ∥∥2
∥∥ 1-⌈ ⌉ ∥∥    1-+-4-+-4
∥ 3  2  ∥ =      9     = 1.
∥    2  ∥

The half angle is

30∘,

so

         √ --
     ∘     3           ∘    1
cos30  = ----,    sin30  =  -.
          2                 2

Therefore

       √3--  1     1    1
BqA  = ----− --i − -j − -k.
        2    6     3    3
(16)

In scalar first column form,

      ⌊ √ -- ⌋
          3∕2
B     | − 1∕6|
 qA = |⌈ − 1∕3|⌉ .

        − 1∕3
(17)

Solution 4: recover an axis and angle

The quaternion is

    ⌊  √--   ⌋
        2 ∕2
    ||    0-  ||
q = ⌈ − √ 2∕2 ⌉ .

         0

Its scalar part is

     √2--
qw = ----,
      2

and the vector magnitude is

    √ --
s = --2.
     2

Therefore

            ( √ --√ --)
              --2---2-     π-
𝜃 = 2 atan2    2 , 2    =  2.
(18)

For the passive convention,

       q
^u =  − -.
       s

Since

      √ --
q = − --2-j,
       2

we obtain

^u = +j.
(19)

Thus the quaternion represents a positive 90∘ frame rotation about +y.

Solution 5: a     ∘
180 quaternion

For

    ⌊      ⌋
        0
    || − 1∕3 ||
q = ⌈ 2 ∕3 ⌉ ,
      − 2∕3

the vector part has unit magnitude:

    ∘ -----------
       1-  4-  4-
s =    9 + 9 + 9 =  1.

Because qw = 0,

𝜃 = 2 atan2(1,0) = π.
(20)

The passive axis is

^u = − q

because s = 1. Hence

      ⌊    ⌋
     1   1
^u =  -⌈ − 2⌉ .
     3   2
(21)

Replacing q by −q reverses the displayed vector part and therefore reverses the extracted axis. At exactly 180∘,

(^u,π )

and

(− ^u,π)

describe the same frame orientation. This is a special case of the general q versus −q ambiguity.

Solution 6: q  versus − q

The supplied quaternion is

q = cos20∘ − k sin 20∘.

Comparing with

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

gives

𝜃-     ∘     ^
2 =  20 ,    u =  +k.

Therefore

𝜃 = 40∘
(22)

about +z.

Now

− q = − cos20∘ + k sin 20∘.

Use

        ∘         ∘
− cos20  =  cos160

and

      ∘         ∘
sin 160  = sin20  .

Then

− q = cos160∘ − (− k)sin 160∘.

Therefore −q may be written as the passive axis angle pair

                    ∘
^u = − ^z,     𝜃 = 320 .
(23)

A 320∘ frame rotation about −z is equivalent to a 40∘ frame rotation about +z, so q and −q represent the same orientation.

Solution 7: zero, 2π  , and 4π

The passive quaternion is

          𝜃-        𝜃-
q(𝜃) = cos2 − ^u sin 2.

For 𝜃 = 0,

q(0) = 1.
(24)

For 𝜃 = 2π,

cosπ =  − 1,    sinπ =  0,

so

q(2π) = − 1.
(25)

For 𝜃 = 4π,

cos2π =  1,    sin2π =  0,

so

q(4π) = 1.
(26)

Thus

q (0 ) = q (4 π)

as quaternions, while

q(2π ) = − q(0).

All three represent the same frame orientation because q and −q produce the same orientation map.

This illustrates the two to one relationship between unit quaternions and proper three dimensional orientations.

Solution 8: passive frame map and active counterpart

For a positive 30∘ frame rotation about +z,

𝜃-= 15∘.
2

Therefore

BqA  = cos15 ∘ − k sin15∘.
(27)

Because it is unit,

 B   − 1   B    ∗
( qA)   = (  qA) .

Hence

AqB  = cos15 ∘ + k sin15∘.
(28)

As a passive quaternion, Aq B maps coordinate components from frame B back into frame A.

The same numerical quaternion

cos15 ∘ + k sin 15∘

is also the familiar Hamilton active rotor for a positive 30∘ physical vector rotation about +z in a fixed coordinate frame.

The same numbers therefore admit different physical interpretations depending on whether the quaternion represents active vector motion or a passive frame map. The frame labels remove that ambiguity.

Solution 9: the nonunit axis trap

The programmer uses

u  = 2i

without normalization. For 𝜃 = 90∘,

𝜃-    ∘
2 = 45 .

The incorrect quaternion becomes

qbad = cos45 ∘ − 2i sin 45∘
       √ --    --
     = --2-− √ 2 i.
        2

Its squared norm is

∥qbad∥2 = 1-+  2 = 5.
          2        2

Therefore

         ∘ --
           5-
∥qbad∥ =   2 ,
(29)

which is not one.

The mistake is that the axis in the axis angle formula must be a unit vector. The correct axis is

^u = i.

Therefore the correct passive unit quaternion is

    √ --   √ --
    --2-   --2-
q =  2  −   2 i.
(30)

Solution 10: small attitude correction

The passive first order approximation is

     [     ]
δq ≈    1    .
      − 12δ𝜃

For

     ⌊       ⌋
        0.01
δ𝜃 = ⌈ − 0.02 ⌉ ,

        0.03

we obtain

        ⌊        ⌋
             1
δq    = || − 0.005 ||.
  first   ⌈  0.010  ⌉
          − 0.015
(31)

Its squared norm is

∥δqfirst∥2 = 1 + (0.005 )2 + (0.010)2 + (0.015 )2

         = 1.00035.

Therefore

          √ --------
∥δqfirst∥ =   1.00035 ≈  1.000174985.
(32)

The first order approximation is therefore slightly longer than a unit quaternion.

Normalizing gives approximately

         ⌊              ⌋
            0.999825046
         | − 0.004999125 |
δqnorm ≈ |⌈              |⌉ .
            0.009998250
           − 0.014997376
(33)

The normalization correction is second order in the small rotation magnitude.

Solution 11: engineering command axis

The axis

       ⌊   ⌋
     1   2
u^ = --⌈− 1⌉
     3   2

is unit because

4 +-1 +-4 = 1.
    9

The frame rotation angle is

𝜃 = 15∘,

so the half angle is

7.5∘.

Thus

B            ∘   1-                   ∘
  qA = cos7.5  − 3 (2i − j + 2k) sin 7.5 .
(34)

Using

      ∘
cos7.5 ≈  0.991444861

and

      ∘
sin 7.5  ≈ 0.130526192,

the scalar first components are

       ⌊              ⌋
          0.991444861
B      | − 0.087017461 |
  qA ≈ |⌈  0.043508731  |⌉ .

         − 0.087017461
(35)

The vector part is opposite the positive frame rotation axis, as required by the passive convention.

Solution 12: derive the half angle for the passive map

Let

c = cosϕ,     s = sinϕ,

so that

q =  c − s^u

and

 ∗
q =  c + su^.

Because u and v are perpendicular unit pure quaternions,

^uv = ^u ×  v,

v^u =  − ^u × v,

and

^uv ^u = v.

Now expand:

qvq∗ = (c − s^u)v (c + s^u )
        2                     2
     = c v + csv ^u − cs^uv −  s ^uv^u.

Substituting the perpendicular Vector Identities gives

qvq ∗ = (c2 − s2)v − 2cs(^u × v ).

Using the double angle identities,

 2    2
c −  s =  cos2ϕ

and

2cs =  sin 2ϕ,

we obtain

qvq∗ = cos 2ϕv −  sin 2ϕ (^u ×  v).
(36)

The coordinate vector therefore undergoes a rotation of −2ϕ about u.

That is exactly the coordinate motion expected when the coordinate frame itself is rotated positively through +2ϕ. Therefore a positive frame rotation through angle 𝜃 requires

                 𝜃
𝜃 = 2 ϕ,    ϕ =  -.
                 2
(37)

This proves both the half angle and the passive minus sign.

Solution 13: derive the passive quaternion exponential

Start with the power series

             ∑∞  (−u^ϕ)n
exp (− ^u ϕ) =     -------.
             n=0    n!

Since

^u 2 = − 1,

the even powers are

        2      4      6
1,   − ϕ ,  + ϕ ,  − ϕ ,  ...

while the odd powers contain −u times

       3       5
ϕ,  − ϕ ,   +ϕ  ,  ...

Therefore

             (      2    4      )
exp (− ^u ϕ) =   1 − ϕ--+ ϕ--− ⋅⋅⋅
                   2!   4!
                 (     ϕ3   ϕ5      )
             − ^u  ϕ −  ---+ ---− ⋅⋅⋅  .
                       3!   5!

Recognizing the cosine and sine series gives

exp(− ^u ϕ) = cosϕ − ^u sinϕ.
(38)

Setting

    𝜃-
ϕ = 2

gives the passive axis angle quaternion

          (      )
B             𝜃-
 qA = exp   − 2^u   .
(39)

Solution 14: principal representative from a negative scalar part

The supplied quaternion is approximately

    ⌊            ⌋
     − 0.9238795
q = ||      0     || .
    ⌈      0     ⌉
      0.3826834

Its vector magnitude is

s =  0.3826834.

Using the quaternion exactly as supplied,

𝜃-                                        ∘
2 = atan2 (0.3826834,− 0.9238795 ) ≈ 157.5 .

Therefore

𝜃 ≈ 315 ∘.
(40)

The passive axis is

       q-
^u =  − s = − ^z.

Thus the supplied quaternion can be interpreted as

315∘ about  − ^z.
(41)

Now choose the equivalent quaternion with nonnegative scalar part:

      ⌊            ⌋
        0.9238795
      |     0      |
− q = |⌈            |⌉ .
            0
       − 0.3826834

Then

𝜃p-= atan2 (0.3826834, 0.9238795 ) ≈ 22.5∘,
 2

so

𝜃p ≈ 45 ∘.
(42)

The passive principal axis is

        − 0.3826834k
^up =  − -------------=  +^z.
         0.3826834

Therefore the principal representative is

  ∘
45  about  + ^z.
(43)

The two axis angle descriptions are equivalent because

   ∘
315  about  − ^z

and

45∘ about +  ^z

produce the same frame orientation, and the unit quaternions q and −q always represent the same orientation map.

4 Summary of passive sign checks

The exercises above provide several quick checks for the PhysicsLibrary convention.

For a positive frame rotation about a unit axis u,

B         𝜃        𝜃
 qA =  cos--− ^u sin--.
          2        2
(44)

For principal positive frame angles, the recovered axis is

        q
^u =  − ---.
       ∥q∥
(45)

For a small frame rotation vector,

     [     ]
δq ≈    1    .
      − 12δ𝜃
(46)

The inverse passive map and the corresponding positive active rotor use the conjugate sign:

(Bq  )∗ = cos 𝜃-+ ^usin 𝜃.
   A        2         2
(47)

These checks make it possible to detect an accidental return to the previous active sign convention immediately.

5 Sources and exercise provenance

The problems and solutions above are newly written or rewritten for PhysicsLibrary under the passive quaternion convention. Their subject matter is cross checked against public domain quaternion texts by Hamilton, Hathaway, Joly, and Macfarlane.

Joly discusses the relation between quaternion phase and twice angle rotation, while Hathaway and Macfarlane provide historical treatments of finite rotation and quaternion geometry. No historical exercise is transcribed verbatim.

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]   A. Macfarlane, Vector Analysis and Quaternions, John Wiley and Sons, New York, 1906. Public domain historical source. Project Gutenberg edition

License

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


"example of Axis Angle Representation and Unit Quaternion" 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: relation, domain, detect, powers, identities, Vector Identities, unit vector, magnitude, formula, power series, norm, vector, unit, scalar, quaternion, section, work, Axis Angle Representation and Unit Quaternion
There is 1 reference to this object.

This is version 2 of example of Axis Angle Representation and Unit Quaternion, born on 2026-08-23, modified 2026-08-26.
Object id is 1096, canonical name is ExampleOfAxisAngleRepresentationAndUnitQuaternion.
Accessed 243 times total.

Classification:
Physics Classification: 02.40.Yy (Geometric mechanics )
 02.10.Hh (Rings and algebras)

Pending Errata and Addenda

None.

Discussion

No messages.

Interact