Mathwords logoMathwords

3D Projection — Definition, Formula & Example

3D projection is a way of turning points in three-dimensional space into points on a flat image, much as a camera flattens a scene onto film. A single matrix does the work. In perspective projection, objects farther from the viewer come out smaller.

In homogeneous coordinates, a 3D projection is represented by a 3×43 \times 4 matrix PP of rank 3, defined up to a nonzero scalar multiple. A point (x,y,z)(x, y, z) is written as (x,y,z,1)(x, y, z, 1) and multiplied by PP to give (x′,y′,w′)(x', y', w'). It is then sent to the image point (x′/w′, y′/w′)(x'/w',\, y'/w') whenever w′≠0w' \neq 0. The null space of PP is one-dimensional and corresponds to the center of projection. If that center is a finite point, every projection line passes through it, and the projection is central (perspective). If the center is a point at infinity, the projection lines are all parallel, and the projection is a parallel projection.

Key Formula

(x′y′w′)=(d0000d000010)(xyz1),(u,v)=(x′w′,y′w′)=(d xz,d yz)\begin{pmatrix} x' \\ y' \\ w' \end{pmatrix} = \begin{pmatrix} d & 0 & 0 & 0 \\ 0 & d & 0 & 0 \\ 0 & 0 & 1 & 0 \end{pmatrix} \begin{pmatrix} x \\ y \\ z \\ 1 \end{pmatrix}, \qquad (u, v) = \left(\frac{x'}{w'}, \frac{y'}{w'}\right) = \left(\frac{d\,x}{z}, \frac{d\,y}{z}\right)
Where:
  • x,y,zx, y, z = Coordinates of the point, measured from the center of projection at the origin. The viewer looks along the positive z-axis, so z > 0 is the depth.
  • dd = Distance from the center of projection to the image plane z = d
  • x′,y′,w′x', y', w' = Homogeneous image coordinates produced by the matrix product
  • u,vu, v = Actual coordinates of the projected point on the image plane, found after dividing by w'

Worked Example

Problem: A pinhole camera sits at the origin and looks along the positive z-axis. Its image plane is z = 2 inches away. Project the points A = (6, 3, 12) and B = (6, 3, 24), measured in inches. B is directly behind A and twice as deep.
Step 1: Write A in homogeneous coordinates and multiply by the perspective matrix with d = 2.
(200002000010)(63121)=(12612)\begin{pmatrix} 2 & 0 & 0 & 0 \\ 0 & 2 & 0 & 0 \\ 0 & 0 & 1 & 0 \end{pmatrix} \begin{pmatrix} 6 \\ 3 \\ 12 \\ 1 \end{pmatrix} = \begin{pmatrix} 12 \\ 6 \\ 12 \end{pmatrix}
Step 2: Divide by the last entry, w' = 12, to get A's image point.
(u,v)=(1212,612)=(1,12)(u, v) = \left(\frac{12}{12}, \frac{6}{12}\right) = \left(1, \tfrac{1}{2}\right)
Step 3: Repeat for B. The matrix gives (12, 6, 24), and this time w' = 24.
(u,v)=(1224,624)=(12,14)(u, v) = \left(\frac{12}{24}, \frac{6}{24}\right) = \left(\tfrac{1}{2}, \tfrac{1}{4}\right)
Answer: A projects to (1, 1/2) and B projects to (1/2, 1/4), both in inches on the image plane. B has the same x and y as A but twice the depth. Its image therefore lies along the same ray from the image center, at exactly half A's distance from it. An orthographic projection along the z-axis would send both points to the same spot.

Why It Matters

Every 3D video game and rendering engine, including those built on OpenGL, Vulkan, or Direct3D, applies a 4 × 4 version of this matrix to each vertex and then performs the perspective divide on the GPU. In computer vision courses, the same 3 × 4 camera matrix appears in camera calibration and 3D reconstruction from photos.

Common Mistakes

Mistake: Treating the matrix product (x', y', w') as the final image point.
Correction: The product is only a set of homogeneous coordinates. You must divide x' and y' by w' to get the point on the image plane. This division by depth is the step that makes distant objects shrink. In the example, skipping it would place A at (12, 6) instead of (1, 1/2).

Related Terms