WOLFRAM

gives the line segments representing the n^(th)-step Hilbert curve.

gives the n^(th)-step Hilbert curve in dimension d.

Details and Options

  • HilbertCurve is also known as Hilbert space-filling curve.
  • HilbertCurve[n] returns a Line primitive corresponding to a path that starts at {0,0}, then joins all integer points in the 2n-1 by 2n-1 square, and ends at {2n-1,0}. »
  • HilbertCurve takes a DataRange option that can be used to specify the range the coordinates should be assumed to occupy.

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

A 2D Hilbert curve:

Out[1]=1

Lengths of the approximations to the Hilbert curve:

Out[2]=2

The formula:

Out[3]=3

Visualize the Hilbert curve in 2D with splines:

Out[1]=1

Scope  (8)Survey of the scope of standard use cases

Curve Specification  (4)

A 2D Hilbert curve:

Out[1]=1

A 3D Hilbert curve:

Out[1]=1

An D Hilbert curve:

The ^(th) approximation of the Hilbert curve:

Out[1]=1

Curve Styling  (4)

Hilbert curves with different thicknesses:

Out[1]=1
Out[2]=2

Thickness in scaled size:

Out[1]=1

Thickness in printer's points:

Out[2]=2

Dashed curves:

Out[1]=1
Out[2]=2

Colored curves:

Out[1]=1

Generalizations & Extensions  (2)Generalized and extended use cases

Hilbert curve in 4D:

Hilbert curve in D:

Out[1]=1

Options  (1)Common values & functionality for each option

DataRange  (1)

DataRange allows you to specify the range of mesh coordinates to generate:

Out[1]=1

Specify a different range:

Out[2]=2

Applications  (4)Sample problems that can be solved with this function

HilbertCurve is constructed recursively by transforming cups into four cups linked together by lines:

Out[2]=2

Next iteration:

Out[4]=4

Visualize the Hilbert curve in 2D:

Out[1]=1

With splines:

Out[2]=2

In 3D:

Out[3]=3

With tubes:

Out[4]=4

Build a polygon from the Hilbert curve:

Out[1]=1

Apply a Hilbert curve texture to a surface:

Out[1]=1

Properties & Relations  (3)Properties of the function, and connections to other functions

HilbertCurve consists of lines:

Out[1]=1

Find the perimeter of the 2D Hilbert curve:

Out[1]=1
Out[2]=2
Out[3]=3

3D Hilbert curve:

Out[4]=4
Out[5]=5
Out[6]=6

DataRangerange is equivalent to using RescalingTransform[{},range]:

Out[1]=1

Use RescalingTransform:

Out[3]=3

Possible Issues  (2)Common pitfalls and unexpected behavior

By default, the coordinates of the Hilbert curve are not in the unit square:

Out[1]=1

Using DataRange to generate the Hilbert curve in the unit square:

Out[2]=2

HilbertCurve can be too large to generate:

Out[1]=1

Neat Examples  (1)Surprising or curious use cases

Traversal animations:

Out[1]=1
Wolfram Research (2017), HilbertCurve, Wolfram Language function, https://reference.wolfram.com/language/ref/HilbertCurve.html.
Wolfram Research (2017), HilbertCurve, Wolfram Language function, https://reference.wolfram.com/language/ref/HilbertCurve.html.

Text

Wolfram Research (2017), HilbertCurve, Wolfram Language function, https://reference.wolfram.com/language/ref/HilbertCurve.html.

Wolfram Research (2017), HilbertCurve, Wolfram Language function, https://reference.wolfram.com/language/ref/HilbertCurve.html.

CMS

Wolfram Language. 2017. "HilbertCurve." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HilbertCurve.html.

Wolfram Language. 2017. "HilbertCurve." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HilbertCurve.html.

APA

Wolfram Language. (2017). HilbertCurve. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HilbertCurve.html

Wolfram Language. (2017). HilbertCurve. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HilbertCurve.html

BibTeX

@misc{reference.wolfram_2025_hilbertcurve, author="Wolfram Research", title="{HilbertCurve}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/HilbertCurve.html}", note=[Accessed: 25-March-2025 ]}

@misc{reference.wolfram_2025_hilbertcurve, author="Wolfram Research", title="{HilbertCurve}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/HilbertCurve.html}", note=[Accessed: 25-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_hilbertcurve, organization={Wolfram Research}, title={HilbertCurve}, year={2017}, url={https://reference.wolfram.com/language/ref/HilbertCurve.html}, note=[Accessed: 25-March-2025 ]}

@online{reference.wolfram_2025_hilbertcurve, organization={Wolfram Research}, title={HilbertCurve}, year={2017}, url={https://reference.wolfram.com/language/ref/HilbertCurve.html}, note=[Accessed: 25-March-2025 ]}