Member-only story
Combining and inverting transform matrices
We previously looked at using matrices to represent transformations in 2 dimensions. As we will see here, we can apply compound transformations (such as scale and rotate) by applying several matrices. We can also calculate the inverse of a transform simply by inverting the matrix.
This in turn allows us to switch between different frames of reference to define transformations, for example, to allow us to rotate a shape about its own centre. We can also use matrix algebra to represent a combination of transformations as a single matrix, which means the transformations can be applied very efficiently.
Using 3 by 3 matrices
In the earlier article on transformations, we introduced the idea of using a 3 by 3 matrix, which allows us to represent translation via matrix multiplication:
The values a to d represent the values in a normal 2 by 2 matrix, u and v represent the x and y translation, and the bottom row is always (0, 0, 1).
This matrix needs a 3-vector to operate on. This is formed by adding an extra element, which is always 1, to the normal (x, y) vector:
In this article, since we are dealing with general, combined, transform matrices, we will always use the 3 by 3 form, even when u and v happen to be 0.