Homogeneous transformation matrix (7)
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 that parametrize a normalized (unit) vector :
Use to construct
The rotation matrix is hence
Conversely, given a rotation matrix , how can we find its axis-angle representation ? Assume are the three eigenvalues of . Then for each eigenvalue of , ,
which means is also an eigenvalue of . In other words, is obtained by performing a similarity transform on , so matrices and have the same eigenvalues.
The sum of eigenvalues of an matrix equals its matrix trace, that is the sum of diagonal elements of :
Having the same eigenvalues, matrices and also have the same trace
Since entries of are given, we can calculate by
To derive the rotation axis , we may first try to eliminate one of the two trigonometric terms and . In our first attempt, we get rid of by taking the difference of and its transpose:
We claim this is exactly , where “” is an operator on a directional vector such that
Then the cross product can be also written as
To show (4) is indeed , we first write (using subscripts in column major form)
and the matrix product becomes
The last step can be verified by writing into the full matrix, for example, on position (1,2),
So far we have shown
We have three cases to discuss:
Case 1: and . This is the regular case: . Getting is by simply matching both hand sides in (5):
Case 2: . Then the rotation is trivial so the rotation axis can be arbitrary. In such a case we choose the default in our convention.
We remind ourselves that