Hilbert Curve

Rather astonishingly, curves exist that fill the plane without leaving any gaps. One such curve is the Hilbert curve. If that isn't enough, it can also be proven that these curves are self-intersecting. The following represents the nth approximation of a Hilbert curve for a square. With higher values of n, more of the square is filled.

Jolly good, but does this have any real-world applications? Why, yes! The Hilbert curve is a mapping between 1D and 2D space that preserves locality quite well. This means that points near each other in terms of distance along the curve will also be near each other on the 2D plane. For example, colours of the rainbow can be plotted such that similar colours are always near each other. Click show colours to see a demonstration below.

:

Further Reading