.TH "islet_point" 3 "islet" \" -*- nroff -*- .ad l .nh .SH NAME islet_point \- Point utilities .PP \- Arithmetic and helper functions for int16_t coordinate points\&. .SH SYNOPSIS .br .PP .SS "Functions" .in +1c .ti -1c .RI "static void \fBpoint_add_1\fP (int16_t *tar, int16_t *orig, int16_t *tr)" .br .RI "Add two points component-wise\&. " .ti -1c .RI "static void \fBpoint_add_2\fP (int16_t *tar, int16_t *orig, int16_t *tr)" .br .RI "2D vector addition\&. See \fBpoint_add_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_add_3\fP (int16_t *tar, int16_t *orig, int16_t *tr)" .br .RI "3D vector addition\&. See \fBpoint_add_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_add_4\fP (int16_t *tar, int16_t *orig, int16_t *tr)" .br .RI "4D vector addition\&. See \fBpoint_add_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_sub_1\fP (int16_t *tar, int16_t *orig, int16_t *tr)" .br .RI "Subtract two points component-wise\&. " .ti -1c .RI "static void \fBpoint_sub_2\fP (int16_t *tar, int16_t *orig, int16_t *tr)" .br .RI "2D vector subtraction\&. See \fBpoint_sub_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_sub_3\fP (int16_t *tar, int16_t *orig, int16_t *tr)" .br .RI "3D vector subtraction\&. See \fBpoint_sub_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_sub_4\fP (int16_t *tar, int16_t *orig, int16_t *tr)" .br .RI "4D vector subtraction\&. See \fBpoint_sub_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_min_1\fP (int16_t *tar, int16_t *a, int16_t *b)" .br .RI "Compute component-wise minimum of two points\&. " .ti -1c .RI "static void \fBpoint_min_2\fP (int16_t *tar, int16_t *a, int16_t *b)" .br .RI "2D component-wise minimum\&. See \fBpoint_min_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_min_3\fP (int16_t *tar, int16_t *a, int16_t *b)" .br .RI "3D component-wise minimum\&. See \fBpoint_min_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_min_4\fP (int16_t *tar, int16_t *a, int16_t *b)" .br .RI "4D component-wise minimum\&. See \fBpoint_min_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_max_1\fP (int16_t *tar, int16_t *a, int16_t *b)" .br .RI "Compute component-wise maximum of two points\&. " .ti -1c .RI "static void \fBpoint_max_2\fP (int16_t *tar, int16_t *a, int16_t *b)" .br .RI "2D component-wise maximum\&. See \fBpoint_max_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_max_3\fP (int16_t *tar, int16_t *a, int16_t *b)" .br .RI "3D component-wise maximum\&. See \fBpoint_max_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_max_4\fP (int16_t *tar, int16_t *a, int16_t *b)" .br .RI "4D component-wise maximum\&. See \fBpoint_max_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_copy_1\fP (int16_t *tar, int16_t *orig)" .br .RI "Copy a point (component-wise shallow copy)\&. " .ti -1c .RI "static void \fBpoint_copy_2\fP (int16_t *tar, int16_t *orig)" .br .RI "2D point copy (exact 4-byte move)\&. See \fBpoint_copy_1()\fP for docs\&. " .ti -1c .RI "static void \fBpoint_copy_3\fP (int16_t *tar, int16_t *orig)" .br .RI "3D point copy\&. See \fBpoint_copy_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_copy_4\fP (int16_t *tar, int16_t *orig)" .br .RI "4D point copy (exact 8-byte move)\&. See \fBpoint_copy_1()\fP for docs\&. " .ti -1c .RI "static int32_t \fBpoint_vol_1\fP (int16_t *p)" .br .RI "Compute the volume (product of all components) of a point\&. " .ti -1c .RI "static int32_t \fBpoint_vol_2\fP (int16_t *p)" .br .RI "2D area\&. See \fBpoint_vol_1()\fP for the family docs\&. " .ti -1c .RI "static int32_t \fBpoint_vol_3\fP (int16_t *p)" .br .RI "3D volume\&. See \fBpoint_vol_1()\fP for the family docs\&. " .ti -1c .RI "static int32_t \fBpoint_vol_4\fP (int16_t *p)" .br .RI "4D volume\&. See \fBpoint_vol_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_set_1\fP (int16_t *tar, int16_t value)" .br .RI "Set all components of a point to the same value\&. " .ti -1c .RI "static void \fBpoint_set_2\fP (int16_t *tar, int16_t value)" .br .RI "2D broadcast set\&. See \fBpoint_set_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_set_3\fP (int16_t *tar, int16_t value)" .br .RI "3D broadcast set\&. See \fBpoint_set_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_set_4\fP (int16_t *tar, int16_t value)" .br .RI "4D broadcast set\&. See \fBpoint_set_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_debug_1\fP (char *label, int16_t *p)" .br .RI "Print a point to stderr for debugging\&. " .ti -1c .RI "static void \fBpoint_debug_2\fP (char *label, int16_t *p)" .br .RI "Print a 2D point\&. See \fBpoint_debug_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_debug_3\fP (char *label, int16_t *p)" .br .RI "Print a 3D point\&. See \fBpoint_debug_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_debug_4\fP (char *label, int16_t *p)" .br .RI "Print a 4D point\&. See \fBpoint_debug_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBpoint_idx_1\fP (int16_t *p, int16_t *s, int16_t *e)" .br .RI "Compute a linear index for a point within a bounding box\&. " .ti -1c .RI "static uint64_t \fBpoint_idx_2\fP (int16_t *p, int16_t *s, int16_t *e)" .br .RI "2D row-major index\&. See \fBpoint_idx_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBpoint_idx_3\fP (int16_t *p, int16_t *s, int16_t *e)" .br .RI "3D row-major index\&. See \fBpoint_idx_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBpoint_idx_4\fP (int16_t *p, int16_t *s, int16_t *e)" .br .RI "4D row-major index\&. See \fBpoint_idx_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_add_2_32\fP (int32_t *tar, int32_t *orig, int32_t *tr)" .br .RI "2D x 32-bit vector addition\&. See \fBpoint_add_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_sub_2_32\fP (int32_t *tar, int32_t *orig, int32_t *tr)" .br .RI "2D x 32-bit vector subtraction\&. See \fBpoint_sub_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_min_2_32\fP (int32_t *tar, int32_t *a, int32_t *b)" .br .RI "2D x 32-bit component-wise minimum\&. See \fBpoint_min_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_max_2_32\fP (int32_t *tar, int32_t *a, int32_t *b)" .br .RI "2D x 32-bit component-wise maximum\&. See \fBpoint_max_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_copy_2_32\fP (int32_t *tar, int32_t *orig)" .br .RI "2D x 32-bit point copy (exact 8-byte move)\&. See \fBpoint_copy_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBpoint_vol_2_32\fP (int32_t *p)" .br .RI "2D x 32-bit area\&. The product of two lanes (each at most 2^32-1 wide) always fits in uint64_t\&. " .ti -1c .RI "static void \fBpoint_set_2_32\fP (int32_t *tar, int32_t value)" .br .RI "2D x 32-bit broadcast set\&. See \fBpoint_set_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBpoint_debug_2_32\fP (char *label, int32_t *p)" .br .RI "Print a 2D x 32-bit point\&. See \fBpoint_debug_1()\fP for the family docs\&. " .ti -1c .RI "static uint64_t \fBpoint_idx_2_32\fP (int32_t *p, int32_t *s, int32_t *e)" .br .RI "2D x 32-bit row-major index\&. See \fBpoint_idx_1()\fP for the family docs\&. " .in -1c .SH "Detailed Description" .PP 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\&. .PP Memory Safety: .IP "\(bu" 2 All arrays must have at least as many elements as the dimension count implied by the function name (1\&.\&.4) .IP "\(bu" 2 No bounds checking is performed for performance .IP "\(bu" 2 Caller is responsible for ensuring valid memory access .IP "\(bu" 2 Output arrays may alias input arrays unless noted otherwise .PP .PP Overflow Behavior: .IP "\(bu" 2 All arithmetic follows standard int16_t overflow semantics (wrapping) .IP "\(bu" 2 Large multiplications (e\&.g\&., point_vol) may overflow .IP "\(bu" 2 No overflow detection or saturation is provided .PP .PP \fBSee also\fP .RS 4 \fBIslet core API\fP .RE .PP .SH "Function Documentation" .PP .SS "void point_add_1 (int16_t * tar, int16_t * orig, int16_t * tr)\fR [inline]\fP, \fR [static]\fP" .PP 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)\&. .PP \fBParameters\fP .RS 4 \fItar\fP Output point\&. May alias orig or tr for in-place operations\&. .br \fIorig\fP First operand (addend)\&. Array of int16_t\&. .br \fItr\fP Second operand (addend)\&. Array of int16_t\&. .RE .PP \fBNote\fP .RS 4 No overflow detection\&. 32767 + 1 = -32768 (standard int16_t wrapping)\&. .RE .PP Example: .PP .nf 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} .fi .PP .PP \fBSee also\fP .RS 4 \fBpoint_sub_3\fP .RE .PP .SS "void point_copy_1 (int16_t * tar, int16_t * orig)\fR [inline]\fP, \fR [static]\fP" .PP 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\&. .PP \fBParameters\fP .RS 4 \fItar\fP Destination point\&. Must have space for the dim count\&. .br \fIorig\fP Source point\&. Array of int16_t\&. .RE .PP \fBWarning\fP .RS 4 Do not use a wider variant than the arrays actually hold: e\&.g\&. copying a bare int16_t[3] with \fBpoint_copy_4()\fP would read/write past the end\&. .RE .PP \fBSee also\fP .RS 4 \fBpoint_set_3\fP .RE .PP .SS "void point_debug_1 (char * label, int16_t * p)\fR [inline]\fP, \fR [static]\fP" .PP 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\&. .PP \fBParameters\fP .RS 4 \fIlabel\fP String label to print before the point (e\&.g\&., "pos")\&. .br \fIp\fP Point to print\&. Array of int16_t\&. .RE .PP \fBNote\fP .RS 4 Output goes to stderr, not stdout\&. .RE .PP Example output: .PP .nf int16_t pos[3] = {10, \-20, 30}; point_debug_3("position", pos); // Output to stderr: "position(10, \-20, 30)\\n" .fi .PP .SS "uint64_t point_idx_1 (int16_t * p, int16_t * s, int16_t * e)\fR [inline]\fP, \fR [static]\fP" .PP 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\&. .PP Row-major means the first dimension (p[0]) varies fastest, last dimension (p[dim-1]) varies slowest\&. This matches C array layout\&. .PP \fBParameters\fP .RS 4 \fIp\fP Point to index\&. Must be within the box [s, e)\&. Array of int16_t\&. .br \fIs\fP Box start (minimum corner, inclusive)\&. Array of int16_t\&. .br \fIe\fP Box end (maximum corner, exclusive)\&. Array of int16_t\&. .RE .PP \fBReturns\fP .RS 4 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\&. .RE .PP \fBWarning\fP .RS 4 Undefined behavior if p is outside the box [s, e)\&. The function does not check bounds\&. Results may be incorrect or overflow\&. .RE .PP \fBNote\fP .RS 4 The point p[i] must satisfy: s[i] <= p[i] < e[i] for all dimensions\&. .RE .PP Example (2D grid): .PP .nf 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 .fi .PP .PP \fBSee also\fP .RS 4 \fBpoint_vol_3\fP .PP islet_iter .RE .PP .SS "void point_max_1 (int16_t * tar, int16_t * a, int16_t * b)\fR [inline]\fP, \fR [static]\fP" .PP 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\&. .PP \fBParameters\fP .RS 4 \fItar\fP Output point (maximum per component)\&. May alias a or b\&. .br \fIa\fP First operand\&. Array of int16_t\&. .br \fIb\fP Second operand\&. Array of int16_t\&. .RE .PP \fBNote\fP .RS 4 Comparison uses signed int16_t ordering (32767 is maximum value)\&. .RE .PP \fBSee also\fP .RS 4 \fBpoint_min_3\fP .RE .PP .SS "void point_min_1 (int16_t * tar, int16_t * a, int16_t * b)\fR [inline]\fP, \fR [static]\fP" .PP 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\&. .PP \fBParameters\fP .RS 4 \fItar\fP Output point (minimum per component)\&. May alias a or b\&. .br \fIa\fP First operand\&. Array of int16_t\&. .br \fIb\fP Second operand\&. Array of int16_t\&. .RE .PP \fBNote\fP .RS 4 Comparison uses signed int16_t ordering (-32768 is minimum value)\&. .RE .PP \fBSee also\fP .RS 4 \fBpoint_max_3\fP .RE .PP .SS "void point_set_1 (int16_t * tar, int16_t value)\fR [inline]\fP, \fR [static]\fP" .PP 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\&. .PP \fBParameters\fP .RS 4 \fItar\fP Output point\&. Must have space for the dim count\&. .br \fIvalue\fP Value to assign to all components\&. .RE .PP Example (zero initialization): .PP .nf int16_t pos[3]; point_set_3(pos, 0); // pos = {0, 0, 0} .fi .PP .PP Example (uniform bounds): .PP .nf int16_t min_bounds[3]; point_set_3(min_bounds, \-100); // {\-100, \-100, \-100} .fi .PP .PP \fBSee also\fP .RS 4 \fBpoint_copy_3\fP .RE .PP .SS "void point_sub_1 (int16_t * tar, int16_t * orig, int16_t * tr)\fR [inline]\fP, \fR [static]\fP" .PP 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)\&. .PP \fBParameters\fP .RS 4 \fItar\fP Output point\&. May alias orig or tr for in-place operations\&. .br \fIorig\fP Minuend (value to subtract from)\&. Array of int16_t\&. .br \fItr\fP Subtrahend (value to subtract)\&. Array of int16_t\&. .RE .PP \fBNote\fP .RS 4 No overflow detection\&. -32768 - 1 = 32767 (standard int16_t wrapping)\&. .RE .PP Example (compute delta): .PP .nf 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} .fi .PP .PP \fBSee also\fP .RS 4 \fBpoint_add_3\fP .RE .PP .SS "int32_t point_vol_1 (int16_t * p)\fR [inline]\fP, \fR [static]\fP" .PP 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\&. .PP \fBParameters\fP .RS 4 \fIp\fP Point with dimensions\&. Array of int16_t\&. .RE .PP \fBReturns\fP .RS 4 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\&. .RE .PP \fBNote\fP .RS 4 Negative components will produce negative or unexpected results\&. This function is designed for positive dimensions (lengths)\&. .RE .PP Example (3D volume): .PP .nf int16_t size[3] = {10, 20, 30}; int32_t volume = point_vol_3(size); // volume = 6000 .fi .PP .SH "Author" .PP Generated automatically by Doxygen for islet from the source code\&.