[Math] Rotation matrix if X Y Z (The angles through which x y and z axis have been rotated ) are given.

rotations

If the x-axis is rotated by X degrees and y, z-axis by Y and Z degrees respectively, then how to find the rotation matrix.
X Y Z are the angles by which each axis is rotated from the reference axis. For a single rotation of 45 degrees about z axis, X=45 Y=45 and Z=0.
I am trying to do this by using the basic mathematical definition of the rotation matrix.
\begin{bmatrix}x1.x0&x1.y0&x1.z0\\y1.x0&y1.y0& y1.z0\\
z1.x0&z1.y0&z1.z0
\end{bmatrix}

When I substitute the values fo dot products (unit vectors) I get
\begin{bmatrix}cos(X)&cos(90+Y)&cos(90-Z)\\cos(90-X)&cos(90)& cos(90+Z)\\
cos(90+X)&cos(90-Y)&cos(Z)
\end{bmatrix}

This matrix must reduce to the basic rotation matrix of z-axis when Z=0 is substituted, but it is not happening. What's wrong with this approach?

Best Answer

It should be clarified: matrix multiplication is not commutative, and so it is important to specify the order in which you want to perform rotations.

A counterclockwise rotation by $\theta$ about the x-axis, y-axis and z-axis are represented by the matrices:

$$ R_x(\theta) = \begin{bmatrix} 1 & 0 & 0\\ 0 & \cos{\theta} & -\sin{\theta}\\ 0 & \sin{\theta} & \cos{\theta}\\\end{bmatrix}\,,$$

$$ R_y(\theta) = \begin{bmatrix} \cos{\theta} & 0 & \sin{\theta}\\ 0 & 1 & 0\\ -\sin{\theta} & 0 & \cos{\theta}\\\end{bmatrix}\,,$$

$$ R_z(\theta) = \begin{bmatrix} \cos{\theta} & -\sin{\theta} & 0\\ \sin{\theta} & \cos{\theta} & 0\\ 0 & 0 & 1\end{bmatrix}\,,$$

respectively.

Assuming you want the matrix representation $R$ of a counterclockwise rotation by $X$, $Y$ and $Z$ about the x-axis, y-axis and z-axis, respectively, then obtaining the matrix is trivial:

$$ R = R_z(Z) R_y(Y) R_x(X) = \ldots$$