hbertoduarte / hilbert_2d

Rust functions for mapping between 1D and 2D space using the Hilbert curve, and its approximations.
Apache License 2.0
8 stars 1 forks source link

Consider limiting the order for continuous (f32,f32)->(f32) mapping #2

Open swfsql opened 1 year ago

swfsql commented 1 year ago

Thanks for your work, this is a very interesting project!

I'm not sure if my thinking is correct, so I'd like to ask you if it would make sense to limit the maximum order for continuous mappings.

For the f32 mapping, the macro defining that aspects expands into:

pub(crate) const ORDER_MAX: u32 = U32_BITS / 2;

In which case the ORDER_MAX would be 16.

But in reality the maximum integer precision for f32 is 16777216 = 4096² which would indicate an order of 12. After 4096² the f32 no longer can represent odd integers so I'm not sure if it would be a viable tradeoff, on continuing the hilbert approximation vs start losing integer-precision indexing.

Then again I'm not sure if I'm missing something, but I thought of making this suggestion nevertheless. Thanks once again!