user
What are the rotation matrices in 3D ?
alphonsio

In 3D space, rotation matrices are used to rotate points or objects around one of the coordinate axes (x, y, or z). Each of these is a 3×3 orthogonal matrix with determinant = 1. Here are the standard rotation matrices for counterclockwise rotation:

Illustration of angle orientation in rotation matrice

We’ll assume:

  • α = rotation about the X-axis
  • β = rotation about the Y-axis
  • γ = rotation about the Z-axis

1. Rotation about the X-axis (by α):

Rotates around the x-axis, affecting the y and z coordinates:

Rx(α)=[1000cosαsinα0sinαcosα]R_x(\alpha) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos\alpha & -\sin\alpha \\ 0 & \sin\alpha & \cos\alpha \end{bmatrix}

Rotation about the Y-axis (by β):

Rotates around the y-axis, affecting the x and z coordinates:

Ry(β)=[cosβ0sinβ010sinβ0cosβ]R_y(\beta) = \begin{bmatrix} \cos\beta & 0 & \sin\beta \\ 0 & 1 & 0 \\ -\sin\beta & 0 & \cos\beta \end{bmatrix}

3. Rotation about the Z-axis (by γ):

Rotates around the z-axis, affecting the x and y coordinates:

Rz(γ)=[cosγsinγ0sinγcosγ0001]R_z(\gamma) = \begin{bmatrix} \cos\gamma & -\sin\gamma & 0 \\ \sin\gamma & \cos\gamma & 0 \\ 0 & 0 & 1 \end{bmatrix}


Combining Rotations

To rotate around multiple axes, you can multiply the corresponding rotation matrices together:

R=Rz(γ)Ry(β)Rx(α)R = R_z(\gamma) \cdot R_y(\beta) \cdot R_x(\alpha)

Where α, β, and γ are the rotation angles about x, y, and z axes, respectively. The order matters — matrix multiplication is not commutative.

Assuming we rotate in the order X → Y → Z (i.e. R = Rz * Ry * Rx), the full rotation matrix is:

R(α,β,γ)=Rz(γ)Ry(β)Rx(α)R(\alpha, \beta, \gamma) = R_z(\gamma) \cdot R_y(\beta) \cdot R_x(\alpha)

Multiplying them out gives:

R=[cosγcosβcosγsinβsinαsinγcosαcosγsinβcosα+sinγsinαsinγcosβsinγsinβsinα+cosγcosαsinγsinβcosαcosγsinαsinβcosβsinαcosβcosα]R = \begin{bmatrix} \cos\gamma\cos\beta & \cos\gamma\sin\beta\sin\alpha - \sin\gamma\cos\alpha & \cos\gamma\sin\beta\cos\alpha + \sin\gamma\sin\alpha \\ \sin\gamma\cos\beta & \sin\gamma\sin\beta\sin\alpha + \cos\gamma\cos\alpha & \sin\gamma\sin\beta\cos\alpha - \cos\gamma\sin\alpha \\ -\sin\beta & \cos\beta\sin\alpha & \cos\beta\cos\alpha \end{bmatrix}

Notes

  • This is often referred to as ZYX Euler angles.
  • The order of multiplication matters: ZYX is common, but XYZ, YXZ, etc. are also used depending on the context (like aerospace vs robotics).
  • If you want intrinsic rotations (relative to the rotating axes), or extrinsic (relative to fixed axes), the interpretation changes slightly.