Matrix exponential to the Rodrigues' rotation formula

Last time we have seen where the formula R=e^{[\omega]_\times} came from and today I will try to describe how to do the matrix exponential by means of sine and cosine of the rotation angle and some multiplication and addition. As we will see at the end the result will be the Rodrigues' rotation formula which should not be a surprise 🙂

Ok so how can we exponentiate a matrix. With a real number we use the Taylor series.

    \[e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots = \sum_{n\geq 0}^\infty \frac{x^n}{n!}\]

Remember that [\omega]_\times is a skew symmetric matrix of the \omega  vector

    \[\omega = (x,y,z) \in \mathbb{R}^3\]

Where the direction of this vector is the axis of the rotation and the magnitude is the angle of rotation in counter clockwise direction. We can split the \omega vector to the axis of rotation  represented by a unit vector n where |n|=1 and the angle of rotation \phi

    \[n=\frac{\omega}{|\omega|}  \qquad \phi=\sqrt{x^2 +  y^2 + z^2}\]

Upon converting the vector n to the skew symmetric matrix

    \[[n]_\times=\begin{pmatrix}0 & -n_3 & n_2\\n_3 & 0 & -n_1\\-n_2 & n_1 & 0\end{pmatrix}\]

so we can write

    \[[\omega]_\times = [n]_\times\phi\]

Thus

    \[$e^{[\omega]_\times} = e^{[n]_\times\phi}\]

The Taylor series for e^{[n]_\times\phi}

    \[e^{[n]_\times\phi} = I + [n]_\times\phi + \frac{[n]_\times^2 \phi^2}{2!} + \frac{[n]_\times^3 \phi^3}{3!} + \frac{[n]_\times^4 \phi^4}{4!} + \frac{[n]_\times^5 \phi^5}{5!} + \frac{[n]_\times^6 \phi^6}{6!} + \cdots\]

Ok this is nice but so far nothing really new or too interesting. To move on we need to keep staring at this formula for a bit. We know that sine and cosine functions have very similar power series.

    \[\cos x = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots\]

    \[\sin x = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots\]

The sine and cosine can be added to form e^x with the help of complex numbers, strictly speaking the imaginary number i

    \[e^{ix} = \cos x + i\sin x\]

Lets look how it works

    \[e^{ix} = 1 + ix + \frac{(ix)^2}{2!} + \frac{(ix)^3}{3!} + \frac{(ix)^4}{4!} + \frac{(ix)^5}{5!} + \frac{(ix)^6}{6!} + \frac{(ix)^7}{7!} + \frac{(ix)^8}{8!} + \cdots\]

Now we exponentiate the i as such i^2 = -1 \quad i^3=-i  \quad i^4=1 and i^5=i We get

    \[e^{ix}= 1 + ix - \frac{x^2}{2!} - \frac{ix^3}{3!} + \frac{x^4}{4!} + \frac{ix^5}{5!} - \frac{x^6}{6!} - \frac{ix^7}{7!} + \frac{x^8}{8!} + \cdots \]

We can group the real and imaginary numbers to get.

    \[e^{ix}= \left( 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \frac{x^8}{8!} - \cdots \right) + i\left( x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots \right) \]

The real component is the same as the cosine and the imaginary one as the sine function which give us the famous Euler formula.

    \[e^{ix}= \cos x + i\sin x \]

Without diving into more mathematical details we can say the imaginary number i in front of  the sine function alternates the signs of the elements in the sine power series based on the exponent.

This is great but how does it help us? Well if we could find something that alternates the sign based on the exponent we could convert R = x^{[n]_\times \phi} to an easy to calculate sum of the sine and cosine.  Luckily this is possible.

It turns out that if we exponentiate the skew symmetric matrix we get back the original with just inverted sign. Well unfortunately not for all exponents. We know that the outer product is

    \[nn^T=[n]_\times^2+I \quad \Rightarrow \quad[n]_\times^2 = nn^T - I\]

This is the result of squaring the skew symmetric matrix, now what happens when we do power of 3,4,5.....

[n]_\times^3 = -[n]_\times

[n]_\times^4 = -[n]_\times^2

[n]_\times^5 = -[n]_\times^3 = [n]_\times

[n]_\times^6 = -[n]_\times^4 = -[n]_\times^2

Lets use this knowledge and reduce the terms [n]_\times^a in the Taylor expansion e^{[n]_\times\phi} We only leave [n]_\times^2 for now.

    \[e^{[n]_\times\phi} = I + [n]_\times\phi + \frac{[n]_\times^2 \phi^2}{2!} + \frac{-[n]_\times \phi^3}{3!} + \frac{-[n]_\times^2 \phi^4}{4!} + \frac{[n]_\times \phi^5}{5!} + \frac{[n]_\times^2 \phi^6}{6!} + \frac{-[n]_\times \phi^7}{7!}\cdots\]

We can see that there are terms with  [n]_\times and [n]_\times^2 Lets factor them out.

    \[e^{[n]_\times\phi} = I + [n]_\times \left(\phi -\frac{\phi^3}{3!} +\frac{\phi^5}{5!} -\frac{\phi^7}{7!}+\cdots\right ) +[n]_\times^2\left(\frac{\phi^2}{2!} -\frac{\phi^4}{4!}  +\frac{\phi^6}{6!} - \cdots \right)\]

Hmm I'm sure you can already see some similarity with the sine and cosine functions. Well, the sine is quite clear but what about the cosine? We can see that we are missing the 1 at the beginning of the series an also that all signs are inverted.

    \[\cos x = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots\]

and this is what we have...

    \[\frac{\phi^2}{2!} -\frac{\phi^4}{4!}  +\frac{\phi^6}{6!} - \cdots\]

We can convert our power series to the cosine by subtracting 1 from the cosine power series.

    \[1-\cos x = 1-(1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots) = \frac{x^2}{2!} - \frac{x^4}{4!} + \frac{x^6}{6!} - \cdots\]

Great using this manipulation in our matrix exponential equation we get

    \[e^{[n]_\times\phi} = I + [n]_\times \sin \phi +[n]_\times^2\left(1-\cos \phi \right)\]

And here we go, this is the Rodrigues' rotation formula

 

This entry was posted in Computer Vision. Bookmark the permalink.

Leave a Reply