# Programming the Hilbert curve

• Published in 2004
In the collections
The Hilbert curve has previously been constructed recursively, using $p$ levels of recursion of $n$‐bit Gray codes to attain a precision of $p$ bits in $n$ dimensions. Implementations have reflected the awkwardness of aligning the recursive steps to preserve geometrical adjacency. We point out that a single global Gray code can instead be applied to all $np$ bits of a Hilbert length. Although this “over‐transforms” the length, the excess work can be undone in a single pass over the bits, leading to compact and efficient computer code.

### BibTeX entry

@article{ProgrammingtheHilbertcurve,
title = {Programming the Hilbert curve},
abstract = {The Hilbert curve has previously been constructed recursively, using $p$ levels of recursion of $n$‐bit Gray codes to attain a precision of $p$ bits in $n$ dimensions. Implementations have reflected the awkwardness of aligning the recursive steps to preserve geometrical adjacency. We point out that a single global Gray code can instead be applied to all $np$ bits of a Hilbert length. Although this “over‐transforms” the length, the excess work can be undone in a single pass over the bits, leading to compact and efficient computer code.},
url = {https://aip.scitation.org/doi/abs/10.1063/1.1751381},
year = 2004,
author = {John Skilling},
comment = {},
urldate = {2021-02-12},
collections = {basically-computer-science,things-to-make-and-do}
}