Given a pure rotation matrix, is it possible to find the angle of rotation such that the sign of the rotational angle is preserved

matrices

Good day.

When finding the angle of rotation for a 3×3 pure rotation matrix, one need only consider that the trace of said matrix will live by the equation trace = 1 + 2sin(theta) where theta is the angle of rotation of said matrix, and that thus one can find the angle itself by simply re-arranging the equation as theta = arccos((trace – 1) / 2).

Now, this bit of math is all well and good, but one of the vary limiting parts of this approach is that it doesn't preserve the sign of the angle in question, which, put another way, means that given an angle of 80 degrees and an angle of 280 degrees this approach will, in both cases, return 80 degrees as 280 degrees = -80 degrees as stated prior, the answer is correct but the sign is not preserved in the process.

Thus, I have to ask, is there a way to calculate this rotation angle such that the sign of the rotation is preserved? Or equivalently, that it properly accounts for angles beyond 180 degrees?

If it's not mathmatically possible to do so, fine, but if it can be done, I'd really like to learn how, as unfortunately, this equation renders itself vary difficult to use, especially in the context of making things in C++, given that it quickly breaks down for angles beyond a half-rotation.

Best Answer

Let $M$ be your matrix. There is some vector $v_1$ such that $\lVert v_1\rVert=1$ and that $M.v_1=v_1$. Fix some vector $v_2$ such that $\lVert v_2\rVert=1$ and that $\langle v_1,v_2\rangle=0$ and let $v_3=v_1\times v_2$. Then, for some $\theta\in[0,2\pi)$,$$M.v_2=\cos(\theta)v_2+\sin(\theta)v_3$$and$$M.v_3=-\sin(\theta)v_2+\cos(\theta)v_3.$$Note that $\cos(\theta)=\langle M.v_2,v_2\rangle$ and that $\sin(\theta)=\langle M.v_2,v_3\rangle$. This $\theta$ is the angle that you are interested in.