Matrices in 2D
Faculty of Media, Creative Arts, and Design, Humber Polytechnic
Demos built using Claude Code
A matrix is just a table of numbers. Here’s an example from the wild:
\[\begin{pmatrix} 3 & 0 & 4 \\ 0 & 3 & 5 \\ 0 & 0 & 1 \end{pmatrix}\]Why do game developers love them so much? They allow us to do useful things to positions and directions!
You can make vectors bigger, smaller or point the other way with the scale matrix, where \(scale_x\) and \(scale_y\) mean the scale along \(x\) and \(y\):
\[\begin{pmatrix} scale_x & 0 & 0\\ 0 & scale_y & 0\\ 0 & 0 & 1 \end{pmatrix}\]You can move positions around using the translation matrix, where \(\Delta x\) and \(\Delta y\) mean the change in \(x\) and \(y\):
\[\begin{pmatrix} 1 & 0 & \Delta x\\ 0 & 1 & \Delta y\\ 0 & 0 & 1 \end{pmatrix}\]You can rotate vectors using the rotation matrix, where \(\theta\) is the angle:
\[\begin{pmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{pmatrix}\]Think of a row vector multiplying a column vector:
\[\begin{pmatrix} 1 & 2 & 3 & 4 \end{pmatrix} \times \begin{pmatrix} 10\\20\\30\\40 \end{pmatrix}\]
\[= 1(10) + 2(20) + 3(30) + 4(40)\]
\[= 300\]
Use the dumptruck method three times for a 3x3 matrix multiplied with a column vector:
Just keep on dumptrucking for multiplying matrices:
Multiply matrices to combine transformations. But be careful, order matters!
Game Math 1, Umer Noor, PhD