Labs ICT
Pro Login

3D Transformations

Translation, rotation, scaling in 3D space

3D Transformations

3D transformations extend 2D concepts into three dimensions using 4x4 homogeneous coordinate matrices. These transformations position, orient, and scale objects in 3D space.

Translation

4x4 Translation Matrix:

  [ 1   0   0   tx ] [ x ]   [ x + tx ]
  [ 0   1   0   ty ] [ y ] = [ y + ty ]
  [ 0   0   1   tz ] [ z ]   [ z + tz ]
  [ 0   0   0   1  ] [ 1 ]   [ 1      ]

Scaling

4x4 Scaling Matrix:

  [ sx  0   0   0 ]
  [ 0   sy  0   0 ]
  [ 0   0   sz  0 ]
  [ 0   0   0   1 ]

Rotation

3D rotation is more complex — rotations can occur around any axis.

Rotation around X-axis (Rx):

  [ 1    0     0    0 ]
  [ 0   cosθ  -sinθ 0 ]
  [ 0   sinθ   cosθ 0 ]
  [ 0    0     0    1 ]

Rotation around Y-axis (Ry):

  [ cosθ   0   sinθ  0 ]
  [ 0      1   0     0 ]
  [-sinθ   0   cosθ  0 ]
  [ 0      0   0     1 ]

Rotation around Z-axis (Rz):

  [ cosθ  -sinθ  0   0 ]
  [ sinθ   cosθ  0   0 ]
  [ 0      0     1   0 ]
  [ 0      0     0   1 ]

Combined Rotation

General rotation: Rx * Ry * Rz

  Euler angles: yaw, pitch, roll
  - Yaw   = rotation around Y
  - Pitch = rotation around X
  - Roll  = rotation around Z

  M = Ry(yaw) * Rx(pitch) * Rz(roll)

Warning: Euler angles suffer from gimbal lock.

Rotation Matrices for Arbitrary Axes

Rotation by θ around unit axis (ux, uy, uz):

  R = [ cosθ + ux²(1-cosθ)       ux·uy(1-cosθ) - uz·sinθ  ux·uz(1-cosθ) + uy·sinθ  0 ]
      [ uy·ux(1-cosθ) + uz·sinθ  cosθ + uy²(1-cosθ)       uy·uz(1-cosθ) - ux·sinθ  0 ]
      [ uz·ux(1-cosθ) - uy·sinθ  uz·uy(1-cosθ) + ux·sinθ  cosθ + uz²(1-cosθ)       0 ]
      [ 0                         0                         0                         1 ]

🧪 Quick Quiz

What is a homogeneous coordinate in 3D graphics?