Single Transform

When drawing graphics in terms of vectors, one often needs to transform shapes by scaling, rotation, translation and so forth. If every function that draws shapes implements the transformations it needs, much complexity is introduced to the code.

How can we reduce the amount of code implementing geometric transforms?

All affine transformations can be described mathematically using matrices. Multiplying a vector by a transformation matrix applies that transformation to the vector. Multiplying two transformation matrices concatenates the transformations.

Therefore:

Maintain a single transformation matrix within each graphics context that is applied to shapes drawn by the operations of the display manager.

All code that performs drawing operations can easily transform or scale the drawn shapes by changing the transform matrix.

Transformations can be combined. This is the basis for SceneGraphs.

However, all drawing operations are transformed by the single transform matrix, even if the matrix does not specify a transformation (i.e. is the identity matrix). This common case can be treated specially: the transformation matrix can be ignored when it is the identity matrix.

Known uses include the Win32 API, OpenGL, the Java 2D API, and many other "immediate mode" graphics APIs.


Also see GraphicsPatterns.

CategoryGraphicsPattern CategoryPattern MatrixAnalysis


EditText of this page (last edited August 19, 2014) or FindPage with title or text search