Homogeneous Coordinates
(You can watch the video version of this post on YouTube.)
Now using matrix multiplication, you can do scaling and rotation around the origin, right? Shearing too. But it’s all around the origin, and there’s no way to do translation .. with just a matrix-vector multiplication. It’d be nice if we could represent any affine transformation by a matrix, and compose them by multiplying the matrices as normal. Enter: homogeneous coordinate. (“Ho-MOH-genous” or “homo-GEE-nious”? People just don’t really seem to agree on the pronunciation here.) There are different ways to get there and reasons to do it, but let’s do it as, uh … sleight of hand to get translations.
Take the normal transformation matrix and let’s just put the translation vector in a new column to the right. And we’ll give all of our vectors one more component: just put a 1. Now if we multiply this - hey presto - we did the translation!
$$\begin{bmatrix} a_{11} & a_{12} & t_x \\ b_{21} & b_{22} & t_y \\ \end{bmatrix}\begin{bmatrix} x \\ y \\ \mathbf{1} \\ \end{bmatrix} = \begin{bmatrix} a_{11}x + a_{12}y + t_x \\ b_{21}x + b_{22}y + t_y \\ \end{bmatrix} $$
To get the matrices to compose like we want to, add a row at the bottom and put some numbers to make it do what it’s supposed to.
$$\begin{bmatrix} a_{11} & a_{12} & t_x \\ b_{21} & b_{22} & t_y \\ 0 & 0 & 1\\ \end{bmatrix}\begin{bmatrix} x \\ y \\ 1 \\ \end{bmatrix} = \begin{bmatrix} a_{11}x + a_{12}y + t_x \\ b_{21}x + b_{22}y + t_y \\ 1 \\ \end{bmatrix} $$
So the way I said it, we just did this to push some numbers around, and I would say that this mostly explains why you see $4\times4$ matrices, or maybe $3\times4$, when you do 3D graphics. But it is still linear algebra so all of this does actually mean something – it comes up projective geometry, which is actually particularly useful for computer graphics, but I’ll let you look that up on your own. Particularly fun are the “perspective divide” and Plücker coordinates.