rotation1

$P = (x, y) = (1, 0)$ $P' = (x', y' )$

$\cos{\theta} = \frac{x'}{x}$ $\sin{\theta} = \frac{y'}{x}$

therefore:

$x' = \cos{\theta} \cdot x$ $y' = \sin{\theta} \cdot x$

similarly:

rotation2

$Q = (x, y) = (0, 1)$ $ Q' = (x', y' )$

$\cos{\theta} = \frac{y'}{y}$ $\sin{\theta} = \frac{-x'}{y}$

therefore:

$x' = -\sin{\theta} \cdot y$ $y' = \cos{\theta} \cdot y$

add them together:

$\begin{bmatrix} \cos{\theta} & -\sin{\theta} \\
\sin{\theta} & \cos{\theta} \\
\end{bmatrix}$, it rotates counter-clockwise

$\begin{bmatrix} \cos{\theta} & \sin{\theta} \\
-\sin{\theta} & \cos{\theta} \\
\end{bmatrix}$, it rotates clockwise