islet_point(3)islet

NAME

islet_point - Point utilities

- Arithmetic and helper functions for int16_t coordinate points.

SYNOPSIS

Functions

static void point_add_1 (int16_t *tar, int16_t *orig, int16_t *tr)

Add two points component-wise.

static void point_add_2 (int16_t *tar, int16_t *orig, int16_t *tr)

2D vector addition. See point_add_1() for the family docs.

static void point_add_3 (int16_t *tar, int16_t *orig, int16_t *tr)

3D vector addition. See point_add_1() for the family docs.

static void point_add_4 (int16_t *tar, int16_t *orig, int16_t *tr)

4D vector addition. See point_add_1() for the family docs.

static void point_sub_1 (int16_t *tar, int16_t *orig, int16_t *tr)

Subtract two points component-wise.

static void point_sub_2 (int16_t *tar, int16_t *orig, int16_t *tr)

2D vector subtraction. See point_sub_1() for the family docs.

static void point_sub_3 (int16_t *tar, int16_t *orig, int16_t *tr)

3D vector subtraction. See point_sub_1() for the family docs.

static void point_sub_4 (int16_t *tar, int16_t *orig, int16_t *tr)

4D vector subtraction. See point_sub_1() for the family docs.

static void point_min_1 (int16_t *tar, int16_t *a, int16_t *b)

Compute component-wise minimum of two points.

static void point_min_2 (int16_t *tar, int16_t *a, int16_t *b)

2D component-wise minimum. See point_min_1() for the family docs.

static void point_min_3 (int16_t *tar, int16_t *a, int16_t *b)

3D component-wise minimum. See point_min_1() for the family docs.

static void point_min_4 (int16_t *tar, int16_t *a, int16_t *b)

4D component-wise minimum. See point_min_1() for the family docs.

static void point_max_1 (int16_t *tar, int16_t *a, int16_t *b)

Compute component-wise maximum of two points.

static void point_max_2 (int16_t *tar, int16_t *a, int16_t *b)

2D component-wise maximum. See point_max_1() for the family docs.

static void point_max_3 (int16_t *tar, int16_t *a, int16_t *b)

3D component-wise maximum. See point_max_1() for the family docs.

static void point_max_4 (int16_t *tar, int16_t *a, int16_t *b)

4D component-wise maximum. See point_max_1() for the family docs.

static void point_copy_1 (int16_t *tar, int16_t *orig)

Copy a point (component-wise shallow copy).

static void point_copy_2 (int16_t *tar, int16_t *orig)

2D point copy (exact 4-byte move). See point_copy_1() for docs.

static void point_copy_3 (int16_t *tar, int16_t *orig)

3D point copy. See point_copy_1() for the family docs.

static void point_copy_4 (int16_t *tar, int16_t *orig)

4D point copy (exact 8-byte move). See point_copy_1() for docs.

static int32_t point_vol_1 (int16_t *p)

Compute the volume (product of all components) of a point.

static int32_t point_vol_2 (int16_t *p)

2D area. See point_vol_1() for the family docs.

static int32_t point_vol_3 (int16_t *p)

3D volume. See point_vol_1() for the family docs.

static int32_t point_vol_4 (int16_t *p)

4D volume. See point_vol_1() for the family docs.

static void point_set_1 (int16_t *tar, int16_t value)

Set all components of a point to the same value.

static void point_set_2 (int16_t *tar, int16_t value)

2D broadcast set. See point_set_1() for the family docs.

static void point_set_3 (int16_t *tar, int16_t value)

3D broadcast set. See point_set_1() for the family docs.

static void point_set_4 (int16_t *tar, int16_t value)

4D broadcast set. See point_set_1() for the family docs.

static void point_debug_1 (char *label, int16_t *p)

Print a point to stderr for debugging.

static void point_debug_2 (char *label, int16_t *p)

Print a 2D point. See point_debug_1() for the family docs.

static void point_debug_3 (char *label, int16_t *p)

Print a 3D point. See point_debug_1() for the family docs.

static void point_debug_4 (char *label, int16_t *p)

Print a 4D point. See point_debug_1() for the family docs.

static uint64_t point_idx_1 (int16_t *p, int16_t *s, int16_t *e)

Compute a linear index for a point within a bounding box.

