FREE LESSON · Graphics & simulation · 1 OF 5

Coordinate systems and affine transformations

Coordinate systems and affine transformations: Track points through scale, rotation, and translation in the correct order.

Prerequisites: Vectors and matrix multiplication.

Learning objectives

  • Distinguish points from direction vectors.
  • Compose affine transformations.
  • Explain why transformation order matters.

Coordinates depend on a frame

A point's coordinates describe its position relative to a chosen origin and basis. The same physical point can have different coordinates in object, world, camera, and screen frames. A graphics pipeline transforms between these frames. Label them explicitly; many bugs are valid matrix operations applied to quantities expressed in incompatible frames.

In two dimensions, a linear transformation is represented by a 2×2 matrix. It can scale, rotate, shear, or reflect, but it leaves the origin fixed. Translation is affine rather than linear. Homogeneous coordinates represent a point (x,y) as (x,y,1), allowing translation and linear operations to be combined in a 3×3 matrix.

A direction vector uses homogeneous coordinate zero, so translation does not affect it. This distinction reflects geometry: moving the origin changes a point's location coordinates but does not change the difference between two points in the same translated frame.

Work the composition

Use column vectors. Let S scale x and y by two, and let T translate by (3,1). For point p=(1,2), applying S then T gives (2,4)+(3,1)=(5,5). The combined matrix is TS because the rightmost operation acts first. Applying T then S gives 2×(4,3)=(8,6). The results differ, so these operations do not commute.

A counterclockwise rotation by angle θ has matrix rows (cosθ,-sinθ) and (sinθ,cosθ). At 90 degrees, (1,0) maps to (0,1). This assumes a Cartesian coordinate system with y upward. A screen system with y downward changes the visual interpretation, so conventions must be documented.

Inverses and normals require care

An invertible transform can map a world-space point back into object space. A zero scale collapses a dimension and is not invertible. Checking dimensions and invertibility is more useful than blindly applying an inverse routine.

Surface normals transform differently from ordinary direction vectors under nonuniform scaling: preserving perpendicularity requires the inverse transpose of the linear part, followed by normalization where appropriate. A uniform rotation hides this distinction because its inverse transpose equals the rotation itself.

Test transformations with simple points whose expected positions are obvious: the origin, basis directions, and a known corner. Include round-trip tests for invertible transforms and an explicit singular case. A visually plausible image is weaker evidence than a small set of verified geometric invariants.

Practice problem

Using column vectors, transform point (2,1) by a 90-degree counterclockwise rotation and then translation (4,0). Reverse the order and compare. Explain what translation does to direction vector (2,1).

Worked solution

Rotation maps (2,1) to (-1,2); translation then gives (3,2). Reversing the order first gives (6,1), then rotation gives (-1,6). The operations do not commute. A direction vector has homogeneous coordinate zero, so translation leaves it unchanged; only the rotation changes it to (-1,2). State the upward-y coordinate convention and the column-vector convention so the calculation can be reproduced. With a downward-y screen convention, the visible direction of rotation must be interpreted accordingly.

Check your understanding

With column vectors, applying A then B produces which composite?

  • AB.
  • A+B.
  • BA.
  • A inverse.
Explanation

The rightmost matrix acts on the input first.

Why does a direction use homogeneous coordinate zero?

  • Directions have no magnitude.
  • Translation should not change a displacement.
  • It prevents rotation.
  • It makes all transforms invertible.
Explanation

A displacement is independent of the choice of translated origin.

Primary reading

Open the study and save your work →