Game dev
Saved & recent

Homogeneous coordinates

Related terms: w component, 4D vector, perspective divide

3D positions are stored with a fourth number, w. That extra slot is what lets a single 4x4 matrix move things as well as rotate and scale them.

A w of 1 marks a position. A w of 0 marks a direction, which moving must not change. After projection, w holds the depth. Dividing x, y and z by it is the perspective divide, the step that makes far things small.

Further reading
LearnOpenGL: Transformations: homogeneous coordinates
X Y position, w = 1 X Y direction, w = 0 same translation perspective divide 0 w = 4 x/w = 0.25 w = 2 x/w = 0.5
The translation contributes w times its offset. It moves the point (w = 1) and leaves the direction (w = 0) unchanged. Below, a clip-space x of 1 lands closer to zero when divided by a larger w.

View in the full Game dev collection