Motivation
A triangle is not intrinsically a list of three screen positions. A modeler may specify its vertices relative to an object, a scene places that object in a world, and a camera describes the world relative to an observer. Only then do projection and a viewport produce image coordinates. Separating these stages lets one mesh appear at several positions and lets a camera move without rewriting every object. More importantly, the separation tells us what each number means. Multiplying two arrays of compatible dimensions is not enough: their coordinate systems must also agree.
Throughout this note, vectors are columns, transformations act on the left, and three-dimensional coordinates use a right-handed orthonormal frame. The camera looks along its negative third axis. These are conventions, not universal facts about graphics APIs. A different convention can represent the same scene, provided every stage is changed consistently. We use exact real arithmetic for derivations; floating-point precision and clipping introduce additional implementation questions.
The key conceptual division is between changing an object and changing its description. Moving a point three units to the right changes the scene. Measuring the same point from a camera three units to the right changes the point's coordinates in the opposite direction. Both operations involve matrices, but confusing their meanings produces cameras that appear to move backwards.
Definitions
Definition 1.1.1
(Points, directions, and affine maps)
A point is a location in affine space; a direction is a displacement between points. In chosen coordinates an affine transformation has the form , with a matrix and translation . Its action on a displacement is , because translation cancels in the difference of two transformed points. The map is invertible exactly when is invertible.
Homogeneous coordinates package an affine map as
The fourth coordinate records the distinction between a point and a direction. General homogeneous point coordinates with nonzero represent ; multiplying all four entries by the same nonzero scalar does not change that point. A representative with zero fourth coordinate is not an ordinary finite position. Do not divide by zero or silently reinterpret it as one.
Definition 1.1.2
(Camera frame and perspective image)
Let a camera center be , with orthonormal world-space axes for right, up, and backward. A point has camera coordinates . For a point in front of the camera, put . A pinhole image on the virtual plane , with , has coordinates .
The camera frame is a basis, so the view transformation is an inverse placement. If has columns , then and . Orthonormality justifies replacing by . If the stored frame is not orthonormal, taking a transpose is generally wrong. The focal length and field of view are related by , where is the image-plane height; the relation follows from the right triangle through the top edge.
Theorem / proposition
Theorem 1.1.3
(Affine combinations survive affine transformations)
If real weights satisfy , then for every affine map ,
In particular, an affine map preserves line interpolation, and it maps a triangle to the triangle spanned by the transformed vertices, possibly degenerately.
The sum condition matters. An arbitrary weighted sum of point coordinates need not describe an operation independent of the coordinate origin. Nonnegative weights additionally identify the convex hull. An invertible affine map preserves nondegeneracy and parallel lines; a singular map can flatten a triangle to a segment or point.
Counterexample mode
Weights that do not sum to one
A tempting extension is that for arbitrary weights. Take with , and , whose sum is . Then , but . In general the two sides differ by , which vanishes only when the weights sum to one or the translation is zero.
Theorem 1.1.4
(Normals use the inverse transpose)
Let an invertible matrix transform tangent directions by . If a nonzero satisfies for every tangent direction of a plane, then is perpendicular to every transformed tangent direction. A unit normal is therefore obtained by normalizing , with orientation handled consistently.
This theorem concerns an affine map's linear part, before perspective projection. Applying it to a singular scaling is invalid because the inverse does not exist. Also, a reflected surface may need an orientation correction if its normal is defined by the transformed vertex winding: . Orthogonality alone does not choose the outward side.
Concept lensAlgebraic
A normal as a linear functional
Take a plane through the origin with tangent space . The normal enters only through the functional , whose kernel is . After the change , the tangent space becomes , and the functional with kernel is , that is, . Directions (columns) transform by , while functionals (rows) are multiplied on the right by , which for the column vector is . A nonzero rescaling of does not change the kernel, so normalizing afterwards is harmless.
The explorer below applies stretch, shear, reflection and flattening maps to a plane and compares the shortcut with the inverse-transpose normal using exact tangent dot products.
Proof sketch or proof idea
Proof
(Distributing the affine map over the weights)
Distribute over the weighted sum. The right-hand side becomes , which equals the left-hand side precisely because the weights sum to one. This small algebraic fact underlies matrix-based modeling and the interpolation of attributes before projection.
Proof
(The dot product after the change of coordinates)
Let be any tangent direction of the plane, so ; the transformed tangent directions are exactly the vectors . Then
Since was arbitrary, is perpendicular to every transformed tangent direction. Normalizing afterwards restores length one, but does not change which directions give zero.
Proof X-ray
Why a normal is not just another direction
The hypothesis supplies a vanishing pairing between a normal and every tangent. The conclusion must preserve that pairing after the tangent changes by . Choosing makes the two transformations cancel inside the dot product. Choosing instead gives , which need not vanish. Uniform scaling and rotations can hide this mistake because their is a scalar multiple of the identity; nonuniform scaling exposes it.
Perspective follows from similar triangles, rather than from the affine-combination theorem. The ray from the origin through is . It meets the virtual plane at , giving the image coordinates above. Because the divisor depends on the point, this projection is not an affine map on three-dimensional points. A point behind the camera lies on a different ray half-line and must not be accepted simply because division produces finite numbers.
Worked examples
Worked example 1.1.5
(Transformation order changes the object)
In two dimensions embedded in three, let and . For , , whereas . Under our column convention, the first composition is : the rightmost matrix acts first. A hierarchy with child transform and parent transform therefore uses . The child's translation is itself expressed in the parent's frame.
Worked example 1.1.6
(Building and checking a view transformation)
Place the camera at with world-aligned axes. Then and . The world origin becomes , correctly in front of a camera looking along negative . Moving the camera to makes the same origin in camera coordinates. As a check, the camera center always maps to zero and the world point maps to . Such semantic checks catch many transpose and sign errors faster than inspecting a full matrix product.
Worked example 1.1.7
(Projection and a corrected surface normal)
With , the points and both project to because they lie on the same camera ray. Depth is lost from the two image coordinates, so visibility needs an additional depth value. Separately, let a surface tangent be and normal . Under the tangent becomes . The wrongly transformed normal has dot product with it. The correct unnormalized normal has dot product zero; its unit version is .
A projection matrix with an explicit depth convention
For a symmetric viewing frustum, let be width divided by height, , and choose near and far distances . A common clip-coordinate matrix is
For camera coordinates it produces . Dividing by gives normalized image coordinates and
At this equals , and at it equals . The formula states our depth convention explicitly; APIs and configurations can use different intervals. A viewport may map this depth to and image coordinates to pixels. It is essential to distinguish camera depth , clip depth , and divided depth .
Clipping is naturally done before division, using the homogeneous inequalities for this frustum. For a segment , each clip-plane inequality is linear in , so its valid parameters form an interval. Intersecting these intervals clips the segment. Cutting only after division can mishandle a segment passing across the camera plane, where the denominator vanishes.
A practical camera construction starts from a center , target , and an approximate up vector not parallel to . Set , , and . The nonparallel hypothesis prevents division by zero. Recomputing makes the basis orthonormal even when the approximate up vector was not perpendicular to the viewing direction. At a camera orientation where the proposed up becomes parallel to the view, one must choose another reference; numerical noise is not a principled replacement for a missing basis vector.
The viewport is a further coordinate change, rather than part of the camera model. For an image rectangle of width and height , one possible continuous mapping is and . A separate choice locates pixel centers, for example at half-integer coordinates. If row indices increase downward, the vertical mapping is reversed. Explicitly documenting these choices prevents a mathematically correct projection from acquiring an unexplained half-pixel shift or vertical reflection.
Common mistakes
Counterexample mode
A screen midpoint need not be the projected spatial midpoint
Take camera-space endpoints and with . Their image coordinates are and , so their screen midpoint is . Their spatial midpoint is and projects to . Perspective preserves a visible straight segment's supporting line, but generally changes its parameterization. Linear screen-space interpolation of a surface attribute therefore needs a perspective correction, derived in the next note.
Common mistake
(Translating a direction as if it were a point)
Light directions, velocities and surface tangents must not be translated. Subtracting two transformed points proves that translations cancel for displacements. Conversely, writing a position with fourth coordinate zero loses its translation altogether. Positions carry and directions carry .
For an orthographic camera, dropping depth is a linear projection. Parallel scene lines project to parallel or coincident image lines when neither collapses to a point; a line along the viewing direction does collapse. Perspective may instead send parallel scene lines toward a common vanishing point. Neither image recovers a unique three-dimensional scene without additional information.
Common mistake
(Transposing a matrix because of its storage order)
Matrix storage order and multiplication convention are different issues. Column-major storage describes memory layout; column-vector multiplication describes algebra. Transposing an array merely because an API documentation mentions storage order can introduce an error. Write down one point and its expected image, then check the documented data layout against that calculation.
Summary
An affine model matrix changes points by a linear part plus translation. A view matrix expresses the world in a camera basis and is the inverse camera placement. Normals transform by the inverse transpose of the invertible linear part. Perspective then divides by depth, requiring clipping and a clear depth convention. These stages explain why one matrix chain can serve a scene while still requiring different treatment for points, directions, and normals.
Exercises
Quick check
(Let with invertible . Derive its inverse affine transformation, and check both compositions on a point.)
Solve for .
Solution · Answer
Solve : . Substituting cancels the translations and gives ; substituting this expression into gives . The inverse homogeneous matrix therefore has blocks .
Quick check
(A triangle has vertices . Apply and to its barycentric point with weights . Verify the result using transformed vertices.)
Compute the point first, then transform each vertex.
Solution · Answer
The point is , whose image is . The image vertices are . Their weighted sum has first coordinate , second , and third . The weights still sum to one.
Quick check
(A plane has normal and is transformed by . Find a unit normal to the image plane and test it against the image of tangent .)
Use the inverse transpose.
Solution · Answer
The inverse transpose sends the normal to , with norm . A unit choice is . The image tangent is , whose dot product with this vector is . This verifies the perpendicularity required by the theorem.
Quick check
(In the displayed projection convention choose . Find the normalized depths at distances , and determine whether equal increments in camera distance produce equal depth increments.)
Use .
Solution · Answer
Here . The values are . They are not proportional to distance: increasing distance from to changes depth by , while increasing from to changes it by only . The derivative explains why this convention allocates more depth resolution near the camera.