Homogeneous coordinates

This line, which copies a three dimensional coordinate into a four dimensional variable requires some explanation.

    gl_Position = vec4(position, 1);

Graphics cards are very good at multiplying matrices and vectors. We can already represent a three dimensional rotation as a matrix.

Homogeneous coordinates introduce a fourth coordinate, w. With homogeneous coordinates we can represent translations as matricies as well. Here we translate x by Δx, y by Δy, and z by Δz.

Notes

A rotational transformation is represented in homogeneous coordinates by embedding the rotational matrix in the upper left of a homogeneous transformation matrix.

Different transformations are combined by multiplying their corresponding matrices.

Graphics hardware and software is highly tuned to multiply matrices as efficiently as possible.

We will see later that homogeneous coordinates are also intimately tied to perspective.