The idea: take away twice the part along the normal
A mirror plane through the origin is fixed by its unit normal n, the direction at a right angle to the plane. Split any vector v into two parts: the part along n, which is (n·v)n, and the part in the plane, which is the rest. A mirror keeps the part in the plane and turns the part along n around. So the image is v minus twice the part along n:
H·v = v − 2(n·v)n, so H = I − 2nnT.
This matrix is called a Householder reflection. nnT is a 3 × 3 matrix (column times row), and (nnT)v = n(n·v) is exactly the part of v along n.
The matrix for each mirror
For a normal direction a (any length), n = a/|a| and Hij = δij − 2aiaj/(a·a). Its columns are where î, ĵ and k̂ land, as for every matrix (red, green and blue on the canvas).
| mirror | n | H | what it does |
|---|---|---|---|
| the xy-plane (z = 0) | (0, 0, 1) | [1 0 0; 0 1 0; 0 0 −1] | z → −z |
| the yz-plane (x = 0) | (1, 0, 0) | [−1 0 0; 0 1 0; 0 0 1] | x → −x |
| the xz-plane (y = 0) | (0, 1, 0) | [1 0 0; 0 −1 0; 0 0 1] | y → −y |
| the plane x = y | (1, −1, 0)/√2 | [0 1 0; 1 0 0; 0 0 1] | swap x and y |
| the plane x + y + z = 0 | (1, 1, 1)/√3 | 1/3 on the diagonal, −2/3 elsewhere | subtract (2/3)(x + y + z) from each coordinate |
The coordinate mirrors only flip the sign of one coordinate (Demo: mirror in the xy-plane, z flips). A tilted mirror mixes all three: for x + y + z = 0, nnT has 1/3 in every entry, so H = I − (2/3)·(all ones) (Demo: a tilted mirror, x + y + z = 0).
Straight across, at a right angle
H·v − v = −2(n·v)n points along n, so every point moves on a line at a right angle to the mirror. The midpoint (v + H·v)/2 = v − (n·v)n has no part along n left, so it lies on the plane, and v and H·v are the same distance |n·v| from it on opposite sides. With the plane x = y and v = (2, 0, 1): H·v = (0, 2, 1), the midpoint is (1, 1, 1), which has x = y, and H·v − v = (−2, 2, 0) is along n = (1, −1, 0)/√2 (Demo: each point crosses at a right angle). With x + y + z = 0 and v = (2, 1, 2): n·v = 5/√3, H·v = (−4/3, −7/3, −4/3) and the midpoint (1/3, −2/3, 1/3) adds up to 0.
When you press Reflect, every point of the cube moves on such a line. Halfway the map is (I + H)/2 = I − nnT, the projection onto the plane, so for one moment the whole cube lies flat on the mirror.
Right hand becomes left hand: det = −1
A reflection keeps every length and every angle: HTH = I. But it turns space inside out. î, ĵ, k̂ form a right-handed triple: î × ĵ = k̂ (curl the fingers of your right hand from x to y and the thumb points along z). After the mirror, H·î × H·ĵ = −H·k̂: the triple is left-handed. The determinant is the signed volume of the image cube, and its sign records the hand: det H = −1. The letter F on the cube's face reads backwards (Demo: right hand becomes left hand (det −1)). No rotation can do that: rotations have det = +1.
Reflect twice: back to the start
Reflecting the mirror image gives back the original: H2 = I. In symbols, with nTn = 1, (I − 2nnT)2 = I − 4nnT + 4n(nTn)nT = I. So H−1 = H, and since H is symmetric, HT = H = H−1: H is both orthogonal and symmetric. Two reflections have det (−1)(−1) = +1 (Demo: reflect twice, back to the start). Two reflections in different mirrors give a rotation about the line where the two planes meet, by twice the angle between them.
Eigenvalues 1, 1 and −1
Every vector u in the mirror plane has n·u = 0, so H·u = u: eigenvalue 1, and the plane gives two independent directions. The normal itself flips: H·n = n − 2n = −n, eigenvalue −1. The eigenvalues 1, 1, −1 multiply to det = −1 and add up to the trace 1. Points on the mirror never move; on the canvas the v menu has v = (1, 1, −1), which lies on the plane x = y, and v = (1, 1, 1), which is along the normal of x + y + z = 0. More in Eigenvectors.
H = I − 2Pn
Pn = nnT is the projection onto the line of n, and I − Pn is the projection onto the plane. A reflection goes twice as far as the projection onto the plane: H = I − 2Pn = 2(I − Pn) − I. Projections in 3D have their own page, 3D Projection Matrix; the same formula in 2D is F = 2P − I on Reflection Matrix.
Through the origin: −I
The point reflection v → −v sends every point straight through the origin. Its matrix is −I, and det(−I) = (−1)3 = −1 in 3D, because the dimension is odd. So in 3D −I reverses the hand, like a mirror. In 2D, −I is a rotation by 180° with det = +1. −I is not a mirror plane: it is the product of the three coordinate mirrors, HxyHyzHxz. All three eigenvalues are −1 (Demo: through the origin, −I).
Householder reflections in practice
Given a vector x, the mirror with n along x − |x|e1 sends x to (|x|, 0, 0): a reflection can zero every entry below the first in one step. Doing that column by column turns a matrix into an upper triangle R, and the product of the mirrors is the orthogonal Q of the QR factorization. This is how numerical libraries (LAPACK) compute QR, because reflections never amplify rounding errors. Gram–Schmidt builds the same Q one column at a time.
See also the overview Linear Transformations; the 2D Reflection Matrix; the other 3D maps 3D Rotation Matrix, 3D Projection Matrix and 3D Shear Matrix; Determinant; Inverse Matrix; Composing Transforms for products of maps; Vectors and the Dot Product for n·v; and Plane Equation for a plane and its normal.
What the page leaves out
Mirror planes that do not pass through the origin (an affine map: H·v + 2dn for the plane n·x = d), the proof that every orthogonal matrix is a product of at most three reflections (Cartan–Dieudonné), the rotation from two mirrors drawn step by step, reflections in more than three dimensions, complex Householder matrices, and the details of Householder QR (choice of sign, storing the vectors instead of the matrices).