Hilbert curve
A single path that visits every cell of a 2ⁿ × 2ⁿ grid; in the limit it passes through every point of the square.
Adjust parameters
Export
Formulas and key values
- Construction rule
Visit the four quarters of the square in a U; inside each quarter, repeat the whole pattern at half size, rotated so the pieces join.
- Arc lengthIn the graph ≈ 31.97
- Cells visitedIn the graph = 1024
- Dimension of the limit
n is the order; the curve lives in the unit square.
Explainer video
Make a video of the Hilbert curve
Opens the Creator with a ready-made brief for this curve. Free-form generation is in beta.
Start the video01 · Definition
What is the Hilbert curve?
Divide a square into four quarters and join their centres with a U-shaped path. Then replace each quarter by a smaller copy of the whole pattern, rotated so the copies connect end to end. David Hilbert published this construction in 1891, a year after Peano showed that a curve can fill a square.
The order-n path visits all 4ⁿ cells of the grid once. As n grows, the curves converge to a continuous map from a line segment onto the entire square. Its practical virtue is locality: points close along the curve are close in the square, which is why it orders pixels, map tiles and database keys.
02 · Properties
Key properties
- Order n visits 4ⁿ grid cells, each exactly once.
- In the unit square the order-n path has length 2ⁿ − 2⁻ⁿ.
- The limit is a continuous surjection from [0, 1] onto the square: a space-filling curve.
- Its image has dimension 2, the dimension of the square it fills.
- Nearby positions along the curve land in nearby cells, which makes it a good 1-D index for 2-D data.
03 · Questions
Hilbert curve: common questions
- How is the Hilbert curve constructed?
- Construction rule: Visit the four quarters of the square in a U; inside each quarter, repeat the whole pattern at half size, rotated so the pieces join.. n is the order; the curve lives in the unit square.
- What is the arc length of the Hilbert curve?
- Arc length: L_n = 2^n - 2^(-n). n is the order; the curve lives in the unit square.
04 · Keep exploring