[Intermediate] — Translation, scaling, rotation, shear and reflection as homogeneous matrices; reading a matrix by its pattern; composing transforms (and why order matters); row- versus column-vector conventions; and the “move this object so its features end up there” method for 3D questions.

Part 1 of the course. Note 09 uses these matrices in the camera pipeline; Rigid Body Transforms goes deeper on rotations. This note is the by-hand, exam version.

Before you start

You can multiply a matrix by a vector and two matrices together, and you know , .

After this note you will be able to:

  1. Write the 3 × 3 homogeneous matrix for any basic 2D transform, and say why the extra coordinate is needed.
  2. Identify a given matrix by its pattern.
  3. Compose transforms about an arbitrary pivot, in either vector convention, and check the result.
  4. Plan a 3D transform from features (apex, base centre, size) and write it as a product.

The kid version

Picture a shape cut out of paper on a table. You can slide it (translate), stretch it (scale), spin it (rotate), or push its top sideways like a deck of cards (shear). Each move can be written as a little grid of numbers, and doing two moves one after another is the same as multiplying their grids. The order matters: spin-then-slide puts the shape somewhere different from slide-then-spin.

Where the analogy stops working. Sliding cannot be done by multiplying the ordinary 2-number position by a 2 × 2 grid at all. That is the whole reason for the extra “1” coordinate below — it is a trick, not something the paper “has”.

Terms used in transformations

  1. Affine transformation: This is a transformation that keeps straight lines straight and parallel lines parallel. Translation, rotation, scaling, shear and reflection are all affine.
  2. Homogeneous coordinates: This is writing a 2D point as , or a 3D point as , so that translation becomes a matrix multiplication too.
  3. Pivot: This is also known as the fixed point. This is the point a rotation or scaling happens about; it does not move.
  4. Composition: This is combining several transformations into one matrix by multiplying their matrices.
  5. Column-vector convention: This is writing the point as a column and the new point as . A chain applies first (read right to left).
  6. Row-vector convention: This is writing the point as a row and the new point as . The matrices are the transposes of the column versions, and a chain reads left to right.
  7. Shear: This is a transform that slides each point parallel to an axis by an amount proportional to its other coordinate, turning a square into a parallelogram.

1. Why homogeneous coordinates

Rotation and scaling are matrix multiplications in ordinary 2D coordinates, but translation (adding a shift) is not — no 2 × 2 matrix adds a constant. Adding a third coordinate makes every transformation a multiplication, so a whole chain combines into one matrix by multiplying.

“Easier to use a 3 × 3 than a 2 × 2” is the usual half-answer. The real reason is that translation cannot be written as a 2 × 2 multiplication; with 3 × 3 homogeneous matrices, everything (translation included) is one, and chains combine.

A homogeneous 2D point is with and ; usually .

Convention warning. With column vectors, and applies first. With row vectors, , every matrix is transposed, and the chain reads left to right. Always check which convention the question uses — SSG 511’s assignment uses row vectors.

2. The 2D matrices (column-vector convention)

Translation by — the shift sits in the right-hand column:

Scaling by about the origin — only the diagonal changes:

Rotation by anticlockwise about the origin. In words: the new is and the new is ; anticlockwise is positive.

Shear in by () and shear in by ():

Reflection about the -axis flips the sign of : diagonal . About the -axis it flips : diagonal .

Row-vector form (): transpose each. For rotation

3. Recognising a matrix by its pattern

What you seeWhat it is
Non-zero numbers in the right-hand column (top two rows) — or, with row vectors, the bottom rowTranslation
Only the diagonal differs from the identityScaling (a negative entry is a reflection)
A 2 × 2 block of cos and sinRotation. If the minus sign on sin is on the other row from the standard matrix, the direction reverses (clockwise with column vectors — or it is the row-vector form of anticlockwise)
Non-zero off-diagonal entries in the top-left 2 × 2 that are not cos/sinShear. If the diagonal is also not 1, shear combined with scaling
Bottom row Any 2D affine transformation

How to draw the image of a shape: transform each corner by multiplying its homogeneous coordinates by the matrix, then join the new corners in the same order. This works because affine transforms keep straight lines straight. For a square divided into four smaller squares, also transform the edge midpoints and the centre, so the inner lines can be drawn.

4. Composing transformations

Matrix multiplication is not commutative, so order matters.

To rotate (or scale) about a point other than the origin: translate it to the origin, rotate, translate back. With column vectors:

Worked — a composite 2D transform (row vectors)

Triangle , , . In order: rotate 60° anticlockwise about , then scale by 2 in and 0.5 in about the same point, then translate by .

With row vectors the first operation is written first:

PointImage
(3, 2)(7, 1)
(5, 2)(9, 1.866)
(3, 5)(1.804, 1.75)