static uint64_t point_idx_2 (int16_t *p, int16_t *s, int16_t *e)

2D row-major index. See point_idx_1() for the family docs.

static uint64_t point_idx_3 (int16_t *p, int16_t *s, int16_t *e)

3D row-major index. See point_idx_1() for the family docs.

static uint64_t point_idx_4 (int16_t *p, int16_t *s, int16_t *e)

4D row-major index. See point_idx_1() for the family docs.

static void point_add_2_32 (int32_t *tar, int32_t *orig, int32_t *tr)

2D x 32-bit vector addition. See point_add_1() for the family docs.

static void point_sub_2_32 (int32_t *tar, int32_t *orig, int32_t *tr)

2D x 32-bit vector subtraction. See point_sub_1() for the family docs.

static void point_min_2_32 (int32_t *tar, int32_t *a, int32_t *b)

2D x 32-bit component-wise minimum. See point_min_1() for the family docs.

static void point_max_2_32 (int32_t *tar, int32_t *a, int32_t *b)

2D x 32-bit component-wise maximum. See point_max_1() for the family docs.

static void point_copy_2_32 (int32_t *tar, int32_t *orig)

2D x 32-bit point copy (exact 8-byte move). See point_copy_1() for the family docs.

static uint64_t point_vol_2_32 (int32_t *p)

2D x 32-bit area. The product of two lanes (each at most 2^32-1 wide) always fits in uint64_t.

static void point_set_2_32 (int32_t *tar, int32_t value)

2D x 32-bit broadcast set. See point_set_1() for the family docs.

static void point_debug_2_32 (char *label, int32_t *p)

Print a 2D x 32-bit point. See point_debug_1() for the family docs.

static uint64_t point_idx_2_32 (int32_t *p, int32_t *s, int32_t *e)

2D x 32-bit row-major index. See point_idx_1() for the family docs.

Detailed Description

Arithmetic and helper functions for int16_t coordinate points.

These functions operate on points represented as arrays of int16_t coordinates. They provide common vector operations (add, subtract, min, max), utility functions (copy, set, volume), and spatial indexing helpers.

Memory Safety:

Overflow Behavior:

See also

Islet core API

Function Documentation

void point_add_1 (int16_t * tar, int16_t * orig, int16_t * tr) [inline], [static]

Add two points component-wise. Performs vector addition: tar[i] = orig[i] + tr[i] for each dimension. Overflow follows standard int16_t arithmetic (wrapping at -32768/32767).

Parameters

tar Output point. May alias orig or tr for in-place operations.
orig First operand (addend). Array of int16_t.
tr Second operand (addend). Array of int16_t.

Note

No overflow detection. 32767 + 1 = -32768 (standard int16_t wrapping).

Example:

int16_t a[3] = {10, 20, 30};
int16_t b[3] = {1, 2, 3};
int16_t result[3];
point_add_3(result, a, b);  // result = {11, 22, 33}

See also

point_sub_3

void point_copy_1 (int16_t * tar, int16_t * orig) [inline], [static]

Copy a point (component-wise shallow copy). Copies the coordinates of one point into another. The destination must have space for the dimension count of the function used. 1D/2D/4D use exact scalar or multi-byte moves; nothing is ever read or written past the point's own elements.

Parameters

tar Destination point. Must have space for the dim count.
orig Source point. Array of int16_t.

Warning

Do not use a wider variant than the arrays actually hold: e.g. copying a bare int16_t[3] with point_copy_4() would read/write past the end.

See also

point_set_3

void point_debug_1 (char * label, int16_t * p) [inline], [static]

Print a point to stderr for debugging. Outputs the point in format: "label(p[0], p[1], ..., p[dim-1])\n" to stderr. Useful for debugging spatial algorithms and visualizing coordinate values during development.

Parameters

label String label to print before the point (e.g., "pos").
p Point to print. Array of int16_t.

Note

Output goes to stderr, not stdout.

Example output:

int16_t pos[3] = {10, -20, 30};
point_debug_3("position", pos);
// Output to stderr: "position(10, -20, 30)\n"

uint64_t point_idx_1 (int16_t * p, int16_t * s, int16_t * e) [inline], [static]

Compute a linear index for a point within a bounding box. Converts a multi-dimensional coordinate to a linear array index using row-major ordering. This is useful for mapping spatial coordinates to flat array indices when storing spatial data in contiguous memory.

