.TH "ttypt/morton.h" 3 "islet" \" -*- nroff -*- .ad l .nh .SH NAME ttypt/morton.h \- Morton code (Z-order) encoding and decoding utilities\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br .SS "Functions" .in +1c .ti -1c .RI "static uint64_t \fBmorton_set_1\fP (int16_t *p)" .br .RI "Encode multi-dimensional coordinates into Morton codes\&. " .ti -1c .RI "static uint64_t \fBmorton_set_2\fP (int16_t *p)" .br .RI "Encode a 2D point\&. See \fBmorton_set_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBmorton_set_3\fP (int16_t *p)" .br .RI "Encode a 3D point\&. See \fBmorton_set_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBmorton_set_4\fP (int16_t *p)" .br .RI "Encode a 4D point\&. See \fBmorton_set_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBmorton_set_2_32\fP (int32_t *p)" .br .RI "Encode a 2D x 32-bit point\&. Dense full-64-bit layout (2 x 32 bits); part of the dense config family, not the legacy 16-bit-lane sparse layout that \fBmorton_set_2()\fP uses\&. " .ti -1c .RI "static void \fBmorton_get_1\fP (int16_t *pos, uint64_t code)" .br .RI "Decode a Morton code into a multi-dimensional coordinate\&. " .ti -1c .RI "static void \fBmorton_get_2\fP (int16_t *pos, uint64_t code)" .br .RI "Decode a 2D Morton code\&. See \fBmorton_get_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBmorton_get_3\fP (int16_t *pos, uint64_t code)" .br .RI "Decode a 3D Morton code\&. See \fBmorton_get_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBmorton_get_4\fP (int16_t *pos, uint64_t code)" .br .RI "Decode a 4D Morton code\&. See \fBmorton_get_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBmorton_get_2_32\fP (int32_t *pos, uint64_t code)" .br .RI "Decode a 2D x 32-bit Morton code\&. Inverse of \fBmorton_set_2_32()\fP\&. " .in -1c .SH "Detailed Description" .PP Morton code (Z-order) encoding and decoding utilities\&. Morton codes, also known as Z-order codes, are a way to map multi-dimensional coordinates to a single dimension while preserving spatial locality\&. They interleave the binary representations of each coordinate dimension, creating a space-filling curve that visits all points in a recursive Z pattern\&. .PP Benefits: .IP "\(bu" 2 Preserves spatial locality: nearby points in N-D space have nearby Morton codes .IP "\(bu" 2 Enables efficient range queries on 1D data structures (hash tables, B-trees) .IP "\(bu" 2 Simple bitwise operations for encoding/decoding .PP .PP This implementation is optimized for 3D coordinates (int16_t per dimension) and produces 64-bit Morton codes (48 bits used for 3D, 16 bits reserved)\&. 4D coordinates use a dense stride-4 packing that fills all 64 bits\&. The 2D x 32-bit config (int32_t per dimension) is the dense stride-2 partner: 2 x 32 = 64 bits, no reserved bits\&. .PP Prefer the config objects (\fBpointcfg\&.h\fP: Point1_2\&.\&.Point4_2, Point2_4) in application code; these inlines remain the tight-loop fast path\&. .PP References: .IP "\(bu" 2 Morton, G\&.M\&. (1966)\&. "A computer Oriented Geodetic Data Base" .IP "\(bu" 2 http://www.vision-tools.com/h-tropf/multidimensionalrangequery.pdf .IP "\(bu" 2 https://en.wikipedia.org/wiki/Z-order_curve .PP .PP \fBSee also\fP .RS 4 \fBIslet core API\fP .RE .PP .SH "Author" .PP Generated automatically by Doxygen for islet from the source code\&.