Skip to content
Level 1Drill-down concept

Transformation Matrices

What the parent explanation assumed you knew:

You have a basic understanding that 3D graphics involves moving, rotating, and scaling objects.

What this page explains:

How 4×4 matrices encode all possible 3D transformations (translation, rotation, scale) and why matrix multiplication lets us combine them efficiently.

The Explanation

In 3D graphics, every object's position, orientation, and size is controlled by a 4×4 transformation matrix. This single matrix can encode any combination of translation (moving), rotation (turning), and scale (resizing).

Why 4×4 instead of 3×3?

A 3×3 matrix can handle rotation and scale, but not translation. The trick is to use homogeneous coordinates - adding a 4th coordinate (w=1 for points, w=0 for directions).

The Structure:

| Rx  Ry  Rz  Tx |     Rotation + Scale (3×3)  |  Translation
| Rx  Ry  Rz  Ty |     in the upper-left       |  in the right
| Rx  Ry  Rz  Tz |     corner                  |  column
| 0   0   0   1  |     Always [0, 0, 0, 1] for affine transforms

Identity Matrix (No Change):

| 1  0  0  0 |
| 0  1  0  0 |  × point = same point
| 0  0  1  0 |
| 0  0  0  1 |

Translation (Move):

To move by (tx, ty, tz):

| 1  0  0  tx |
| 0  1  0  ty |  × (x, y, z, 1) = (x+tx, y+ty, z+tz, 1)
| 0  0  1  tz |
| 0  0  0  1  |

Scale:

To scale by (sx, sy, sz):

| sx 0  0  0 |
| 0  sy 0  0 |  × (x, y, z, 1) = (x×sx, y×sy, z×sz, 1)
| 0  0  sz 0 |
| 0  0  0  1 |

Rotation (around Z axis by θ):

| cos(θ) -sin(θ)  0  0 |
| sin(θ)  cos(θ)  0  0 |
| 0       0       1  0 |
| 0       0       0  1 |

The Power: Composition

Multiply matrices together to combine transformations:

M_final = M_translate × M_rotate × M_scale

Order Matters!

Matrix multiplication is not commutative:

  • Rotate then translate ≠ Translate then rotate
  • Read right-to-left: M₃ × M₂ × M₁ means 'first M₁, then M₂, then M₃'

In Skeletal Animation:

Each bone stores its local transform matrix. To find a vertex's world position:

world_position = M_root × M_spine × M_shoulder × M_arm × M_hand × local_position

This chain of multiplications is why bone hierarchies work - moving the shoulder automatically moves everything below it.

Visual Aid

Manipulate translation, rotation, and scale values and see the resulting 4×4 matrix and its effect on a 3D cube.

Open interactive demo →

The "Aha" Moment

A 4×4 matrix is a compact encoding of 'where is this object and what does it look like?' - and multiplying matrices lets us chain these questions through a hierarchy of parent-child relationships.

Go Even Deeper

This explanation assumes you understand these fundamentals. Click to learn more:

matrix multiplication

Level 1 fundamental

trigonometry basics

Level 1 fundamental