The Hilbert curve in this visualization
In 1890 Giuseppe Peano gave a curve that passes through every point of a square, built on thirds; a year later David Hilbert gave a geometric construction built on halves. Order 1 is a U through the four cells of a grid. At each step, four smaller copies of the previous path are turned into position and joined end to end. Order visits all cells of a grid, one step at a time, and its line is about long.
The orders are nested: the parameter is cut into equal pieces, one per cell, and the cells for each piece are the sub-cells of the cell for the piece containing it in the order before. A fixed lies in nested pieces, whose cells shrink to one point ; neighbouring pieces get neighbouring cells, so is continuous. Conversely, take any point of the square and pick, order after order, nested small cells containing it. Their closed parameter pieces are nested too and share some ; the cells shrink to the point, so is that point. No finite order does this: each joins the centres of its cells by straight segments.
Points close on the line stay close in the square: a parameter interval of width stays within a few times of its start, all in one piece, as the probe’s window shows. The other way round fails: two cells side by side in the square can sit far apart on the line. It has to fail. A continuous curve that visited every point exactly once would make the square and a line segment the same shape, and they are not: remove an interior point from a segment and it falls into two pieces, remove one from a square and it does not. So the limit curve passes through some points more than once.
The Z order visits the cells in the same quarters but simply interleaves the binary digits of their coordinates. It is easy to compute and widely used for indexing, but it jumps: halfway along, one step goes from the rightmost column to the leftmost. Some map formats number tiles in Hilbert order, so consecutive tile IDs at one zoom level follow neighbouring tiles.
Things to notice
- Every order you can draw misses almost every point of the square; only the limit curve fills it.
- The limit is still a curve, a continuous image of a line segment, yet it covers an area: the parameter is one-dimensional, the image is the whole square.
Related
- Dragon curvePlanned
- Koch snowflake
- Mandelbrot set
Further reading: Wikipedia: Hilbert curve; Wikipedia: Space-filling curve; MacTutor History of Mathematics: Giuseppe Peano.