# How do rotational matrices work? [duplicate]

I am confuse on the how exactly rotational matrices work. So I understand that you can rotate a point around the x, y and z axis but if asked how you find a single matrix that will show the same rotation if you were to rotate it along the x, y and z axis in that order. Any help would be appreciated!

## marked as duplicate by Marc van Leeuwen, user63181, Stefan Hansen, Davide Giraudo, TooToneMar 18 '14 at 11:38

• This is totally unclear. Rotate a matrix around the $x,y$ and $z$ axes? – Marc van Leeuwen Mar 18 '14 at 10:07

The nice thing about matrices as representations for linear mappings is that you can combine (concatenate) mappings simply by multiplying their respective matrices. A rotation around the $x$-Axis in $\mathbb{R}^3$ is specified by the matrix $$M_x(\varphi) = \begin{pmatrix}1 & 0 & 0 \\ 0 & cos \varphi & -\sin \varphi \\ 0 & \sin \varphi & \cos \varphi \end{pmatrix} \text{,}$$ a rotation around the $y$-Axis is specified by $$M_y(\vartheta) = \begin{pmatrix}\cos\vartheta & 0 & -\sin\vartheta \\ 0 & 1 & 0 \\ \sin\vartheta & 0 & \cos \vartheta \end{pmatrix} \text{,}$$ and a rotation around the $z$-Axis by $$M_z(\rho) = \begin{pmatrix}cos \rho & -\sin \rho & 0\\ \sin \rho & \cos \rho & 0 \\ 0 & 0 & 1\end{pmatrix} \text{.}$$ To find the matrix representing the mapping which first rotates around the $x$-Axis, then around the $y$-Axis and finally around the $z$-Axis, just multiply the three matrices, i.e. compute $$M(\varphi,\vartheta,\rho) = M_z(\varphi)M_y(\vartheta)M_x(\rho) \text{.}$$ Note that it is the rightmost matrix in such a product that is applied first. This is because such products are associative, i.e. $$M \mathbf{x} = (M_x M_y M_z) \mathbf{x} = M_x (M_y (M_z \mathbf{x})) \text{.}$$

• Thank you very much! that is exactly what I needed! – user136207 Mar 18 '14 at 10:02

Wikipedia has a decent explantion: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation

To understand how they get their equations let's consider a 2D case where you have a point $(x,y)$ and you want to rotate to $\phi$ degrees clockwise to get $(x',y')$. If we convert to polar coorindates then this would be really simple so lets do that.

$$x=r\cos(\theta)$$ $$y=r\sin(\theta)$$

now rotate by $\phi$ degress and covert back to Cartesian coordiantes:

$$x' = r\cos{(\theta-\phi)}$$ $$=r\cos(\theta)\cos(-\phi)-r\sin(\theta)\sin(-\phi)$$ $$\therefore x' =x\cos(\phi)+y\sin(\phi)$$

similarly $$y'=-x\sin(\phi)+y\sin(\phi)$$

so the idea of the rotation matrix is to just summarise those two equations in to one matrix equation:

$$\begin{pmatrix}x'\\y'\end{pmatrix} = \begin{pmatrix}\cos \phi & \sin \phi \\ -\sin \phi & \cos \phi \end{pmatrix} \begin{pmatrix}x\\y\end{pmatrix}$$

Which if you multiply out give you exactly the rotation equations we derived by rotation in polar coordinates.