Chapter 6
Determinants
When you apply a transformation, regions of space grow or shrink. The determinant tells you by exactly how much -- and whether orientation flips.
You've been thinking of matrices as transformations. A matrix takes the basis vectors and moves them somewhere new, and the entire plane follows. But we haven't yet asked a simple question: after the transformation, how much has area changed?
Take the unit square -- the square formed by and , with an area of exactly 1. Apply a transformation, and that square warps into a parallelogram. The area of that parallelogram tells you something fundamental about the transformation. It's called the determinant.
The unit square, before and after
Start with the unit square: corners at , , , and . Its area is 1. Now apply the transformation described by the matrix . The basis vectors land at and . The unit square becomes a parallelogram.
The dashed purple square has area 1. After the transformation, it becomes the orange parallelogram with area 3. The determinant of this matrix is 3.
The original unit square (purple, dashed) had area 1. The orange parallelogram has area 3. That factor of 3 is the determinant. Every region of the plane -- not just this square -- gets its area multiplied by 3 under this transformation. A tiny circle becomes a tiny ellipse with 3 times the area. A complex polygon triples its area. The determinant is a single number that captures the scaling factor for all areas.
Determinant = 2: area doubles
Here's a cleaner example. The matrix stretches space horizontally by a factor of 2 and leaves the vertical direction alone. The basis vector lands at , and stays at .
The unit square doubles in width. Area goes from 1 to 2. The determinant is 2 -- every area in the plane doubles.
This is the simplest case: a horizontal stretch by factor 2 with no vertical change. The rectangle's area is . The determinant confirms it: .
Determinant = 0: collapse
Now something dramatic. The matrix sends to and to . Look closely at those two vectors: is exactly half of . They point in the same direction. The two basis vectors, which used to span the entire plane, now both land on the same line.
Both basis vectors land on the same line. The parallelogram has collapsed to zero area. The determinant is zero.
When the determinant is zero, space collapses. The entire 2D plane gets squished down onto a line (or even a single point). Information is lost. If two different input vectors get mapped to the same output, you can't tell them apart anymore -- the transformation is irreversible. A matrix with determinant zero is called singular, and it has no inverse.
The computation confirms it: .
Negative determinant: orientation flips
Here's the subtlest case. The matrix reflects space across the -axis. The basis vector flips to , while stays at .
The parallelogram (in this case still a square) has area 1. So area is preserved. But something has changed: the orientation of the basis vectors is reversed. Originally, was counter-clockwise from . After the reflection, is clockwise from the new . It's like the plane has been turned inside-out.
The area is still 1, but the plane has been reflected. The determinant is -1: the negative sign means orientation reversed.
The determinant captures both pieces of information. Its absolute value tells you the area scaling factor. Its sign tells you whether orientation is preserved (positive) or flipped (negative). A positive determinant means the basis vectors maintain their counter-clockwise relationship. A negative determinant means that relationship has reversed -- like looking at the plane in a mirror.
The formal bit
For a 2x2 matrix, the determinant has a clean formula:
This isn't a magic incantation -- it's the signed area of the parallelogram formed by the column vectors and . The "signed" part means it's positive when the second vector is counter-clockwise from the first, and negative when it's clockwise.
Here's how the formula connects to the geometry. The column vectors of the matrix are the transformed basis vectors. They form a parallelogram. The area of a parallelogram spanned by two vectors can be computed as the cross product magnitude -- and for 2D vectors and , that's exactly .
Three properties worth knowing:
Multiplicative. . If scales area by 3 and scales area by 2, then applying then scales area by 6. The determinants just multiply.
Zero means singular. If , the matrix is not invertible. Space has collapsed -- you can't un-collapse it. This is the single most important use of the determinant: it's a one-number test for whether a matrix has an inverse.
Sign tracks flips. Each reflection flips the sign. Two reflections cancel out (positive again). The sign of the determinant is a running tally of how many times orientation has been flipped.
Worked example: front-face culling in 2D
In 2D game rendering, you often need to know if a triangle is "front-facing" (vertices listed counter-clockwise) or "back-facing" (clockwise). This matters for deciding what to draw and what to cull.
Given a triangle with vertices , , and , form two edge vectors:
Now compute the determinant of the matrix formed by these edge vectors as columns:
The result is positive, so the vertices are listed counter-clockwise -- this triangle is front-facing. If the result were negative, the vertices would be clockwise (back-facing). If the result were zero, the three points would be collinear -- not a triangle at all.
The absolute value divided by 2 also gives you the triangle's area: square units. Two results from one computation.
In code, that's just:
function isFrontFacing(p0, p1, p2) {
const e1x = p1.x - p0.x;
const e1y = p1.y - p0.y;
const e2x = p2.x - p0.x;
const e2y = p2.y - p0.y;
const det = e1x * e2y - e2x * e1y;
return det > 0; // positive = CCW = front-facing
}
This exact pattern shows up in physics engines (checking winding order), computational geometry (point-in-polygon tests), and every 3D renderer's back-face culling pipeline -- just extended to 3D with cross products.
Key Takeaway: The determinant measures how a transformation scales area. Zero means collapse -- information is lost. Negative means orientation flips.
What's next
If a transformation has a nonzero determinant, it doesn't collapse space -- which means it can be undone. That's the inverse matrix. Given a matrix and a result vector , the inverse lets you solve for the original input: . But only when the determinant isn't zero.