How would I go about extracting the angle from a 2x2 rotational matrix? I'm using a matrix to track transformations in 2D space, but I'm struggling to figure out how to reverse this once I've got the rotation matrix so I can just see the angle that was applied.


If it's a 2D rotation matrix, then it equals $$R(\theta)=\begin{pmatrix} \cos\theta & -\sin\theta\\ \sin\theta & \cos \theta \end{pmatrix}$$ where $\theta$ is the angle you are looking for. Therefore, you can simply take $\cos^{-1}$ of the first entry in your matrix.

Due to the periodicity of the cosine function though, you won't know the sign of $\theta$ (i.e., whether it is clockwise or anticlockwise). You can determine this by noting the signs of the sines (e.g. if the angle is $-30^\circ$, then the $\sin$ entry in the first column would be negative).

  • $\begingroup$ Note that that's not the complete answer. You still need to distinguish between clockwise and anticlockwise. You can do that by looking at the sign of the off-diagonal entries. $\endgroup$ – Arthur Sep 9 at 16:11
  • 2
    $\begingroup$ I would use the atan2 function on the entries with $\cos$ and $\sin$, otherwise you can get the direction wrong: $$\cos\theta=\cos(-\theta)$$ $\endgroup$ – Andrei Sep 9 at 16:11
  • 1
    $\begingroup$ You're right, let me edit my answer. $\endgroup$ – Luke Collins Sep 9 at 16:12
  • $\begingroup$ This looks like I what I'm looking for, thanks. What does @Andrei mean by the entries with cos and sin for atan2? There are two of each in the matrix. $\endgroup$ – Incredidave Sep 9 at 16:17
  • $\begingroup$ The definition of tangent is $\tan\theta=\frac{\sin\theta}{\cos\theta}$. The atan2 function takes two inputs, the cosine and the sine. So, in this case, use the two values in the first column. $\endgroup$ – Andrei Sep 9 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.