Homogeneous transformation matrix (7)

Kinematics & Universal Numerics
July 28, 2019

Conversion between rotation matrix and its axis-angle representation.

In the past two blogs, we have shown how to convert a rotation in the axis-angle representation (𝐝,θ) into the matrix representation. We summarize the steps here:

  • β€’

    Find Ο•βˆˆ[0,Ο€],ψ∈(-Ο€,Ο€] that parametrize a normalized (unit) vector 𝐝:

  • β€’

    Use Ο•,ψ to construct

    𝐒0=[sψcϕ⁒cψsϕ⁒cψ-cψcϕ⁒sψsϕ⁒sψ-sΟ•cΟ•]. (1)
  • β€’

    The rotation matrix is hence

    𝐑=𝐒0⁒[cΞΈ-sΞΈsΞΈcΞΈ1]⁒𝐒0T. (2)

Conversely, given a rotation matrix 𝐑=(ri⁒j), how can we find its axis-angle representation (𝐝,ΞΈ)? Assume Ξ»1,Ξ»2,Ξ»3 are the three eigenvalues of 𝐑. Then for each eigenvalue of 𝐑, i=1,2,3,

0 =det⁑(𝐑-Ξ»i⁒𝐈)

which means Ξ»i is also an eigenvalue of Rotz⁒(ΞΈ). In other words, 𝐑 is obtained by performing a similarity transform 𝐒0 on Rotz⁒(ΞΈ), so matrices 𝐑 and Rotz⁒(ΞΈ) have the same eigenvalues.

The sum of eigenvalues of an nΓ—n matrix 𝐀=(ai⁒j) equals its matrix trace, that is the sum of diagonal elements of 𝐀:


Having the same eigenvalues, matrices 𝐑 and Rotz⁒(ΞΈ) also have the same trace


Since entries of 𝐑 are given, we can calculate ΞΈ by

θ=arccos⁑r11+r22+r33-12. (3)

To derive the rotation axis 𝐝=𝐒0⁒𝐞1,3, we may first try to eliminate one of the two trigonometric terms sΞΈ and cΞΈ. In our first attempt, we get rid of cΞΈ by taking the difference of 𝐑 and its transpose:

𝐑-𝐑T =𝐒0⁒[cΞΈ-sΞΈsΞΈcΞΈ1]⁒𝐒0T-𝐒0⁒[c-ΞΈ-s-ΞΈs-ΞΈc-ΞΈ1]⁒𝐒0T
=2⁒sθ⋅𝐒0⁒[-110]⁒𝐒0T. (4)

We claim this is exactly 2⁒sθ⋅𝐝×, where β€œ(β‹…)×” is an operator on a directional vector 𝐝 such that


Then the cross product can be also written as


To show (4) is indeed 2⁒sθ⋅𝐝×, we first write (using subscripts in column major form)


and the matrix product becomes

𝐒0⁒[-110]⁒𝐒0T=[𝐬2,-𝐬1, 0]⁒[𝐬1T𝐬2T𝐝T]=𝐬2⁒𝐬1T-𝐬1⁒𝐬2T=𝐝×.

The last step can be verified by writing 𝐬2⁒𝐬1T-𝐬1⁒𝐬2T into the full 3Γ—3 matrix, for example, on position (1,2),


So far we have shown

𝐑-𝐑T=2⁒sθ⁒𝐝×=2⁒sθ⁒[-dzdydz-dx-dydx]. (5)

We have three cases to discuss:

  1. Case 1: ΞΈβ‰ 0 and ΞΈβ‰ Ο€. This is the regular case: sΞΈβ‰ 0. Getting 𝐝 is by simply matching both hand sides in (5):

    𝐝=[dxdydz]=12⁒sθ⁒[r32-r23r13-r31r21-r12], (6)

    where 𝐑=(ri⁒j).

  2. Case 2: θ=0. Then the rotation is trivial so the rotation axis can be arbitrary. In such a case we choose the default 𝐝=[001] in our convention.

  3. Case 3: ΞΈ=Ο€. This occurs only when (tr⁒(𝐑)-1)/2=sΞΈ=sin⁑π=-1, so tr⁒(𝐑)=r11+r22+r33=-1. In this case, 𝐑=𝐑T, so we cannot use (6) to determine 𝐝. By plugging in 𝐒0 from (1) and ΞΈ=Ο€ in (2), we obtain



    Ο• =12⁒arccos⁑r33∈[0,Ο€/2]
    ψ ={arbitraryifΒ Ο•=0, so ⁒𝐝=[001]r22+12ifΒ Ο•=Ο€/2, so ⁒𝐝=[cψsψ0]atan2⁒(r23,r13)ifΒ s2⁒ϕ≠0, soΒ Ο•β‰ 0Β andΒ Ο•β‰ Ο€/2.

We remind ourselves that