Graphics / Reference / 2×2 matrix representation
2×2 matrix representation
A 2 by 2 matrix represents transformations whose output coordinates are linear combinations of the original x and y. Rotation, scaling, shear and identity all fit this form.
The general 2 by 2 transformation is:
[x';y'] = [a,b;c,d]*[x;y]
which means:
x' = a*x + b*y y' = c*x + d*y
Rotation by θ:
[cos θ,-sin θ;sin θ,cos θ]
so x' = x cos θ - y sin θ and y' = x sin θ + y cos θ.
Uniform scale by factor m:
[m,0;0,m]
Non-uniform scaling uses different diagonal entries:
[mx,0;0,my]
Identity, which leaves the point unchanged:
[1,0;0,1]
X-shear by factor a:
[1,a;0,1]
The matrix entries specify how much of the original x and y contributes to each output coordinate. Translation does not fit this simple 2 by 2 form because translation adds constants rather than forming only linear combinations of x and y.
Builds on
Read
- Read the chapter: 2×2 matrix representation