Converting from rotation matrix to axis angle … with no ambiguity

Every conversion I've seen for finding the axis and angle $\theta$ of a rotation from a rotation matrix $\mathbf{R}$ uses

$tr (\mathbf{R}) = 1+2\cos{\theta}$

and then inverting by way of $\cos^{-1}$. But $\cos{\theta}=\cos{(-\theta)}$. Therefore, if the only information we really have is $\cos\theta$, the rotation angle could be $\theta$, or just as easily, $-\theta$. The only ways I have figured to solve the ambiguity are rather clunky. Is there a short, straightforward way to do it?

• You can’t resolve this ambiguity without also fixing the orientation of the rotation axis. – amd Oct 17 '16 at 16:52

You should take into account that matrix $R(v,\theta)=R(-v,-\theta)$.
So we have two possibilities $v$ and $-v$ for the axes and appropriately two possible values of the angle which have the same $cos(\theta)$ value.
You can calculate the axis from the formula: $v= {\dfrac {1}{2sin(\theta)}}\begin{bmatrix} r_{32}-r_{23} \\ r_{13}-r_{31} \\ r_{21} -r_{12} \end{bmatrix}$ where $r_{ij}$ are appropriate entries of $R$ matrix, so you see from this formula that changing sign of the angle $\theta$ changes sign of $sin(\theta)$ and consequently orientation of $v$ vector.
• Let me make sure I understand: What is needed is not exactly the correct angle, but the correct angle/axis pair. So you're saying that I can "naively" take the positive value of $\theta$ from the trace formula, then plug that value into the formula you give here, and that will give the correct axis corresponding to the positive $\theta$? – bob.sacamento Oct 20 '16 at 17:12
• @bob I didn't say you took something "naively" , but generally you are right - the full representation of rotation matrix is pair axis/ angle, we can't abstract one value from the other. So we have $R(v,\theta)=R(-v, -\theta)$ which are formally two solutions but in fact represent the same rotation. – Widawensen Oct 20 '16 at 18:32