- Hilbert curve
A Hilbert curve (also known as a Hilbert space-filling curve) is a continuous
fractal space-filling curve first described by the German mathematicianDavid Hilbert in1891 . [D. Hilbert: Über die stetige Abbildung einer Linie auf ein Flächenstück. Math. Ann. 38 (1891 ), 459–460.]Because it is space-filling, its
Hausdorff dimension (in the limit ) is .
The Euclidean length of is , i.e., it grows exponentially with .For multidimensional databases, Hilbert order has been proposed to be used instead of Z order because it has better locality-preserving behavior.
Representation as Lindenmayer system
The Hilbert Curve can be expressed by a rewrite system (
L-system ).:Alphabet : L, R:Constants : F, +, −:Axiom : L :Production rules: : L → +RF−LFL−FR+ : R → −LF+RFR+FL−
Here, "F" means "draw forward", "+" means "turn left 90°", and "−" means "turn right 90°" (see
turtle graphics ).Computer program
Butz [A.R. Butz: Alternative algorithm for Hilbert’s space filling curve. IEEE Trans. On Computers, 20:424-42, April 1971.] provided an algorithm for calculating the Hilbert curve in multidimensions.
The following Java
applet draws a Hilbert curve by means of four methods that recursively call one another:And here is another version that directly implements the representation as a
Lindenmayer system :
This is written using the [http://bagotricks.com/projects/tugaturtle/ Tuga Turtle] programming system, which is built on
def f walk 10 end def p turn 90 end def m turn -90 end def l(n) return if n=0 p; r(n-1); f; m; l(n-1); f; l(n-1); m; f; r(n-1); p end def r(n) return if n=0 m; l(n-1); f; p; r(n-1); f; r(n-1); p; f; l(n-1); m end l(6)JRuby . It requires Java 5 or higher. To execute, run Tuga Turtle [http://bagotricks.com/projects/tugaturtle/tugaturtle.jnlp] by accepting the self-signed certificate, copy-paste the above code to replace the code in the left-hand pane, and press "Go". You will see a sixth-order Hilbert curve being drawn by the turtle on the screen.What follows is an example of how to draw the Hilbert curve in the Logo programming language. The code involves a parity variable to indicate whether the curve being drawn is a right-hand Hilbert curve or a left-hand Hilbert curve. The parity is a multiplication of the drawing direction by −1 (negative one). This leads to the realization that the right-hand curve is symmetrical to the left-hand curve.
An example of invoking the curve is:hilbert 200 5
References
See also
* [http://tog.acm.org/GraphicsGems/gemsii/Hilbert.c Hilbert Curve generation code from Graphics Gems 2]
*Sierpiński curve
*z-order (curve)
*Moore curve
*List of fractals by Hausdorff dimension
Wikimedia Foundation. 2010.