Skip to content

3D Rotations with matrices

1. Represent points as vectors

A 3D point is a column vector:

P = [ x  
      y  
      z ]

2. Rotation matrices

Each axis has a fixed matrix:

Rotate around X

Rx(θ) =  
[ 1      0         0  
  0   cos(θ)   -sin(θ)  
  0   sin(θ)    cos(θ) ]

Rotate around Y

Ry(θ) =  
[ cos(θ)   0   sin(θ)  
    0      1      0  
 -sin(θ)   0   cos(θ) ]

Rotate around Z

Rz(θ) =  
[ cos(θ)  -sin(θ)   0  
  sin(θ)   cos(θ)   0  
    0         0     1 ]

3. Apply rotation

Multiply matrix × vector:

P' = R * P

4. Combine rotations

You can combine multiple rotations into one matrix:

R = Rz * Ry * Rx  
P' = R * P

Order matters.

5. Problem: translation is separate

Basic 3×3 matrices only handle rotation (and scaling), not translation.

So normally you'd do:

P' = R * (P - C) + C

(where C is the rotation centre)