Skip to content

Java library to encode/decode Morton codes (Z-order curve)

License

Notifications You must be signed in to change notification settings

eren-ck/MortonLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MortonLib

Java library to encode/decode Morton codes (Z-order curve). The library maps 2D/3D data to one dimension. This encoding can be used to store the data in various data structures (hash tables, B-trees, ..). The Z-ordering is often used to build quadtrees of point sets.

More information: Z-order curve

Usage

Morton2D mortonTest = new Morton2D();

//range for (x,y) is (0,0) to (16777215,16777215) 
long mortonCode = mortonTest.encode(15, 3);          // => 95

int[] xy = mortonTest.decode(mortonCode); 			// => [15,3]
Morton3D mortonTest = new Morton3D();

//range for (x,y,z) is (0,0,0) to (2097151,2097151,2097151) 
long mortonCode = mortonTest.encode(15, 15, 15); //4095

int xyz[] = mortonTest.decode(mortonCode); // => [15,15,15]

Source

Bit Twiddling Hacks

libmorton

License

MIT licensed

About

Java library to encode/decode Morton codes (Z-order curve)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages