designcoding
About Table of Contents Keywords Monthly Archive
Support designcoding!

Hilbert Curve

January 16, 2024 | Algorithms
#fractal #hilbert #rhino-python #space-filling

The Hilbert Curve, also referred to as the Hilbert space-filling curve, was initially introduced by the German mathematician David Hilbert in 1891. It is a continuous fractal curve, presenting a variation of the space-filling Peano curves uncovered by Giuseppe Peano in 1890. After a study on the mathematical background of this curve, I implemented a Python code into Grasshopper Python. However, I wanted to explore more variations by playing with the algorithm. This is why, the resulting Grasshopper definition can generate interesting curves based on the logic of the original Hilbert Curve. Thanks to the quick and easy workflow of Grasshopper, I was able to connect the inputs and take the following animation in Rhinoceros. You can extend this study into more complex and 3d objects by further developing the Grasshopper definition.

Hilbert Curve animation

This Grasshopper definition generates the Hilbert Curve along with some variations, based on the input parameters. You can control the number of iterations and several other parameters. It is possible to generate the original curve and explore different designs. The output of the definition is a single 2D polyline. The code is using native Grasshopper components with one Grasshopper Python code. So, you don’t need extra add-ons. This simple tool is useful if you are planning to generate space-filling fractals.

import rhinoscriptsyntax as rs
S = "A"
for _ in range(N):
	ns = ""
	for char in S:
		if char == "A":
			ns += "-BF+AFA+FB-"
		elif char == "B":
			ns += "+AF-BFB-FA+"
		else:
			ns += char
	S = ns
V = []
cursor = rs.AddPoint([0,0,0])
dir = rs.VectorCreate([0,0,0],[1,0,0])
V.append(cursor)
for char in S:
	if char == "F":
		new = rs.CopyObject(cursor,dir)
		V.append(new)
		cursor = new
	if char == "+":
		dir = rs.VectorRotate(dir,a,[0,0,1])
	if char == "-":
		dir = rs.VectorRotate(dir,-b,[0,0,1])
C = rs.AddPolyline(V)
Hilbert Curve fractal, hilbert
Grasshopper definition (GH)Download

Cite this post

Yazar, T. (2024, January 16). Hilbert Curve. designcoding. Retrieved August 24, 2026, from https://www.designcoding.net/hilbert-curve/

Related Posts

Why is the Hilbert Curve Beautiful?

April 8, 2025

The Hilbert Curve is one of the results of David Hilbert’s vision of mathematics as a network of symbolic systems. Defined in 1891, this curve is a fractal that fills a two-dimensional plane with a one-dimensional line in the limit. It exhibits self-similarity. It emerged from representing higher-dimensional spaces through continuous, lower-dimensional entities. A curve that grows within a bounded area remains continuous but non-differentiable. Yet it possesses infinite length. Perhaps no one will ever truly see or fully grasp…

Polygon Fractals with Rhino Python

August 2, 2017

We will see a simple Rhino Python exercise here. I called these Polygon Fractals (or Pentaflakes sometimes). It is both educational and fun to play with them. In Rhino, it can be a good exercise for basic CAD commands and transformations such as move, copy, and scale, and precision drawing operations such as object snapping. Also, in Grasshopper, it can be a good challenge for looping. In Rhino Python, it is already a good exercise for understanding Python and the…

Fractal Curves with Rhino Python

July 31, 2017

A simple Rhino Python script that generates fractal curves. An example is a test with the Gosper-Peano curve. However the script is not supporting segment directions, which is why the result is not the intended curve. Curve directions could be implemented in the future.

Space-filling Elongated Dodecahedra

February 22, 2024

The regular dodecahedron is one of the five Platonic solids, characterized by having 12 regular pentagonal faces, 20 vertices, and 30 edges. When you elongate it, you extend its structure in one or more directions, resulting in a shape that retains the basic properties of the dodecahedron but is stretched out. The elongated dodecahedron might not catch your eye at first—it’s just a long version of a shape you’ve probably seen before, and it seems pretty basic. But don’t be…

Space-filling Rhombic Dodecahedra

February 10, 2024

The rhombic dodecahedron is a polyhedron with twelve rhombus-shaped faces, where each face has four sides of equal length. It is possible to construct the space-filling variant of the rhombic dodecahedron by arranging multiple such rhombic dodecahedra in a regular pattern so that they fill space without leaving any gaps. In his 1611 work on snowflakes titled “Strena seu de Nive Sexangula,” Johannes Kepler observed that honey bees utilize the geometric structure of rhombic dodecahedra to construct honeycombs. These honeycombs…

  • Chapters

    • Algorithms
    • Discourses
    • Fabrications
    • Studios
  • Explore

    • All Keywords
    • Table of Contents
    • Monthly Archive
    • #grasshopper
    • #tutorial
    • #polyhedra
    • #rhinoceros
    • #dodecahedron
    • #parametric-curve
    • #bezier-curve
    • #structure
    • #anemone
    • #design-object
    • #simulation
    • #polygon
    • #euclidean-construction
    • #koch
    • #gosper-curve
    • #platonic-solid
    • #design-education
    • #linear-algebra
    • #dual
    • #art
  • Search

  • Support designcoding!

  • Enjoying designcoding? Support me on Patreon to keep it growing. Thank you!

  • copyright 2026 designcoding.net | about | privacy policy | end user license agreement