becheran/fast-hilbert

Fast Hilbert space-filling curve transformation using a LUT

Rust

60

73 commits

updated Jun 25, 2026

See the code

README

Fast Hilbert

Build Status doc crates.io usage license

Fast Hilbert 2D curve computation using an efficient Lookup Table (LUT) and only considering the lowest order for a given input.

h1 h2 h3 h4 h5 h6

  • Convert from discrete 2D space to 1D hilbert space and reverse
  • Generalized for different unsigned integer input types (thanks DoubleHyphen PR#3)
  • Speedup via lowest order computation (thanks DoubleHyphen PR#2)
  • Checked versions available on checked feature (thanks FeeFladder PR#21)
  • Very fast using an efficient 512 Byte LUT
  • No additional dependency

Benchmarking the conversion from full 256x256 discrete 2D space to the 1D hilbert space, shows that fast_hilbert more than twice as fast compared to the fastest 2D hilbert transformation libs written in rust. Benchmarked on a Intel i5-6400 CPU @ 2.70 GHz, 4 Cores with 8 GB RAM:

LibraryTimeDescription
fast_hilbert0.7 msOptimized for fast computation in 2D discrete space using an efficient LUT
hilbert_2d2.5 msAlso allows other variants such as Moore and LIU
hilbert_curve2.0 msImplements algorithm described on Wikipedia
hilbert32.1 msAllows computation of higher dimensional Hilbert curves

Especially for higher orders fast_hilbert outperforms other libraries by using only the next lowest relevant order instead of computing the hilbert curve bit per bit for the given input. See PR #2 and #9 for more details.

For example the computation of xy2h(1, 2, 64) is very fast to compute using fast_hilbert compared to a higher x,y pair such as xy2h(u32::MAX-1, u32::MAX-2, 64):

Libraryx=1, y=2, order=64x=u32::MAX-1, y=u32::MAX-2, order=64
fast_hilbert4 ns32 ns
hilbert_2d73 ns72 ns
hilbert_curve67 ns49 ns
hilbert690 ns680 ns
benchmarking
fractal
hilbert
lut
rust
space-filling-curves

Contributors

becheran

53 commits

feefladder

6 commits

finnbear

4 commits

becheran/fast-hilbert

Fast Hilbert space-filling curve transformation using a LUT

Rust

60

73 commits

updated Jun 25, 2026

See the code

README

Fast Hilbert

Build Status doc crates.io usage license

Fast Hilbert 2D curve computation using an efficient Lookup Table (LUT) and only considering the lowest order for a given input.

h1 h2 h3 h4 h5 h6

  • Convert from discrete 2D space to 1D hilbert space and reverse
  • Generalized for different unsigned integer input types (thanks DoubleHyphen PR#3)
  • Speedup via lowest order computation (thanks DoubleHyphen PR#2)
  • Checked versions available on checked feature (thanks FeeFladder PR#21)
  • Very fast using an efficient 512 Byte LUT
  • No additional dependency

Benchmarking the conversion from full 256x256 discrete 2D space to the 1D hilbert space, shows that fast_hilbert more than twice as fast compared to the fastest 2D hilbert transformation libs written in rust. Benchmarked on a Intel i5-6400 CPU @ 2.70 GHz, 4 Cores with 8 GB RAM:

LibraryTimeDescription
fast_hilbert0.7 msOptimized for fast computation in 2D discrete space using an efficient LUT
hilbert_2d2.5 msAlso allows other variants such as Moore and LIU
hilbert_curve2.0 msImplements algorithm described on Wikipedia
hilbert32.1 msAllows computation of higher dimensional Hilbert curves

Especially for higher orders fast_hilbert outperforms other libraries by using only the next lowest relevant order instead of computing the hilbert curve bit per bit for the given input. See PR #2 and #9 for more details.

For example the computation of xy2h(1, 2, 64) is very fast to compute using fast_hilbert compared to a higher x,y pair such as xy2h(u32::MAX-1, u32::MAX-2, 64):

Libraryx=1, y=2, order=64x=u32::MAX-1, y=u32::MAX-2, order=64
fast_hilbert4 ns32 ns
hilbert_2d73 ns72 ns
hilbert_curve67 ns49 ns
hilbert690 ns680 ns
benchmarking
fractal
hilbert
lut
rust
space-filling-curves

Contributors

becheran

53 commits

feefladder

6 commits

finnbear

4 commits

Languages

Rust

100.0%