2D Encoding & Decoding
Map a pair of 32-bit integer indexes to a single 64-bit Morton code and back with morton2D / demorton2D.
A pure Fortran 2003+ library to encode and decode multidimensional integer indexes into Morton's Z-order.
Encode a 3D index tuple and decode it back:
use, intrinsic :: iso_fortran_env, only : int32, int64
use mortif
integer(int32) :: i, j, k
integer(int64) :: code
! Encode
code = morton3D(i=1_int32, j=2_int32, k=3_int32)
print '(A,I20)', "Morton code of {1,2,3}: ", code
! Decode
call demorton3D(code=code, i=i, j=j, k=k)
print '(A,3(I0,1X))', "Decoded indexes: ", i, j, kuse, intrinsic :: iso_fortran_env, only : int32, int64
use mortif
integer(int64) :: code
! 2D example
code = morton2D(i=0_int32, j=1_int32)
print '(A,I20)', "Morton code of {0,1}: ", code ! 2Contributions are welcome โ see the Contributing page.
MORTIF is distributed under a multi-licensing system:
| Use case | License |
|---|---|
| FOSS projects | GPL v3 |
| Closed source / commercial | BSD 2-Clause |
| Closed source / commercial | BSD 3-Clause |
| Closed source / commercial | MIT |
Anyone interested in using, developing, or contributing to MORTIF is welcome โ pick the license that best fits your needs.