While transformation of 3D coordinates to a z-order curve was relatively straightforward (Efficient z-order transformation in Fortran) I am having difficulties to wrap my head around around the math for using different space-filling curves, for example Peano or Hilbert. Any hints on how an actual code to do the transformation might look like would be appreciated. The goal is to have a subroutine that takes xyz coordinates as an input with whatever normalization is necessary and returns the index of the space-filling curve.
subroutine(x, y, z, space_filling_index)
And related to this: I read that there are many ways to define Hilbert curves in 3D space, which would be best in terms of locality? If there is a definitive answer to this...
The application would be a reordering of cells in a Cartesian computational grid with the goal of increasing cache hits when a cell accesses its neighbors cells.