2D Matrix Transformation Calculator – Rotation, Scaling & More (Theory)
A 2D linear transformation maps a vector \(\mathbf{x}=(x,y)\) to a new vector \(\mathbf{x}'\)
using a matrix:
\[
\mathbf{x}' = A\mathbf{x},\quad
A=\begin{bmatrix}a&b\\c&d\end{bmatrix}.
\]
This includes rotations, scalings, reflections, and shears. Many graphics pipelines also use an
affine transformation, which adds a translation:
\[
\mathbf{x}' = A\mathbf{x} + \mathbf{t},\quad
\mathbf{t}=\begin{bmatrix}t_x\\t_y\end{bmatrix}.
\]
Transforming “about a point”
Matrices naturally act about the origin. If you want to rotate/scale about a center point \(\mathbf{c}\),
you shift the shape so that \(\mathbf{c}\) becomes the origin, apply the matrix, then shift back:
\[
\mathbf{x}' = A(\mathbf{x}-\mathbf{c}) + \mathbf{c} + \mathbf{t}.
\]
In the calculator you can choose \(\mathbf{c}=(0,0)\), the shape centroid, or a custom center.
Common 2D transformation matrices
Determinant: area scale and orientation
The determinant of \(A\),
\[
\det(A)=ad-bc,
\]
controls two important geometric properties:
- Area scaling: a region’s area is multiplied by \(|\det(A)|\).
- Orientation: if \(\det(A)<0\), the transformation flips orientation (like reflections).
If \(\det(A)=0\), the matrix is not invertible and collapses 2D space into a line (or a point).
Inverse transformation
When \(\det(A)\neq 0\), the inverse matrix exists:
\[
A^{-1}=\frac{1}{\det(A)}
\begin{bmatrix}
d & -b\\
-c & a
\end{bmatrix}.
\]
The calculator reports whether the matrix is invertible by checking \(\det(A)\).
Coordinate geometry + graphics intuition
In computer graphics, transformations are often composed: rotate, then scale, then translate.
Composition corresponds to matrix multiplication (order matters):
\[
(A_2(A_1\mathbf{x})) = (A_2A_1)\mathbf{x}.
\]
Use the Play animation in the calculator to build intuition about how a matrix “moves” a shape.
This is especially helpful when comparing a “Z-shape” vs an “S-shape” deformation produced by different shears.
Worked mini-example: rotate the point (1,0) by 45°
With \(\theta=45^\circ\),
\[
A=
\begin{bmatrix}
\cos45^\circ & -\sin45^\circ\\
\sin45^\circ & \cos45^\circ
\end{bmatrix}.
\]
Then
\[
\mathbf{x}'=A\mathbf{x}
=
\begin{bmatrix}
\cos45^\circ\\
\sin45^\circ
\end{bmatrix}.
\]
The calculator’s Fill example uses this exact case.