Expand description
Space-filling curves and locality-preserving orders: Hilbert (2-D and 3-D), Peano, Morton/Z-order, Gray codes, and L-system curves (Sierpiński arrowhead, Moore, Gosper).
Functions§
- gosper_
curve - Gosper (flowsnake) curve, unit steps.
- gray_
code - Binary reflected Gray code.
- gray_
decode - Inverse Gray code (prefix xor by doubling).
- hilbert_
3d_ d2xyz - 3-D Hilbert index to grid coordinates on a
2^ordercube. - hilbert_
3d_ xyz2d - 3-D grid coordinates to Hilbert index (inverse of
hilbert_3d_d2xyz). - hilbert_
curve_ 2d - The full Hilbert curve as points in the unit square (cell centers), in curve order.
- hilbert_
curve_ 3d - The 3-D Hilbert curve as points in the unit cube, in curve order.
- hilbert_
d2xy - Hilbert curve index to grid coordinates on a
2^ordersquare grid (Wikipedia’s iterative rotate-and-flip formulation). - hilbert_
locality_ ratio - Locality measure of the Hilbert order: mean |index difference| (normalized by the index range) divided by mean spatial distance (normalized by the bounding-box diagonal) over all point pairs. Lower means indices track spatial proximity better.
- hilbert_
xy2d - Grid coordinates to Hilbert index (inverse of
hilbert_d2xy). - moore_
curve - Moore curve: the closed variant of the Hilbert curve (last point adjacent to the first), unit grid steps.
- morton_
decode_ 2d - Inverse of
morton_encode_2d. - morton_
decode_ 3d - Inverse of
morton_encode_3d. - morton_
encode_ 2d - Interleaves the bits of x (even positions) and y (odd positions).
- morton_
encode_ 3d - Interleaves 21 bits each of x, y, z.
- peano_
curve - Peano curve on a
3^ordergrid via the ternary digit formula (Peano 1890): points in the unit square in curve order. - sierpinski_
curve - Sierpiński arrowhead curve (traverses the Sierpiński triangle), unit steps from the origin.
- sort_
by_ hilbert - Sorts points by their Hilbert index on a
2^ordergrid over the bounding box. - sort_
by_ morton - Sorts 3-D points by Morton code (21 bits per axis over the bounding box).
- z_
order_ curve - The Z-order (Morton) traversal of a
2^ordergrid as unit-square points.