Row-major means the first dimension (p[0]) varies fastest, last dimension (p[dim-1]) varies slowest. This matches C array layout.

Parameters

p Point to index. Must be within the box [s, e). Array of int16_t.
s Box start (minimum corner, inclusive). Array of int16_t.
e Box end (maximum corner, exclusive). Array of int16_t.

Returns

Linear index in range [0, volume-1] where volume is the product of (e[i] - s[i]) for all dimensions. Returns uint64_t to handle large volumes, but overflow is still possible.

Warning

Undefined behavior if p is outside the box [s, e). The function does not check bounds. Results may be incorrect or overflow.

Note

The point p[i] must satisfy: s[i] <= p[i] < e[i] for all dimensions.

Example (2D grid):

int16_t start[2] = {0, 0};
int16_t end[2] = {10, 10};  // 10x10 grid
int16_t point[2] = {3, 5};
uint64_t idx = point_idx_2(point, start, end);
// idx = 5 * 10 + 3 = 53

See also

point_vol_3

islet_iter

void point_max_1 (int16_t * tar, int16_t * a, int16_t * b) [inline], [static]

Compute component-wise maximum of two points. For each dimension i, sets tar[i] to the larger of a[i] and b[i]. Useful for computing bounding box maximum corners or clamping operations.

Parameters

tar Output point (maximum per component). May alias a or b.
a First operand. Array of int16_t.
b Second operand. Array of int16_t.

Note

Comparison uses signed int16_t ordering (32767 is maximum value).

See also

point_min_3

void point_min_1 (int16_t * tar, int16_t * a, int16_t * b) [inline], [static]

Compute component-wise minimum of two points. For each dimension i, sets tar[i] to the smaller of a[i] and b[i]. Useful for computing bounding box minimum corners or clamping operations.

Parameters

tar Output point (minimum per component). May alias a or b.
a First operand. Array of int16_t.
b Second operand. Array of int16_t.

Note

Comparison uses signed int16_t ordering (-32768 is minimum value).

See also

point_max_3

void point_set_1 (int16_t * tar, int16_t value) [inline], [static]

Set all components of a point to the same value. Broadcasts a single value to all dimensions: tar[i] = value for all i. Useful for initializing points to zero, setting uniform bounds, or creating uniform scaling factors.

Parameters

tar Output point. Must have space for the dim count.
value Value to assign to all components.

Example (zero initialization):

int16_t pos[3];
point_set_3(pos, 0);  // pos = {0, 0, 0}

Example (uniform bounds):

int16_t min_bounds[3];
point_set_3(min_bounds, -100);  // {-100, -100, -100}

See also

point_copy_3

void point_sub_1 (int16_t * tar, int16_t * orig, int16_t * tr) [inline], [static]

Subtract two points component-wise. Performs vector subtraction: tar[i] = orig[i] - tr[i] for each dimension. Overflow follows standard int16_t arithmetic (wrapping at -32768/32767).

Parameters

tar Output point. May alias orig or tr for in-place operations.
orig Minuend (value to subtract from). Array of int16_t.
tr Subtrahend (value to subtract). Array of int16_t.

Note

No overflow detection. -32768 - 1 = 32767 (standard int16_t wrapping).

Example (compute delta):

int16_t end[3] = {100, 200, 300};
int16_t start[3] = {50, 60, 70};
int16_t delta[3];
point_sub_3(delta, end, start);  // delta = {50, 140, 230}

See also

point_add_3

int32_t point_vol_1 (int16_t * p) [inline], [static]

Compute the volume (product of all components) of a point. Multiplies all components together to get the volume of a box with dimensions specified by the point. Useful for computing bounding box volumes or array sizes for spatial grids.

Parameters

p Point with dimensions. Array of int16_t.

Returns

Product of all components: p[0] * p[1] * ... . For 3D a point {200, 200, 200} yields 8,000,000 (fits int32_t), but a 4D product of large sides may overflow int32_t.

Note

Negative components will produce negative or unexpected results. This function is designed for positive dimensions (lengths).

Example (3D volume):

int16_t size[3] = {10, 20, 30};
int32_t volume = point_vol_3(size);  // volume = 6000

Author

Generated automatically by Doxygen for islet from the source code.