# Understanding rotation matrices

1. How does ${\sqrt 2 \over 2} = \cos (45^\circ)$?

2. Is my graph (the one underneath the original) accurate with how I've depicted the representation of the triangle that the trig function represent? What I mean is, the blue triangle is the pre-rotated block, the green is the post-rotated block, and the purple is the rotated change ($45^\circ$) between them.

3. How do these trig functions in this matrix represent a clockwise rotation? (Like, why does "$-\sin \theta$ " in the bottom left mean clockwise rotation... and "$- \sin \theta$ " in the upper right mean counter clockwise? Why not "$-\cos \theta$ "? $$\begin{bmatrix}\cos \theta &\sin \theta \\-\sin \theta & \cos \theta \end{bmatrix}$$

Any help in understanding the trig representations of a rotation would be extremely helpful! Thanks

-
For the third question: If you believe that the matrix for counter clockwise rotation is correct, then to obtain the clockwise matrix, just replace $\phi$ by $-\phi$. Rules of trigonometry will then tell you that $\cos -\phi = \cos \phi$ and $\sin -\phi = -\sin \phi$, leading to the clockwise matrix you have. – TMM Apr 16 '13 at 19:50

All of the trigonometry will be clear if you examine what happens to the points $(1,0)$ and $(0,1)$ under these transformations. After they have moved, drop a perpendicular vertically and a line through the origin and consider the triangle formed. They will be (sometimes degenerate) triangles with hypotenuese 1 and then you will see why each of their legs has measure $\sin(\phi)$ or $\cos(\phi)$ etc.

Here's what I mean: after a $\pi/6$ rotation counterclockwise, the point $(1,0)$ has moved to $(\sqrt{3}/2,1/2)$. This point, in addition to $(0,0)$ and the point directly below it on the $x$ axis, $(\sqrt{3}/2,0$ form a right triangle with hypoteneuse $1$. Look at lengths of the short sides of the triangle. Try to do the same thing with an angle $\phi$ between 0 and $\pi/2$, and analyze what the sides of the triangle have to be in terms of $\sin(\phi)$ and $\cos(\phi)$.

Because a rotation in the plane is totally determined by how it moves points on the unit circle, this is all you have to understand.

You don't actually need a representation for both clockwise and counterclockwise. You can use the counterclockwise one all the time, if you agree that a clockwise rotation would be a negative counterclockwise rotation. That is, if you want to perform a clockwise rotation of $\pi/4$ radians, then you should use $\phi=-\pi/4$ in the counterclockwise rotation representation.

The fact that $\sin(-\phi)=-\sin(\phi)$ accounts for the change in the sign of sine between the two representations, and the fact that the $\cos(\phi)$ doesn't change is because $\cos(-\phi)=\cos(\phi)$. You may as well just pick the counterclockwise representation scheme, and perform both clockwise and counterclockwise rotations with it.

To provide some extra evidence that it makes sense these are rotation matrices, you can check to see that the columns of these matrices always have Euclidean length 1 (easy application of the $\sin^2(x)+\cos^2(x)=1$ identity.) Moreover, they are orthogonal to each other. That means they are orthogonal matrices, and consequently represent rotations. They satisfy $UU^T=U^TU=I_2$. This demonstrates that $U^T=U^{-1}$, and now you'll notice that the transpose of the counterclockwise representation gives you the clockwise representation! Of course, rotating clockwise and rotating counterclockwise by $\phi$ radians are inverse operations.

-
drop a perpendicular vertically and consider the triangle formed - what does this mean? and Because a rotation in the plane is totally determined by how it moves points on the unit circle, this is all you have to understand. do you think you can diagram this point out? – Growler Apr 16 '13 at 19:38
@Growler I wish I knew how to do pictures well on here! I'll clarify my explanation and include an example asap. – rschwieb Apr 16 '13 at 19:40
I guess you could do it in paint or some other tool then append the picture to your answer? – Growler Apr 16 '13 at 19:41
@Growler OK, I finished adding a bit. Let me know if I should say more. I think you'll be able to draw it based on that. – rschwieb Apr 16 '13 at 19:45

Imagine you have the following rotation matrix:

$$\left[ \begin{array}{ccc} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{array} \right]$$

At first one might think this is just another identity matrix. Well, yes and no. This matrix can represent a rotation around all three axes in 3D Euclidean space with...zero degrees. This means that no rotation has taken place around any of the axes.

As we know $\cos(0) = 1$ and $\sin(0) = 0$.

Each column of a rotation matrix represents one of the axes of the space it is applied in so if we have 2D space the default rotation matrix (that is - no rotation has happened) is

$$\left[ \begin{array}{cc} 1 & 0\\ 0 & 1 \end{array} \right]$$

Each column in a rotation matrix represents the state of the respective axis so we have here the following:

$$\left[ \begin{array}{c|c} 1 & 0\\ 0 & 1 \end{array} \right]$$

First column represents the x axis and the second one - the y axis. For the 3D case we have:

$$\left[ \begin{array}{c|c|c} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{array} \right]$$

Here we are using the canonical base for each space that is we are using the unit vectors to represent each of the 2 or 3 axes.

Usually I am a fan of explaining such things in 2D however in 3D it is much easier to see what is happening. Whenever we want to rotate around an axis, we are basically saying "The axis we are rotating around is the anchor and will NOT change. The other two axes however will".

$$\left[ \begin{array}{c|c|c} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{array} \right]$$

and want to rotate around - let's say - the x axis we will do

$$\left[ \begin{array}{c|c|c} 1 & 0 & 0\\ 0 & \cos(\theta) & -\sin(\theta)\\ 0 & \sin(\theta) & \cos(\theta) \end{array} \right] . \left[ \begin{array}{c|c|c} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{array} \right] = \left[ \begin{array}{c|c|c} 1 & 0 & 0\\ 0 & \cos(\theta) & -\sin(\theta)\\ 0 & \sin(\theta) & \cos(\theta) \end{array} \right]$$

What this means is:

• The state of the x axis remains unchanged - we've started with a state of no rotation so the x axis will retain its original state - the unit vector $\left[\begin{array}{c}1\\0\\0\end{array}\right]$
• The state of the y and z axis has changed - instead of the original $\left[\begin{array}{c}0\\1\\0\end{array}\right]$ (for y) and $\left[\begin{array}{c}0\\0\\1\end{array}\right]$ (for z) we now have $\left[\begin{array}{c}0\\\cos(\theta)\\\sin(\theta)\end{array}\right]$ (for the new orientation of y) and $\left[\begin{array}{c}0\\-\sin(\theta)\\\cos(\theta)\end{array}\right]$ (for the new orientation of z).

We can continue applying rotations around this and that axis and each time this will happen - the axis we are rotating around remains as it was in the previous step and the rest of the axes change accordingly.

Now when it comes to 2D we have $$R(\theta) = \left[ \begin{array}{c|c} \cos(\theta) & -\sin(\theta)\\ \sin(\theta) & \cos(\theta) \end{array} \right]$$

for clockwise rotation and

$$R(-\theta) = \left[ \begin{array}{c|c} \cos(\theta) & \sin(\theta)\\ -\sin(\theta) & \cos(\theta) \end{array} \right]$$

for counterclockwise rotation. Notice that both column vectors are different. This is because in 2D none of the two axes remains idle and both need to change in order to create a rotation. This is why also the 3D version has two of the three axes change simultaneously - because it is just a derivative from its 2D version.

When it comes to rotating clock- or counterclockwise you can always use the left or right hand rule:

1. Use your right or left hand to determine the axes:

1. See which way is clock- and which way is counterclockwise:

Once you pick one of the two hands stick with it and use it until the end of the specific task otherwise the results will probably end up screwed up. Notice also that this rule can also be applied to 2D. Just remove (but not cut off) the finger that points along the z axis (or whichever dimension of the three you don't need) and do your thing.

A couple of must knows things:

1. Matrix multiplication is generally not commutative - what this means is that $A.B \ne B.A$

2. Rotation order is determined by the multiplication order (due to 1)) - there are a LOT of rotation conventions (RPY (roll,pitch and yaw), Euler angles etc.) so it is important to know which one you are using. If you are not certain pick one and stick with it (better have one consistent error than 10 different errors that you cannot follow up on) (see here for some compact information on this topic)

3. Inverse of a rotation matrix rotates in the opposite direction - if for example $R_{x,90}$ is a rotation around the x axis with +90 degrees the inverse will do $R_{x,-90}$. On top of that rotation matrices are awesome because $A^{-1} = A^t$ that is the inverse is the same as the transpose

-