Next / Previous / Contents / Shipman's homepage

1. Homogeneous coordinates make life so much easier

Much of graphics programming revolves around coordinate transformations. Objects in the modeled scene are specified by coordinates in scene space. In order to display these objects, we must transform their coordinates into display space.

The contribution of this document is an implementation of this method using the Python language, and the extremely useful NumPy extensions to Python that make vector and matrix operations easy.

The author has found this reference to be extremely valuable in graphics work:

Foley, James D., Andries van Dam, Steven K. Feiner, and John F. Hughes. Computer graphics: principles and practice. Second edition. Addison-Wesley, 1990, ISBN 0-201-12110-7.

In the chapter on geometrical transformations, the authors bring up homogeneous coordinates early on. This ingenous mathematical artifice makes it possible to specify any coordinate transformation using a small matrix: 3×3 for 2-space, 4×4 for 3-space. Points are carried as 3-element vectors for 2-space, or 4-element vectors for 3-space, and a trivial operation converts these vectors back to (x,y) or (x,y,z) form.

Moreover, you can combine these transform matrices to model the effect of multiple transforms. For example, suppose you have a model of some small rigid object like a cup, positioned in a larger scene. The coordinates of the cup are described in some standard orientation; when the cup is placed into the scene, a single transform matrix describes the transformation of those coordinates into coordinates relative to the scene. The net transformation of the cup to display coordinates can be represented as a matrix which happens to be the product of the two transform matrices: the transform that describes the cup's placement in the scene, and the transform that desribes how scene coordinates become display coordinates.

Transform matrices are easily reversible. For example, suppose the user clicks on the display, and you want to know where that click is in scene space. To convert a display coordinate to a scene coordinate requires a single matrix multiplication.

This document is structured in three general parts.