@@ -2585,6 +2585,95 @@ def ijk(self) -> JaggedTensor:
25852585 """
25862586 return JaggedTensor (impl = self ._impl .ijk )
25872587
2588+ def morton (self , offset : NumericMaxRank1 | None = None ) -> JaggedTensor :
2589+ """
2590+ Return Morton codes (Z-order curve) for active voxels in this grid batch.
2591+
2592+ Morton codes use xyz bit interleaving to create a space-filling curve that
2593+ preserves spatial locality. This is useful for serialization, sorting, and
2594+ spatial data structures.
2595+
2596+ Args:
2597+ offset: Optional offset to apply to voxel coordinates before encoding.
2598+ If None, uses the negative minimum coordinate across all voxels.
2599+
2600+ Returns:
2601+ JaggedTensor: A JaggedTensor of shape `[num_grids, -1, 1]` containing
2602+ the Morton codes for each active voxel in the batch.
2603+ """
2604+ if offset is None :
2605+ offset = - torch .min (self .ijk .jdata , dim = 0 ).values
2606+ else :
2607+ offset = to_Vec3i (offset )
2608+
2609+ return self ._impl .morton (offset )
2610+
2611+ def morton_zyx (self , offset : NumericMaxRank1 | None = None ) -> JaggedTensor :
2612+ """
2613+ Return transposed Morton codes (Z-order curve) for active voxels in this grid batch.
2614+
2615+ Transposed Morton codes use zyx bit interleaving to create a space-filling curve.
2616+ This variant can provide better spatial locality for certain access patterns.
2617+
2618+ Args:
2619+ offset: Optional offset to apply to voxel coordinates before encoding.
2620+ If None, uses the negative minimum coordinate across all voxels.
2621+
2622+ Returns:
2623+ JaggedTensor: A JaggedTensor of shape `[num_grids, -1, 1]` containing
2624+ the transposed Morton codes for each active voxel in the batch.
2625+ """
2626+ if offset is None :
2627+ offset = - torch .min (self .ijk .jdata , dim = 0 ).values
2628+ else :
2629+ offset = to_Vec3i (offset )
2630+
2631+ return self ._impl .morton_zyx (offset )
2632+
2633+ def hilbert (self , offset : NumericMaxRank1 | None = None ) -> JaggedTensor :
2634+ """
2635+ Return Hilbert curve codes for active voxels in this grid batch.
2636+
2637+ Hilbert curves provide better spatial locality than Morton codes by ensuring
2638+ that nearby points in 3D space are also nearby in the 1D curve ordering.
2639+
2640+ Args:
2641+ offset: Optional offset to apply to voxel coordinates before encoding.
2642+ If None, uses the negative minimum coordinate across all voxels.
2643+
2644+ Returns:
2645+ JaggedTensor: A JaggedTensor of shape `[num_grids, -1, 1]` containing
2646+ the Hilbert codes for each active voxel in the batch.
2647+ """
2648+ if offset is None :
2649+ offset = - torch .min (self .ijk .jdata , dim = 0 ).values
2650+ else :
2651+ offset = to_Vec3i (offset )
2652+
2653+ return self ._impl .hilbert (offset )
2654+
2655+ def hilbert_zyx (self , offset : NumericMaxRank1 | None = None ) -> JaggedTensor :
2656+ """
2657+ Return transposed Hilbert curve codes for active voxels in this grid batch.
2658+
2659+ Transposed Hilbert curves use zyx ordering instead of xyz. This variant can
2660+ provide better spatial locality for certain access patterns.
2661+
2662+ Args:
2663+ offset: Optional offset to apply to voxel coordinates before encoding.
2664+ If None, uses the negative minimum coordinate across all voxels.
2665+
2666+ Returns:
2667+ JaggedTensor: A JaggedTensor of shape `[num_grids, -1, 1]` containing
2668+ the transposed Hilbert codes for each active voxel in the batch.
2669+ """
2670+ if offset is None :
2671+ offset = - torch .min (self .ijk .jdata , dim = 0 ).values
2672+ else :
2673+ offset = to_Vec3i (offset )
2674+
2675+ return self ._impl .hilbert_zyx (offset )
2676+
25882677 @property
25892678 def jidx (self ) -> torch .Tensor :
25902679 """
0 commit comments