0
$\begingroup$

I need to get the axis angle from a matrix of the form:

$ \begin{matrix} \cos \theta & -\sin \theta & tx\\ \sin \theta & \cos \theta & ty\\ 0 & 0 & 1\\ \end{matrix} $

Into an axis angle. I've tried the standard formula:

$\theta$ = $\arccos$ ( (m[0][0] + m[1][1] + m[2][2] - 1) / 2 )

However this formula inverts when the angle reaches PI. For example, given a rotational matrix for an angle of 225 degrees, we get a returned value of about 135 degrees, which in itself is perfectly correct, but I really need the full value.

Is there any way of handling these cases?

1 Answers 1

0

You may have an Atan2 function available, which sorts out the quadrants. If so, you want Atan2$(\cos\theta,\sin\theta)$ Otherwise, you can do $\arccos\theta$ but then you have to sort out the quadrants afterward using the value for $\sin\theta$

  • 0
    Thanks for the help Ross, I ended up using the arccos approach and made it adjust the quadrant when sin theta is negative. Works fine now!2011-02-11