# Why is rotation about the y axis in $\mathbb{R^3}$ different from rotation about the x and y axis.

In my textbook for a counterclockwise rotation about the x axis we have $\begin{pmatrix} 1 & 0 & 0\\ 0 & \cos\theta & -\sin\theta \\ 0 & \sin\theta & \cos\theta \end{pmatrix}$ For rotation about the z axis we have $\begin{pmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{pmatrix}$. Now for rotation about the why axis it's listed as $\begin{pmatrix} \cos\theta & 0 & \sin\theta \\ 0 & 1 & 0 \\ -\sin\theta & 0 & \cos\theta \end{pmatrix}$. I can see that they changed it to the rotational matrix for a clockwise matrix but it says right infront of these 3 matrices that they are all for counterclockwise rotations so I'm not entirely sure what's going on.

They are all three the same rotation direction. The thing at play here is orientations of coordinate systems.

What right rotation (if you point your right hand thumb along the axis and close your other fingers they will point to the direction of the rotation) around the X-axis does is rotate the Y axis towards the Z axis if XYZ is a right oriented coordinate system (if you take your right hand you can point the thumb in X direction, index finger in Y direction and middle finger in the Z direction).

Now similar is true for rotation about the Z axis, it rotates the X axis towards the Y axis because ZXY is also a right oriented coordinate system.

In fact reordering the axis by rotating/shifting the axes preserves the orientation so XYZ, YZX and ZXY are all positive oriented systems (but just swapping two axes makes it the opposite orientation - giving left orientation). You can also note that swapping twice gets back to the original orientation (all of XYZ, YZX and ZXY can be obtained by swapping two axes).

Now look at what happens to a matrix when you swap axes, then you swap both corresponding columns and rows. And if you do it twice you see that you actually arrive at the three possible matrixes (you can also rotate column- and row- wise if that suits your mind better).

If you sight back along the positive $y$-axis toward the origin with the positive $z$-axis pointed upward, the positive $x$-axis points to the left. I.e., taken by itself, the $xz$-plane has a left-handed coordinate system. This means that negative angles correspond to counterclockwise rotations, which is why the third rotation matrix looks like it’s backwards.

Another way to convince yourself that the matrix is correct is to look at the effect of a counterclockwise rotation through an angle of $\pi/2$: this takes the positive $x$-axis onto the negative $z$-axis and the positive $z$-axis onto the positive $x$-axis. If you plug $\pi/2$ into the third matrix, you’ll see that its first column is $(0,0,-1)^T$ and its third column is $(1,0,0)^T$ just as required.

If you write down your axes by going from one axis to the axis which is left of it, you get $x$, $z$, $y$.

If you continue, you get $x$, $z$, $y$, $x$, $z$, $y$.

Now, observe that your three matrices are just $3\times3$ sub-matrices of \begin{equation*} \begin{pmatrix} 1 & 0 & 0 & 1 & 0 & 0 \\ 0 & \cos(\theta) & -\sin(\theta) & 0 & \cos(\theta) & -\sin(\theta) \\ 0 & \sin(\theta) & \cos(\theta) & 0 & \sin(\theta) & \cos(\theta) \\ 1 & 0 & 0 & 1 & 0 & 0 \\ 0 & \cos(\theta) & -\sin(\theta) & 0 & \cos(\theta) & -\sin(\theta) \\ 0 & \sin(\theta) & \cos(\theta) & 0 & \sin(\theta) & \cos(\theta) \end{pmatrix} \end{equation*} which is just the usual rotation matrix together with three copies. And these sub-matrices come in the order $x$, $z$, $y$.

In two dimensions the notion of clockwise and counter clockwise is well defined because all observers of the plane observe it from one direction only. In three dimensions you have two equally legitimate points of view: When rotating around the $z$-axis, for example, you may choose to place an observer at $(0,0,1)$, for whom the rotation about the $z$-axis you wrote will seem as counter clockwise, or you could put an observer at the opposite point $(0,0,-1)$ for whom the same rotation will seem a clockwise rotation. In your case, the rotation for the $y$ axis looks "wrong" to you because you are observing it's effect from the point $(0,-1,0)$. To "see" it correctly, switch to the opposite point, $(0,1,0)$.