Check by hand: relative to the pivot it is . Rotated: . Scaled: . Add the pivot: . Add : . ✓

Always use the pivot check. The pivot itself must land at — and it does. If your pivot moves, your order is wrong.

Worked — the square under a 30° rotation (row vectors)

Square , , , , and

With row vectors this is a 30° anticlockwise rotation about the origin: , .

PointImage
A(−1, 1)(−1.366, 0.366)
B(1, 1)(0.366, 1.366)
C(1, −1)(1.366, −0.366)
D(−1, −1)(−0.366, −1.366)

Keep the question’s labels. Shifting the letters (writing when the question’s A is ) gives the right numbers on the wrong corners.

Part (ii) of the same question, : the rule is , — a shear combined with a scaling in . Do the four points the same way, then draw.

5. 3D transformations (4 × 4)

Translation has in the right-hand column. Scaling has the diagonal . Rotations about the axes (right-handed, anticlockwise looking toward the origin), with , :

A rotation about one axis leaves that axis’s row and column as the identity and puts cos and sin in the other two. (Note ‘s signs are swapped relative to the others — because going is the positive direction about .)

Homogeneous coordinates in 3D

Conversion: becomes . Any with is the same point. To go back, divide by the last coordinate: , which needs . A point with is a point at infinity — a direction.

The four blocks of a general 4 × 4 matrix (the usual layout):

BlockCoefficientsWhat it does
Top-left 3 × 3 … Linear transforms: rotation, scaling, shear, reflection
Right-hand column … Translation
Bottom row … Perspective (projection)
Bottom-rightOverall uniform scaling via ; 1 for an ordinary matrix

A projection shows up as a bottom row that is not — exactly the in note 09’s perspective matrix.

Worked — rotation about an arbitrary axis

Rotate by 90° anticlockwise about the line through parallel to the -axis, then scale by 2 about the origin.

  1. Translate by : .
  2. Rotate about (): .
  3. Translate back by : .
  4. Scale by 2: .

As a product with row vectors: . The pattern — move the axis to the origin, rotate, move back — works for any axis. For an axis not parallel to a coordinate axis, first rotate the axis onto a coordinate axis, rotate about it, then undo that alignment.

6. The “make these features end up there” method

For questions like the cone in SSG 511 Q4:

  1. Describe the object by a few key features. For a cone: the apex, the centre of the base, the height, and the base radius.
  2. Work out where the same features must end up.
  3. Compare old and new:
    • A change of size is a scaling. If it differs along different directions (say along the cone’s axis and across it), do it in the object’s own axes first, while the object still sits at the origin.
    • A change in the direction of an axis is a rotation. The rotation axis is the cross product of the old and new directions, and the angle comes from . Or use a sequence of rotations about , and .
    • A change of position is a translation, done last.
  4. Write each matrix, then multiply them in order. With column vectors , so the scaling is applied first.

Sanity-check the plan on the features before writing any matrix. Apply your sequence to the apex and the base centre in your head — both must land on their targets, and the distance between them must be the new height.

Common pitfalls

  1. Mixing conventions — a row-vector question answered with column-vector matrices gives the transpose, which for rotation means the wrong direction.
  2. Rotating about the origin when the question says about a point. Translate–rotate–translate back.
  3. Translating first in a feature-matching problem, then scaling — the scale then moves the object.
  4. Relabelling corners.
  5. Forgetting that ‘s sine signs are swapped.

Check your understanding

  1. What does do to a point, in the column-vector convention? And in the row-vector convention?
  2. Why must the translation come last in “scale, rotate, then place”?
  3. A 4 × 4 matrix has bottom row . What kind of transform is it?
Answers (after your attempt)
  1. Column vectors: translation by 0.5 in . Row vectors: , , — the 0.5 sits where a perspective term lives, so after dividing by it is a projective transform, not a translation. Which convention the question uses changes the answer — say which you assumed.
  2. Scaling and rotation are about the origin; once the object is moved away, they would also move (and swing) it.
  3. A projection: becomes , so dividing by divides by depth — perspective.

Practice — independent tasks

From SSG 511 (see the question bank for the full wording):

  1. Exam Q2 — draw the subdivided square’s image under the 60° rotation, the matrix , and . Transform the midpoints too.
  2. Exam Q4 — the cone: apex , base of diameter 1 centred at the origin, to apex , base centred at , diameter 2. Name the transforms, their order, and the product.
  3. Assignment B-3 — translate, rotate, rotate-about-a-point, and recover an affine matrix from three point pairs (six unknowns, six equations).
  4. Supplementary 2 — translate triangle , , by .

Done when each answer passes the pivot check (or the feature check for Q4).

Before moving on

Next: Curves: Bézier and B-splines.

↑ Back to Computer Graphics