Remembering separate translation, scaling and rotation matrices is not enough when the pivot changes, several operations are composed, or a window must be mapped to a viewport. One wrong multiplication order can change every coordinate. Use a single column-vector convention to keep the calculations consistent across the two complete transformation examples, the viewport calculation, and the exam-solving routine.
2-D transformations: points, matrices and homogeneous coordinates
A transformation maps an input point or object to a new set of coordinates. Use these conventions:
Points are column vectors.
A positive angle means anticlockwise rotation.
Transformation matrices multiply a point from the left.
A Cartesian point is written as
p = [x y 1]^T.
A 2 x 2 matrix can rotate, scale, reflect or shear a point because each output coordinate is a linear combination of x and y. It cannot translate every point by a fixed amount. In particular, every 2 x 2 linear transformation must keep the origin at the origin.
Adding a homogeneous coordinate gives a 3 x 3 affine matrix, so translation joins the same matrix multiplication. A point has w = 1, which allows the translation terms to affect it. A direction has w = 0, so moving an object does not change that direction.
Treat each transformation as a function: composition feeds one output into the next, while an inverse reverses the mapping. Set Theory and Relations for GATE: Closures and Posets provides a concise refresher on mappings and composition.
Translation, scaling, rotation, reflection and shear matrices
With the column-vector convention above, the main 2-D primitives are:
Operation | Homogeneous matrix | Result for | Geometric effect |
|---|---|---|---|
Translation by |
|
| Preserves lengths and angles |
Scaling by |
|
| Uniform scaling preserves shape; non-uniform scaling changes aspect ratio |
Rotation by |
|
| Preserves lengths and angles |
Reflection in the x-axis |
| Gives | Reverses orientation across the x-axis |
x-shear by |
|
| Changes angles |
The shear result follows directly from x' = x + shx(y) = 2 + 2(1) = 4, while y' = y = 1.
Composite transformations: scale, rotate and translate a triangle
Take triangle A(1,1), B(3,1), C(2,2). First scale it by S(2,1) about the origin, then rotate it 90 degrees anticlockwise, then translate it by (4,-1).
The matrices are:
S = [[2,0,0],[0,1,0],[0,0,1]]
R = [[0,-1,0],[1,0,0],[0,0,1]]
T = [[1,0,4],[0,1,-1],[0,0,1]]With column vectors, the combined matrix is written in reverse application order:
M = T R S
R S = [[0,-1,0],[2,0,0],[0,0,1]]
M = [[0,-1,4],[2,0,-1],[0,0,1]]Apply the three operations separately first:
A: (1,1) -> (2,1) -> (-1,2) -> (3,1)B: (3,1) -> (6,1) -> (-1,6) -> (3,5)C: (2,2) -> (4,2) -> (-2,4) -> (2,3)
Now verify directly. The matrix gives M[x y 1]^T = [-y+4, 2x-1, 1]^T. Substituting the three original points produces A'(3,1), B'(3,5) and C'(2,3), matching the staged calculation.

Rotation about a fixed point: translate, rotate, translate back
The basic R(theta) matrix rotates around the origin. To rotate around pivot F = (2,1), first move F to the origin, rotate, and then restore it:
M_F = T(2,1) R(90) T(-2,-1)For P = (4,2), the relative vector is P - F = (2,1). A 90-degree anticlockwise rotation maps (2,1) to (-1,2). Adding the pivot back gives P' = (-1,2) + (2,1) = (1,3).
Matrix multiplication provides the second check:
M_F = [[0,-1,3],[1,0,-1],[0,0,1]]
M_F [4,2,1]^T = [1,3,1]^TThe same translate, transform, translate-back pattern handles scaling about a fixed point (xf,yf): x' = xf + sx(x-xf) and y' = yf + sy(y-yf).
Transformation order, inverses and the traps that change the answer
Matrix multiplication is generally not commutative. For P = (1,2), scaling by S(2,3) and then translating by T(4,-1) gives (1,2) -> (2,6) -> (6,5). Translating first and scaling second gives (1,2) -> (5,1) -> (10,3). The same operations produce different outputs.
An inverse composite reverses both the operations and their order. For the triangle matrix, M^-1 = S^-1 R^-1 T^-1. Recover A(1,1) from A'(3,1) in three steps:
Apply
T^-1:(3,1) -> (-1,2).Apply the 90-degree clockwise
R^-1:(-1,2) -> (2,1).Apply
S^-1:(2,1) -> (1,1).
When an answer looks wrong, check for these common causes:
Mixing row-vector and column-vector conventions.
Reading
T R Sas an instruction to applyTfirst.Using clockwise sine signs in an anticlockwise rotation matrix.
Rotating about the origin when the question supplies a pivot.
Dropping the homogeneous
1from a point.Rounding
sin thetaorcos thetabefore the final step.
Window-to-viewport transformation: a complete viewing example
A world window [xmin,xmax] x [ymin,ymax] selects coordinates. A viewport [umin,umax] x [vmin,vmax] specifies where they appear. When both y-axes point upward:
sx = (umax-umin)/(xmax-xmin)
sy = (vmax-vmin)/(ymax-ymin)
u = umin + (x-xmin)sx
v = vmin + (y-ymin)syMap window x = 10..30, y = 20..60 to viewport u = 100..500, v = 50..250. The scales are sx = 400/20 = 20 and sy = 200/40 = 5.
For P(15,50):
u = 100 + (15-10)20 = 200
v = 50 + (50-20)5 = 200The corner checks are (10,20) -> (100,50) and (30,60) -> (500,250), so both endpoints map correctly. However, unequal scales 20 and 5 distort the aspect ratio. Also check the display's axis direction. If raster v increases downward, use v = vmax - (y-ymin)sy; the same point then maps to (200,100), not (200,200).

Transformation exam patterns and a four-step solving routine
Common exam-style forms ask you to identify a primitive matrix, calculate a transformed point, choose the correct composite order, transform about a fixed point, recover an inverse, or map a window point to a viewport.
Use this four-step routine:
Write the coordinate convention and positive rotation direction.
List the operations in spoken order.
Build the combined matrix from right to left.
Verify one point by applying the operations individually.
For a viewport problem, also write the axis direction and decide whether unequal scales are acceptable. After you can execute the routine without notes, GATE Guidance by Sanchit Sir provides a broader preparation structure.
2-D transformations: the short version and next step
Remember this chain: write the homogeneous point, choose each primitive matrix, compose from right to left, handle a pivot with translate-transform-translate back, and treat window-to-viewport mapping as scale plus offset. For the triangle, your self-check is A'(3,1), B'(3,5), C'(2,3).
Redo the triangle without the solution and verify one vertex both ways. For a broader Computer Science learning path, continue with Zero to Hero: Complete CS Course, or review the Semester & College Exam Courses. Then practise the matrix order until it becomes automatic.




