Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Matrices and Transforms  ›  Lesson

Matrices: Grids That Act on Vectors

Matrix 12 minA matrix is a grid of numbers, and multiplying it by a vector gives each output number as the dot product of one row with that vector.

Matrices: Grids That Act on Vectors

When a crate thumps onto a deck, Harbour Hopper squashes its sprite for a moment — wider and shorter — before it springs back. Every corner of the crate moves by the same rule, and games write rules like that as a small grid of numbers: a matrix.

The rule

Each output number is one row dotted with the vector.

A 2×2 matrix has two rows and two columns. Multiplying it by a vector gives a new vector, and each output number is the dot product of one row with the input:

[abcd][xy]=[ax+bycx+dy]\begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} ax + by \\ cx + dy \end{bmatrix}

The landing squash is [1.5000.5]\begin{bmatrix} 1.5 & 0 \\ 0 & 0.5 \end{bmatrix}. The crate's top-right corner, (1,1)(1, 1) measured from the crate's centre, becomes (1.5×1+0×1, 0×1+0.5×1)=(1.5,0.5)(1.5 \times 1 + 0 \times 1,\ 0 \times 1 + 0.5 \times 1) = (1.5, 0.5): half as wide again, and half as tall.

The identity matrix [1001]\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} leaves every vector alone. It's the "do nothing" rule, and it's where the squash ends up when the crate has recovered.

Sizes must match: a matrix needs as many columns as the vector has components. A 2×2 acts on 2D vectors, a 3×3 on 3D ones. Two matrices can also be multiplied together into a single matrix that does both jobs, which the next lessons rely on.

Why a grid rather than a formula? A matrix is data. The game can store it, pass it around, send it to the graphics card, and apply the very same one to every corner of every crate in a stack: thousands of vectors, one rule.

The shortcut

Run along the row, down the vector: pair the numbers up, multiply each pair, add. One row gives one output number.

Rows (2, 1) and (0, 3) times the vector (4, −1)Step 1 of 3
  1. Top row

    (2, 1) with (4, −1): 2 × 4 + 1 × (−1) = 8 − 1 = 7.

The trap is pairing the vector with the columns instead of the rows. For this matrix that gives (2×4+0×(−1), 1×4+3×(−1))=(8,1)(2 \times 4 + 0 \times (-1),\ 1 \times 4 + 3 \times (-1)) = (8, 1), a different and wrong answer. It's the classic transposition slip, and the "along the row" chant prevents it.

Drills

Answer fast — trust the rule.

What is the first number of the matrix with rows (2, 1) and (0, 3) times the vector (5, 2)?
2×5+1×2= ?2 \times 5 + 1 \times 2 = \,?
quick drill

What does the identity matrix, rows (1, 0) and (0, 1), do to (7, −2)?

quick drill

The landing squash has rows (1.5, 0) and (0, 0.5). Where does the corner (2, 2) go?

quick drill

Multiply the matrix with rows (1, 2) and (−1, 0) by the vector (3, 4).

quick drill

Which vector can a 3×3 matrix multiply?

Remember

  • Matrix times vector: each output number is one row dotted with the vector.
  • The identity matrix changes nothing; a 2×2 acts on 2D vectors, a 3×3 on 3D ones.
  • Trap: pairing with columns instead of rows gives a different, wrong answer.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainRows, not columns

Explain to a teammate how to multiply the matrix with rows (2, 1) and (0, 3) by the vector (4, −1), and show which mistake produces (8, 1) instead.