Hilbert 2D
Rust functions for mapping between 1D and 2D space using the Hilbert curve, and its approximations.
Usage
Add this to your Cargo.toml
:
[]
= "1.1.0"
When working with images and matrices, use the h2xy_discrete
and xy2h_discrete
functions:
use ;
let = h2xy_discrete; // (1, 2)
let h = xy2h_discrete; // 13
When performing real-valued calculations, use the continuous functions instead:
use ;
// Approaches the bottom-left corner
let = h2xy_continuous_f64;
// Approaches the bottom-right corner
let = h2xy_continuous_f64;
Some of the pattern variants of the Hilbert curve have also been implemented:
use ;
// In the Liu L1 variant, both ends of the curve approach the center of the square
let = h2xy_continuous_f64; // (~0.5, ~0.5)
let = h2xy_continuous_f64; // (~0.5, ~0.5)
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.