Rotation matrix 2D\[ R_{\theta }=\begin {bmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end {bmatrix} \] Rotation matrix 3D\begin {align*} R_{x}\left (\theta \right ) & =\begin {bmatrix} 1 & 0 & 0\\ 0 & \cos \theta & -\sin \theta \\ 0 & \sin \theta & \cos \theta \end {bmatrix} \\ R_{y}\left (\theta \right ) & =\begin {bmatrix} \cos \theta & 0 & \sin \theta \\ 0 & 1 & 0\\ -\sin \theta & 0 & \cos \theta \end {bmatrix} \\ R_{z}\left (\theta \right ) & =\begin {bmatrix} \cos \theta & -\sin \theta & 0\\ \sin \theta & \cos \theta & 0\\ 0 & 0 & 1 \end {bmatrix} \end {align*}
This is how to find the above. First row, is the projection of \(x^{\prime },y^{\prime },z^{\prime }\) on \(x\). Second row is projection of \(x^{\prime },y^{\prime },z^{\prime }\) on \(y\) and so on.
Spherical coordinates\begin {align*} x & =r\sin \theta \cos \phi \\ y & =r\sin \theta \sin \phi \\ z & =r\cos \theta \end {align*}