简体   繁体   中英

Z Order Curve java implementation

Can any point me to the Java code for Z-order curve implementation? I have x,y floating point coordinates and I want a single dimensional representation for them, which I know is possible using Z-order curve transformation. I am unable to find a Java implementation or a C code for this function.

I will great appreciate any help on this!!

GridKit has a Z-Order implementation according to koders . There is also STANN for nearest neighbour searches on point clouds, if you accept c++ as well.

I'd write this myself.

First convert from float to integer, by computing both exponents using Math.getExponent and taking the maximum of these. Then you can scale the numbers such that the larger of these numbers has 32 bits before the decimal point. Then round (or truncate) the results to int. Then you'll have to combine those two integers into a single long using bit-interleaving, and finally you can scale the result again using the stored exponent.

If your input already is restricted to eg the [0,1] range, you can simply use fixed-point arithmetic based on integers instead of this manual rescaling.

To do the bit interleaving, I'd use a lookup map which eg takes a block of 8 bits and computes the corresponding 16 bit interleaved block. That way you won't have to do too many bit shift operations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM