Skip to main content
Back to module
Calculus & Linear Algebra for STEM · Vectors and Matrices

Linear transformations

Reading37mLesson 3 of 3 in this module

Read a matrix as a transformation of space: rotations, scalings and shears, composition, and the determinant as area scale.

Why this matters

So far a matrix has been a table of coefficients. There is a more powerful way to see it: a matrix is a function that moves vectors. It can rotate, stretch, shear or flatten space. Computer graphics and game engines rotate every vertex with a matrix, robotics chains rotations to place a gripper, materials scientists describe strain with a matrix, and data scientists reduce dimensions by projecting data. Once you see matrices as transformations, eigenvalues (next module) make sense.

The core idea

A linear transformation T takes a vector in and gives a vector out, with two rules: T(u + v) = T(u) + T(v) and T(c·v) = c·T(v). Grid lines stay straight, parallel and evenly spaced, and the origin stays put. Every linear transformation of 2D space is multiplication by a 2 × 2 matrix, and the matrix is easy to read:

The columns of the matrix are where the basis vectors land.

The basis vectors are i = (1, 0) and j = (0, 1). If a transformation sends i to (a, c) and j to (b, d), its matrix is

| a  b |
| c  d |

and any vector (x, y) = x·i + y·j lands at x·(a, c) + y·(b, d).

A gallery of transformations

TransformationMatrixEffect on (1, 0) and (0, 1)
Scale by 2 in x, 3 in y[[2, 0], [0, 3]](2, 0), (0, 3)
Rotate 90° counter-clockwise[[0, −1], [1, 0]](0, 1), (−1, 0)
Rotate by angle θ[[cos θ, −sin θ], [sin θ, cos θ]](cos θ, sin θ), (−sin θ, cos θ)
Horizontal shear[[1, k], [0, 1]](1, 0), (k, 1)
Reflect across the x-axis[[1, 0], [0, −1]](1, 0), (0, −1)
Project onto the x-axis[[1, 0], [0, 0]](1, 0), (0, 0)

Worked example: rotate the point (2, 1) by 90°.

| 0  −1 | | 2 |   | 0·2 − 1·1 |   | −1 |
| 1   0 | | 1 | = | 1·2 + 0·1 | = |  2 |

Composition is multiplication

Applying B first and then A is the single transformation AB. Order matters: rotating then shearing is not the same as shearing then rotating, which is exactly why matrix multiplication is not commutative. Two rotations combine as you would hope: rotation(α) · rotation(β) = rotation(α + β).

The determinant as area scale

The determinant of a 2 × 2 matrix tells you how much the transformation scales area. The unit square (area 1) becomes a parallelogram of area |det|:

  • Scaling by 2 and 3: det = 6, areas grow six-fold.
  • Any rotation: det = 1, areas unchanged.
  • A shear: det = 1, the square leans but keeps its area.
  • A projection: det = 0, space is flattened onto a line, which is why it has no inverse.
  • A negative determinant means the transformation flips orientation (like a mirror).

In code

import numpy as np

def rotation(theta):
    c, s = np.cos(theta), np.sin(theta)
    return np.array([[c, -s], [s, c]])

R = rotation(np.pi / 2)
print(R @ np.array([2.0, 1.0]))    # about [-1, 2]
print(np.linalg.det(R))            # 1.0

To transform many points at once, stack them as columns of a matrix P and compute R @ P.

Common mistakes

  • Putting the images in rows instead of columns. The column convention is what makes A @ x work.
  • Angles in degrees. np.cos expects radians; convert with np.radians.
  • Reading AB as "A first". In AB applied to x, B acts first.
  • Forgetting translation is not linear. Moving every point by a fixed offset moves the origin, so it is not a 2 × 2 matrix. Graphics uses 3 × 3 "homogeneous" matrices to include it.

Quick recap

  • A matrix is a linear transformation: its columns are the images of the basis vectors.
  • Rotations, scalings, shears, reflections and projections all have simple matrices.
  • Composing transformations multiplies their matrices, and order matters.
  • The determinant is the area scale factor; 0 means space is flattened.

Try it

In the Do tab, build a rotation matrix and test that it behaves like a rotation.

Also in this lesson: