/fast-hilbert

Fast Hilbert space-filling curve transformation using a LUT

Primary LanguageRustMIT LicenseMIT

Fast Hilbert

Build Status doc crates.io usage license

Fast Hilbert 2D curve computation using an efficient Lookup Table (LUT) and fast "orientation-stable encoding". The curve is slightly different compared to the original hilbert curve. Every odd iteration is oriented by 90 degrees:

h1 h2 h3 h4 h5 h6

  • Orientation-stable encoding (all credits to DoubleHyphen see this PR for more information)
  • Convert from discrete 2D space to 1D hilbert space and reverse
  • No order or iteration input required
  • Very fast using an efficient 512 Byte LUT
  • Only one additional dependency.

Benchmarking the conversion from full 256x256 discrete 2D space to the 1D hilbert space, shows that fast_hilbert is about 12 times faster 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:

Library Time Description
fast_hilbert 0.2 ms Optimized for fast computation in 2D discrete space using an efficient LUT
hilbert_2d 2.5 ms Also allows other variants such as Moore and LIU
hilbert_curve 2.0 ms Implements algorithm described on Wikipedia
hilbert 32.1 ms Allows computation of higher dimensional Hilbert curves