<s>[INST] Why do the signs of $\sin\theta$ change in 3d rotation matrices about the different coordinate axes? Using matrices for 3-dimensional rotations, I'm confused on why the signs change $\sin(\theta)$ to $-\sin(\theta)$ when rotating around the $z$-axis. What is the cause of this?

*

*Rotate X and Y around the Z-axis
$$\begin{bmatrix}
\cos\theta & -\sin\theta & 0\\
\sin\theta & \phantom{-}\cos\theta & 0\\
0 & 0 & 1
\end{bmatrix}
$$


*Rotate Y and Z around the X-axis
$$\begin{bmatrix}
1 & 0 & 0\\
0 & \cos\theta & -\sin\theta\\
0 & \sin\theta & \phantom{-}\cos\theta
\end{bmatrix}
$$


*Rotate X and Z around the Y-axis
$$\begin{bmatrix}
\phantom{-}\cos\theta & 0 & \color{red}{\sin\theta}\\
0 & 1 & 0\\
\color{red}{-\sin\theta} & 0 & \cos\theta
\end{bmatrix}
$$
 [/INST] This is a manifestation of the handedness of coordinate systems. Only $(\mathbf{i},\mathbf{j},\mathbf{k})$, $(\mathbf{j},\mathbf{k},\mathbf{i})$ and
$(\mathbf{k},\mathbf{i},\mathbf{j})$ are right handed systems. This plays a role because we need the handedness of the system to determine whether a rotation is clockwise/counterclockwise. In other words, the $xyz$-coordinates should be viewed in a cyclic order: $x$ followed by $y$ followed by $z$ followed by $x$ et cetera.
Think of these matrices as follows. The first coordinate is that of the axis of rotation, then the other two in the order indicated above.
The apparent difference between the last rotation matrix and the others reflects this. You are looking at the matrix as if the $x$ coordinate were still the first coordinate after the axis of rotation (there $y$) even though we really should stick to $y$ followed by $z$ followed $x$.

The $-\sin\theta$ term always appears on the row immediately below of the diagonal $1$ and on the column to the left of that diagonal $1$. It is just that when that diagonal $1$ appears on the bottom row (resp. left column) then the row below (resp. the column to the left) wraps around.

Another way of seeing this is to expand the matrices to $5\times5$ matrices by replicating $x$ and $y$ rows/columns, in the order $x,y,z,x,y$. Like this:
$$
\left(\begin{array}{rrrrr}
\cos\theta&-\sin\theta&0&\cos\theta&-\sin\theta\\
\sin\theta&\cos\theta&0&\sin\theta&\cos\theta\\
0&0&1&0&0\\
\cos\theta&-\sin\theta&0&\cos\theta&-\sin\theta\\
\sin\theta&\cos\theta&0&\sin\theta&\cos\theta
\end{array}\right)
$$
Do you see the diagonal $3\times3$ blocks here now that the coordinates follow the right handed ordering?
$$
\left(\begin{array}{rrrrr}
\color{red}{\cos\theta}&\color{red}{-\sin\theta}&\color{red}0&\cos\theta&-\sin\theta\\
\color{red}{\sin\theta}&\color{red}{\cos\theta}&\color{red}{0}&\sin\theta&\cos\theta\\
\color{red}0&\color{red}0&\color{red}1&0&0\\
\cos\theta&-\sin\theta&0&\cos\theta&-\sin\theta\\
\sin\theta&\cos\theta&0&\sin\theta&\cos\theta
\end{array}\right),
$$
$$
\left(\begin{array}{rrrrr}
{\cos\theta}&{-\sin\theta}&0&\cos\theta&-\sin\theta\\
{\sin\theta}&\color{red}{\cos\theta}&\color{red}{0}&\color{red}{\sin\theta}&\cos\theta\\
0&\color{red}0&\color{red}1&\color{red}0&0\\
\cos\theta&\color{red}{-\sin\theta}&\color{red}0&\color{red}{\cos\theta}&-\sin\theta\\
\sin\theta&\cos\theta&0&\sin\theta&\cos\theta
\end{array}\right)
$$
and
$$
\left(\begin{array}{rrrrr}
\cos\theta&-\sin\theta&0&\cos\theta&-\sin\theta\\
\sin\theta&\cos\theta&0&\sin\theta&\cos\theta\\
0&0&\color{red}1&\color{red}0&\color{red}0\\
\cos\theta&-\sin\theta&\color{red}0&\color{red}{\cos\theta}&\color{red}{-\sin\theta}\\
\sin\theta&\cos\theta&\color{red}0&\color{red}{\sin\theta}&
\color{red}{\cos\theta}
\end{array}\right)
$$
This way we see that the three matrices really are the same when we keep track of the cyclic order of the coordinates.
</s>