# Thread: Angle from 2x2 rotation matrix

1. ## Angle from 2x2 rotation matrix

Hy, I need to calculate angle from 2x2 rotation matrix. How exactly i can do that?
Thank you, for help.

2. Originally Posted by PJani
Hy, I need to calculate angle from 2x2 rotation matrix. How exactly i can do that?
Thank you, for help.
You mean this kind of rotation matrix?

$\begin{bmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \\ \end{bmatrix}$

Rotation matrix - Wikipedia, the free encyclopedia

You can derive the rotation matrix by considering what (1,0) and (0,1) map to when rotated by angle theta.

If you have a matrix of that form and need to find theta, you can do so using inverse trig functions.

3. Jep this form i mean.

This will look weird but i just want to get sure its correct.
$\begin{bmatrix} acos(\cos \theta) & asin(--\sin \theta) \\ asin(\sin \theta) & acos(\cos \theta) \\ \end{bmatrix}$

and all elements must be the same if i am not mistaking.

4. Originally Posted by PJani
Jep this form i mean.

This will look weird but i just want to get sure its correct.
$\begin{bmatrix} acos(\cos \theta) & asin(--\sin \theta) \\ asin(\sin \theta) & acos(\cos \theta) \\ \end{bmatrix}$

and all elements must be the same if i am not mistaking.
Sorry I don't know what you mean. Is the matrix you wrote part of the problem, or is it your part of your answer? Would you be able to post the full question?

In general you should be careful about the domain and range of the inverse trig functions.

5. It is part of my answer.
hmm full question...
...Actually i am working on 2D game. And for debug display its hard to read 2x2 transformation matrix in realtime. So i only want to get angle and display it.

6. Originally Posted by PJani
It is part of my answer.
hmm full question...
...Actually i am working on 2D game. And for debug display its hard to read 2x2 transformation matrix in realtime. So i only want to get angle and display it.
Okay, it was a little confusing that you wrote it in matrix form, but I see what you're saying; mainly I would just be careful about domain and range, for example asin(sin(pi/6)) will return pi/6, but asin(sin(5pi/6)) will also return pi/6.