Skip to main content

Module space_filling

Module space_filling 

Source
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^order cube.
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^order square 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^order grid 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^order grid 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^order grid as unit-square points.