The Hilbert Curve: How a Line Can Fill a Plane
The Hilbert curve is a recursively constructed fractal path whose successive approximations fold back on themselves with growing density, converging in the limit to a continuous image of the unit interval that passes arbitrarily close to every point of the unit square.
A complete interactive classroom, not just a preview.
Start when you are ready to enter this Stage's 9 scenes and explore, respond, and learn as you go.
What is the Hilbert curve, and what does it mean for a one-dimensional line to 'fill' a two-dimensional square?
A single line, bent the right way, can snake close enough to every point in a square to count as 'filling' it.
We learn in geometry that a 1D line has zero area, while a 2D square has area. So how can a curve be both?
Interactive order-by-order unfolding of the Hilbert curve, side-by-side comparison of iterations, and a visual measurement showing the curve getting arbitrarily close to every pixel of the square.
The Hilbert curve is a continuous, space-filling limit that trades local line-like structure for global plane-covering reach, and it actually powers real-world algorithms for maps, images, and databases.
It is probably just a clever maze-like spiral that visits a lot of squares in a grid, but never truly fills the plane — true space-filling is impossible because a line has no width.
- General history of all space-filling curves (Peano, Sierpinski, Moore)
- Applications beyond brief mention (e.g., detailed VLSI routing or database Hilbert-R-tree implementation)
- Measure theory and Hausdorff dimension proofs
- Comparison with other fractals such as the Koch snowflake
- 01Can a Line Fill a Square?slideQuestion
Open with the geometric paradox: a line is 1D, a square is 2D, and dimension says one cannot equal the other. Pose the driving question and preview the recursive U-shape that will resolve it.
- A line has length but zero area; a square has area
- We are asking whether a single continuous path can pass through every point of a square
- The Hilbert curve is the canonical visual answer to this paradox
- 02Your First GuessquizPrediction
Ask the learner to commit to one intuition about the Hilbert curve before seeing any construction.
- Make an explicit prediction about what the curve looks like
- Test whether the learner assumes it is a spiral, a grid walk, or a true limit object
- 03Build the Hilbert Curve Step by StepinteractiveEvidence
Let the learner choose the recursion order n and watch the Hilbert polyline unfold inside the unit square, with the path traced in real time and the grid cells visited highlighted.
- Each order divides the square into a 2^n by 2^n grid
- The path visits exactly one cell per step, traversing all 4^n cells without crossing itself
- Higher n visibly crowds more of the square interior
- 04Compare Orders Side by SideinteractiveEvidence
Display iterations n=1, 2, 3, and 4 next to each other so the learner can directly see how density grows while path length doubles each time.
- Order 1 is a simple U of three segments
- Each step turns every segment into four rotated copies
- Path length doubles (2^n) while bounding region stays fixed
- 05The Recursive RecipeslideExplanation
Explain the substitution rule: take any Hilbert polyline, replace each of its 4^k segments with four quarter-sized U-copies rotated and flipped into the four quadrants, then rescale. This is the same rule at every scale, which is why the curve is a fractal.
- Self-similarity: the whole curve looks like four rotated copies of itself
- Continuity is preserved at every join by construction
- The limit curve is continuous because each iteration is continuous and they converge uniformly
- 06How Close Does It Get?interactiveExplanation
Show that as n grows, the maximum distance from any point in the square to the nearest point on the curve shrinks toward zero, illustrating that the limit is genuinely space-filling.
- Pick any point in the square by clicking
- See the nearest segment of the Hilbert polyline light up
- Watch the distance drop sharply as n increases
- 07What the Limit Is — and Is NotslideBoundary
Clarify common misconceptions: the limit is a curve, not a filled region; it is continuous but nowhere differentiable; it has a well-defined point for every t in [0,1], but it is not an injective map.
- The limit has the cardinality and topology of an interval, not of an area
- Multiple values of t can map to the same square point
- Space-filling here means the image covers the square, not that the curve has thickness
- 08From Map to Image: Hilbert in the WildinteractiveTransfer
Transfer the idea: ask the learner to map a 16x16 grayscale image to a 1D Hilbert index and then 'unfold' it back, comparing locality preservation against a naive row-major scan.
- Hilbert order keeps spatially nearby pixels nearby in 1D
- Row-major order scatters neighbors far apart
- This is why Hilbert curves are used in spatial databases and image compression
- 09Answering the Driving QuestionslideResolution
Close the loop: restate the question, summarize that the Hilbert curve is a recursive fractal path whose limit is a continuous surjection from [0,1] onto the unit square, and note its real-world role in preserving locality.
- The Hilbert curve is a specific space-filling curve defined by a U-substitution rule
- Each iteration is a 1D path; the limit fills the 2D square
- It is a theoretical object with practical uses in mapping, indexing, and rendering
Discussion threads for a Stage aren't available yet.