Module 2: Transformations
You can apply one transformation after another. First rotate the grid, then stretch it. The combined effect is itself a linear transformation — and it has its own matrix.
If A is the first transformation and B is the second, the composition is written BA — B after A. The order matters: rotate-then-scale is not the same as scale-then-rotate.
Read right-to-left: apply A to the vector first, then applyB to the result. The combined matrix BA stores that whole process in one object.
Consider rotating 90° then scaling x by 2, versus scaling x by 2 then rotating 90°. Try swapping A and B in the interactive — you'll get a different grid each time. In matrix terms: BA=AB in general.
There's a clean rule for area scaling: the determinant of a product equals the product of the determinants.
If A doubles area and B triples it, BA scales area by 6. Watch the determinant readout below the matrices as you change presets.
import numpy as np
A = np.array([[0, -1], [1, 0]]) # rotate 90°
B = np.array([[2, 0], [0, 1]]) # scale x by 2
# Apply A first, then B
BA = B @ A
v = np.array([1, 0])
print(BA @ v) # same as B @ (A @ v)In NumPy, B @ A computes the composed matrix. Note that A @ B gives a different result.