Computer Graphics · 2D Transformations and Viewing
Basic 2D Transformations and Matrices
Overview
A 2D transformation is a rule that maps every point of a planar object to a new point , and a matrix is the compact way of storing that rule so that many transformations can be multiplied into a single operation.
This lesson sits at the head of the "2D Transformations and Viewing" area of the syllabus: window-to-viewport mapping, clipping, animation and 3D viewing all reuse exactly these matrices.
Before starting you must be comfortable with 2×2 and 3×3 matrix multiplication, with coordinate geometry of the plane, and with the trigonometric values of .
Convention used throughout these notes (the standard one in graphics texts and in the exam): points are column vectors, a positive angle means counterclockwise rotation, and the composite matrix acts as .
Key concepts
- Geometric transformation: a mapping applied to every vertex of an object; the object is redrawn from the transformed vertices.
- Linear transformation: representable by a matrix, i.e. the origin always stays fixed. Rotation, scaling, reflection and shear are linear.
- Affine transformation: a linear transformation followed by a translation; written as a homogeneous matrix whose last row is . It keeps straight lines straight and preserves parallelism.
- Homogeneous coordinates: an ordinary point is written as . In general the triple with means the point , and represents a point at infinity (a direction).
This extra coordinate is needed because translation is not linear and cannot be written with a matrix. - Translation: moves by ; . Two parameters, no fixed point, determinant , orientation and size unchanged.
- Rotation: turns the object by about the origin. One parameter, the only fixed point is the origin, lengths and angles preserved, determinant .
- Scaling: multiplies distances from the origin; . If it is uniform (isotropic) scaling and shape is preserved; otherwise it is non-uniform (differential) scaling and shape is distorted.
Determinant , so the area is multiplied by . Negative factors combine scaling with a flip. - Reflection (mirror): flips the object about a line. Determinant , so orientation is reversed. Standard mirrors: about the x-axis, the y-axis, the line , the line , and about the origin (a half-turn).
- Shear (skewing): shifts one coordinate in proportion to the other; -shear uses , -shear uses . Determinant , so area is preserved, but angles and lengths are not.
- Composite transformation: two or more transformations applied in sequence. With column vectors the matrix of the composite is the product, and the transformation applied last is written leftmost: .
- Rigid-body transformation: translation plus rotation only (shape and size preserved).
- Projective transformation / homography: a general (in 3D, ) homogeneous matrix whose last row is not .
The result must be divided by the new ; straight lines stay straight but parallelism is not preserved — this is how perspective is produced. - Orthogonal matrix: a matrix with . It has determinant (a rotation) or (a reflection, possibly combined with a rotation).
Standard homogeneous matrices (column-vector convention, ):
| Transformation | homogeneous matrix |
|---|---|
| Translation by | |
| Rotation counterclockwise | |
| Rotation clockwise | |
| Scaling about origin | |
| Reflection about x-axis | |
| Reflection about y-axis | |
| Reflection about | |
| Reflection about | |
| Reflection about origin | |
| -shear (shear along x) | |
| -shear (shear along y) |
How it works
-
Why homogeneous coordinates. Translation is , which is not a linear function of — the origin moves.
Append a third coordinate fixed at ; then the constant can sit in the third column and a single multiplication does the job. -
Building the rotation matrix. The columns of a linear matrix are the images of the unit vectors: and . Putting these as the two columns gives in the table above.
Swapping the signs of the terms gives the clockwise matrix. -
Composition order. If and , then . So the first operation is applied first but appears nearest the point, and the last operation appears leftmost.
Matrix multiplication is associative (the whole chain can be pre-multiplied into one matrix) but not commutative, so order changes the result. -
Rotation about an arbitrary pivot . a. Translate so that goes to the origin: . b. Rotate by about the origin: . c. Translate back: . The combined matrix is .
-
Scaling about a fixed point follows exactly the same recipe: .
-
Shear about a reference line. To shear in the y-direction keeping the line fixed, replace by , shear, then add it back: . Similarly an x-shear about gives .
-
Reading a given matrix. For the point maps to . The third column is the translation part and the upper-left block is the linear part (scale, rotation, shear or reflection).
If the translation column equals the translation was applied last; if it equals the translation was applied first and then scaled. -
Determining an unknown matrix from correspondences. Put and , substitute three non-collinear point pairs, solve the two independent systems, then verify on the fourth pair.
-
Inverse and coordinate transformations. The inverse matrix undoes a transformation (, , , and ).
Moving the coordinate system is the inverse of moving the object: if the new coordinate values are obtained by multiplying the old ones by , substitute into the old equation to get the equation in the new frame.
Drawing the diagram…
Formulas
- Translation:
- Rotation counterclockwise about origin:
- Scaling about origin:
- -shear: ; -shear:
- Shears about reference lines: ;
- Rotation about pivot :
- Composite rotation about a pivot:
- Composite scaling about a fixed point:
- Area change: new area old area; in general the factor is
- Homogeneous division: for ; gives a point at infinity
Worked examples
Example 1 (easy, composite order). Rotate by counterclockwise about the origin, then translate by .
- rotation: , , giving .
- translation: .
Composite matrix (translation applied last, so it is leftmost): , and indeed maps to . Answer: .
Example 2 (medium, scaling about a fixed point). Scale the point by about the fixed point .
- shift the fixed point to the origin: .
- scale: .
- shift back: .
Direct check with the closed form: , . Answer: .
Example 3 (hard, rotation about an arbitrary point). Rotate the triangle , , by counterclockwise about . Use .
: rotated , so .
: rotated , so .
: rotated , so .
Answer: , , .
Example 4 (medium, matrix from correspondences). Find the homogeneous matrix that maps the unit square onto the parallelogram .
Write , . From we get . From : . From : . Check the fourth vertex: ✔.
Answer: .
Example 5 (statement type). Statement I: A matrix with determinant squeezes the whole plane onto a line or a single point. Statement II: Every orthogonal matrix represents a rotation.
Statement I is true — a singular matrix has linearly dependent columns, so all image points lie on one line through the origin (or on the origin itself). Statement II is false — orthogonality gives determinant or ; determinant gives a reflection. Answer: I true, II false.
Comparison
| Transformation | Parameters | Fixed elements | Determinant | Preserves |
|---|---|---|---|---|
| Translation | none | shape, size, orientation, angles | ||
| Rotation | the pivot | shape, size, angles, orientation | ||
| Uniform scaling | the fixed point | shape, angles, orientation | ||
| Non-uniform scaling | the fixed point | parallelism only | ||
| Reflection | mirror line | every point of the line | shape, size, angles; reverses orientation | |
| Shear | or | points on the reference line | area, parallelism |
| Class | Matrix form | Preserves |
|---|---|---|
| Linear | any | origin fixed, lines and parallelism |
| Affine | with last row | lines, parallelism, ratios along a line |
| Projective (homography) | general | straight lines only; needs division by |
| Orthogonal matrix, | Orthogonal matrix, |
|---|---|
| Rotation about the origin | Reflection about a line through the origin |
| Object transformation | Coordinate transformation |
|---|---|
| Moves the object, keeps the frame | Moves the frame, keeps the object |
| Uses on the coordinates | Uses on the coordinates |
| Point goes to | Same point has new coordinates |
Revision summary
- Translation is the only primitive that a matrix cannot express — that is the entire reason for homogeneous coordinates.
- Counterclockwise is positive; ; clockwise flips the signs of the two terms.
- The operation applied last is the leftmost matrix in a product.
- Rotation or scaling about a pivot: .
- means rotation; means reflection; means the object is flattened.
- is the area magnification factor.
- Shear changes angles but not area ().
- Inverse of a composite: reverse the order and invert each factor.
- Uniform scaling keeps an object similar; non-uniform scaling does not.
- In , divide by ; is a point at infinity.
- A affine matrix always has the last row ; a rotation about the z-axis keeps the row and column of the identity.
- values are ; a counterclockwise rotation sends to .
Previous-year exam insights
- Direct concept questions are common: "which transformation resizes an object" → scaling; "which changes only position" → translation; "which needs homogeneous coordinates" → translation.
- Matrix-identification questions give a or matrix and ask for the operation or the axis.
Check the diagonal, the off-diagonal pair, the translation column and the last row first.
A matrix whose upper-left block is a rotation block with in the third diagonal position and elsewhere rotates about the z-axis. - Order-of-application questions ("translated by … and rotated by …") are the biggest trap.
Compute one point under both orders, or read which order produces the given translation column, before choosing. - Matrix-decomposition questions give a matrix such as and ask which sequence it represents.
Remember: translation first gives a translation column equal to the scaled translation; translation last gives it unchanged. - Rotation about a non-origin point requires the translate–rotate–translate recipe; wrong options swap the coordinates or use the wrong sign for , so verify one vertex completely.
- Statement I/II questions test determinant-based classification (rotation vs reflection, singular vs invertible) and the fact that a sequence of reflections can equal a rotation.
- Matrix-from-correspondence questions are solved by writing the six linear equations and checking the unused vertex.
- Homogeneous-coordinate questions test (point at infinity) and the general product, which is a projective transformation (homography).
Practice at PARIKSHA
You are ready for the PARIKSHA tests of this sub-topic when you can:
- State why translation cannot be written as a matrix and write its homogeneous form from memory.
- Write the counterclockwise and clockwise rotation matrices and use them on a point without sign errors.
- Decide in one glance whether a given matrix is translation, scaling, rotation, reflection or shear.
- Rotate and scale a point about an arbitrary pivot in three steps and quote the composite matrix.
- Expand a given homogeneous matrix into "first … then …" and justify the order.
- Build the matrix that maps three given points onto three given image points.
- Classify any matrix as rotation, reflection or singular using its determinant and orthogonality.
- State the area factor of any linear transformation and explain uniform versus non-uniform scaling.
- Write the shear formula relative to a reference line in both directions.
- Explain the meaning of and of dividing by in homogeneous coordinates.
Attempt the sub-topic test on 2D transformations first; once you score comfortably, move to the full subject test.