ttypt/morton.h(3)islet

NAME

ttypt/morton.h - Morton code (Z-order) encoding and decoding utilities.

SYNOPSIS

#include <stdint.h>
#include <limits.h>

Functions

static uint64_t morton_set_1 (int16_t *p)

Encode multi-dimensional coordinates into Morton codes.

static uint64_t morton_set_2 (int16_t *p)

Encode a 2D point. See morton_set_1() for the family docs.

static uint64_t morton_set_3 (int16_t *p)

Encode a 3D point. See morton_set_1() for the family docs.

static uint64_t morton_set_4 (int16_t *p)

Encode a 4D point. See morton_set_1() for the family docs.

static uint64_t morton_set_2_32 (int32_t *p)

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 morton_set_2() uses.

static void morton_get_1 (int16_t *pos, uint64_t code)

Decode a Morton code into a multi-dimensional coordinate.

static void morton_get_2 (int16_t *pos, uint64_t code)

Decode a 2D Morton code. See morton_get_1() for the family docs.

static void morton_get_3 (int16_t *pos, uint64_t code)

Decode a 3D Morton code. See morton_get_1() for the family docs.

static void morton_get_4 (int16_t *pos, uint64_t code)

Decode a 4D Morton code. See morton_get_1() for the family docs.

static void morton_get_2_32 (int32_t *pos, uint64_t code)

Decode a 2D x 32-bit Morton code. Inverse of morton_set_2_32().

Detailed Description

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.

Benefits:

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.

Prefer the config objects (pointcfg.h: Point1_2..Point4_2, Point2_4) in application code; these inlines remain the tight-loop fast path.

References:

See also

Islet core API

Author

Generated automatically by Doxygen for islet from the source code.