[Math] Given the degrees to rotate around axis, how do you come up with rotation matrix

matricesrotations

Given angles (in degrees) to rotate around, $x$-, $y$-, $z$-axis how does one come up with the rotation matrix? For example if you have a point $p$ represented by a vector, how do you rotate it by multiplying it with a matrix $A$ so $p = Ap$.

From Wikipedia:

A basic rotation (also called elemental rotation) is a rotation about one of the axes of a coordinate system. The following three basic rotation matrices rotate vectors by an angle $\theta$ about the $x$, $y$, or $z$ axis, in three dimensions:

$$R_{x}(\theta)=\left[\begin{array}{ccc}1 & 0 & 0 \\ 0 & \cos \theta & -\sin \theta \\ 0 & \sin \theta & \cos \theta\end{array}\right]$$
$$R_{y}(\theta)=\left[\begin{array}{ccc}\cos \theta & 0 & \sin \theta \\ 0 & 1 & 0 \\ -\sin \theta & 0 & \cos \theta\end{array}\right]$$
$$R_{z}(\theta)=\left[\begin{array}{cc}\cos \theta & -\sin \theta & 0 \\ \sin \theta & \cos \theta & 0 \\ 0 & 0 & 1\end{array}\right]$$

I'm a little unclear. So you need a different rotation matrix for each one of the axis? Is there a way just to get one rotation matrix that covers the rotations done to each axis? Am I even reading this right, so $R_x(\theta)$ is the matrix used to perform the rotation about the $x$-axis for $\theta$ degrees?

Best Answer

If $R_x$ rotates around the $x$-axis, and $R_y$ rotates around the $y$-axis, and you want to rotate first around $x$, and then around $y$, simply apply $R_y R_x$ to your vector, let's call it $v$.

This is because $R_x v$ rotates $v$ around the $x$-axis, then $R_y(R_x v)$ rotates $R_x v$ around the $y$-axis.