This week we looked at matrices from a theoretical and practical point of view. The code we worked through is available on the class-02-24-end tag.
From a theoretical perspective, matrices are grids of numbers that can be multiplied in a particular way observing specific rules to produce outcomes that are interesting and useful. The rules are:
A * B is only valid of the number of columns in A match the number of rows in B. This number is known as the "interior dimension" of A and B.
The result C of A * B has the same number of rows as A and the same number of columns as B.
For each element in C, where i is the row number of the element, j is the column number of the element, k is the interior dimension
Cij = Ai0×B0j + Ai1×B1j + Ai2×B2j + ... + Aik×Bkj
meaning it is the sum of multiplying all the numbers in the matching row in A with their corresponding numbers in the matching column in B and summing the results.
This is often demonstrated with an animation.
In practice in computer graphics the majority of the time we only deal with two kinds of matrices:
Square matrices represent transformations and multiplying them together combines the transformations. Column matrices represent vectors and multiplying a matrix with a vector applies the matrix's transformation to the vector.
We saw a number of transformations we could represent with matrices. The formal name for this kind of transformation is "affine transformation".
Understanding the math is helpful, but in practice we deal with matrices through programming APIs. Look at all the matrix functions available in Unity.