Skip to main content
Homogeneous coordinates extend ordinary Euclidean geometry into projective space, making it possible to represent points, lines, and planes with simple vectors and to express all geometric transformations — including perspective projection — as matrix multiplications.

Points and lines in 2D

A 2D Euclidean point (x,y)(x, y) is embedded in projective space as a 3-vector: m=(xy1)or more generallym=(wxwyw),w0\mathbf{m} = \begin{pmatrix} x \\ y \\ 1 \end{pmatrix} \quad \text{or more generally} \quad \mathbf{m} = \begin{pmatrix} wx \\ wy \\ w \end{pmatrix}, \quad w \neq 0 The scale factor ww is arbitrary — the vectors (wx,wy,w)(wx,\, wy,\, w) and (x,y,1)(x,\, y,\, 1) represent the same point. When w=0w = 0 the vector represents a point at infinity (ideal point) along the direction (x,y)(x, y). A 2D line ax+by+c=0ax + by + c = 0 is likewise a 3-vector: =(abc)\boldsymbol{\ell} = \begin{pmatrix} a \\ b \\ c \end{pmatrix}

Key operations

Point on a line — point m\mathbf{m} lies on line \boldsymbol{\ell} if and only if: m=ax+by+c=0\boldsymbol{\ell}^\top \mathbf{m} = ax + by + c = 0 Intersection of two lines — the intersection point of 1\boldsymbol{\ell}_1 and 2\boldsymbol{\ell}_2 is: m=1×2\mathbf{m} = \boldsymbol{\ell}_1 \times \boldsymbol{\ell}_2 Line through two points — the line joining m1\mathbf{m}_1 and m2\mathbf{m}_2 is: =m1×m2\boldsymbol{\ell} = \mathbf{m}_1 \times \mathbf{m}_2 where ×\times denotes the cross product. This elegant duality means point–line incidence is handled by a single cross product in either direction.

Duality of points and lines

In projective 2D space there is a perfect duality between points and lines: any theorem about points and lines remains valid when the two notions are swapped. Both are represented by 3-vectors; the roles of “join” and “intersection” exchange.
OperationFormula
Line through m1\mathbf{m}_1, m2\mathbf{m}_2=m1×m2\boldsymbol{\ell} = \mathbf{m}_1 \times \mathbf{m}_2
Intersection of 1\boldsymbol{\ell}_1, 2\boldsymbol{\ell}_2m=1×2\mathbf{m} = \boldsymbol{\ell}_1 \times \boldsymbol{\ell}_2
Point on line testm=0\boldsymbol{\ell}^\top \mathbf{m} = 0
Parallel lines meet at1×2\boldsymbol{\ell}_1 \times \boldsymbol{\ell}_2 (point at infinity)

Extension to 3D

In 3D projective space a point M=(X,Y,Z)\mathbf{M} = (X, Y, Z) becomes a 4-vector: M=(XYZ1)\mathbf{M} = \begin{pmatrix} X \\ Y \\ Z \\ 1 \end{pmatrix} A plane aX+bY+cZ+d=0aX + bY + cZ + d = 0 is also a 4-vector π=(a,b,c,d)\boldsymbol{\pi} = (a, b, c, d)^\top, and the incidence condition is: πM=0\boldsymbol{\pi}^\top \mathbf{M} = 0 Intersection of three planes is the 3D analogue of intersecting two lines — solved as a 3×43 \times 4 linear system or via cross product of the plane normals.
A line in 3D is not simply a 4-vector; it requires either two points, two planes (their intersection), or the Plücker representation (a 4×44\times 4 skew-symmetric matrix).

MATLAB example — points and lines

The following snippet illustrates the basic operations with homogeneous coordinates in MATLAB:
% Define two 2D points in homogeneous coordinates
m1 = [1; 2; 1];   % point (1, 2)
m2 = [4; 0; 1];   % point (4, 0)

% Line through the two points
ell = cross(m1, m2);
fprintf('Line: %dx + %dy + %d = 0\n', ell(1), ell(2), ell(3));

% Check incidence
fprintf('m1 on line: %d\n', abs(dot(ell, m1)) < 1e-9);
fprintf('m2 on line: %d\n', abs(dot(ell, m2)) < 1e-9);

% Define a second line and find intersection
ell2 = [1; 1; -3];   % x + y = 3
m_int = cross(ell, ell2);
m_int = m_int / m_int(3);  % normalise
fprintf('Intersection: (%.2f, %.2f)\n', m_int(1), m_int(2));

Python examples

Points and lines (Colab)

Interactive notebook covering homogeneous point and line operations in Python.

E01 — Where does John Lennon look?

Practical exercise: use line intersections to determine gaze direction from a photograph.

Video lecture

Lecture: Homogeneous coordinates, lines, and points (2021)

Recorded class covering the full theory of homogeneous coordinates in 2D and 3D.

Summary

Homogeneous coordinates unify all geometric operations — including perspective projection, which maps 3D points to 2D image points — into simple matrix multiplications. Points at infinity are handled naturally, eliminating the need for special cases in intersection and transformation algorithms.
Divide all components by the last coordinate: (wx,wy,w)(x,y)(wx, wy, w) \mapsto (x, y). If the last coordinate is zero the point is at infinity and has no Euclidean representation.
Both the line through two points and the intersection of two lines use the cross product of the two 3-vectors. This works because the cross product a×b\mathbf{a} \times \mathbf{b} produces a vector orthogonal to both, and orthogonality in projective space encodes incidence (m=0\boldsymbol{\ell}^\top \mathbf{m} = 0).