A Cube-filling Hilbert Curve

William Gilbert

Pure Mathematics Department, University of Waterloo, Ontario, Canada

Mathematical Intelligencer 6(3) (1984), page 78

First Iterate [2kb] Second Iterate [9kb] Third Iterate [15kb]

In 1891 David Hilbert gave a simple construction of a Peano curve whose limit filled a square. We exhibit a direct generalization of Hilbert's curve that fills a cube. The first three iterates of this curve are shown. In constructing one iterate from the previous one, note that the direction of the curve determines the orientation of the smaller cubes inside the larger one.

The initial stage of this three dimensional curve can be considered as coming from the 3-bit reflected Gray code which traverses the 3-digit binary strings in such a way that each string differs from its predecessor in a single position by the addition or subtraction of 1. The kth iterate could be considered a a generalized Gray code on the Cartesian product set {0,1,2,...,2^k-1}^3.

The n-bit reflected binary Gray code will describe a path on the edges of an n-dimensional cube that can be used as the initial stage of a Hilbert curve that will fill an n-dimensional cube.


E. N. Gilbert, (1958) Gray codes and the paths on the n-cube. Bell System Tech. J. 37 pp. 815-826.

Notes on A Cube-filling Hilbert Curve

This cube-filling Hilbert curve was also produced independently by See also Here is an ASCII text-graphic of the cube-filling Hilbert curve that was posted to the FRAC-L fractal discussion list.
Back to the home page of William Gilbert
Back to the entrance of the Fractal Gallery of William Gilbert
This page was last updated on 19 September 2006 by W. Gilbert