Goxel Module
Goxel (Geometry Engine) Provides geometric primitives and utilities for Hygrid shapes. Includes line generation, polygon cleaning, area calculations, and winding normalization.
Functions and values
| Function or value |
Description
|
Full Usage:
bounds pts
Parameters:
(int * int)[]
-
Array of 2D coordinate points.
Returns: int * int * int * int
4-tuple of (minX, minY, maxX, maxY).
|
Computes the bounding box of a polygon in grid coordinates: (minX, minY, maxX, maxY).
Example
val minX: obj
val minY: obj
val maxX: obj
val maxY: obj
|
Full Usage:
centroid pts
Parameters:
(int * int)[]
-
Array of 2D coordinate points.
Returns: int * int
Tuple of (centerX, centerY).
|
Computes the arithmetic centroid (average of grid indices) of a collection of points.
Example
val cx: obj
val cy: obj
|
Full Usage:
cleanPolygon sqn pts
Parameters:
Sqn
-
Traversal sequence.
pts : (int * int)[]
-
Raw input polygon vertices.
Returns: (int * int)[]
Cleaned, validated, clockwise polygon vertices.
|
Cleans a polygon by deduplicating sequential points, removing sawtooth aliasing, closing the loop, removing collinear points, and normalizing winding to clockwise.
Example
val cleaned: obj
|
Full Usage:
dedupeSequential pts
Parameters:
(int * int)[]
-
Array of 2D coordinate points.
Returns: (int * int) array
Array of points without adjacent duplicates.
|
Deduplicates consecutive identical coordinate points in a sequence.
Example
val deduped: obj
|
Full Usage:
ensureClosed pts
Parameters:
(int * int)[]
-
Array of 2D coordinate points.
Returns: (int * int)[]
Closed array of points where the last point matches the first.
|
Ensures a polygon coordinate sequence is closed by appending the first point to the end if not already equal.
Example
val closed: obj
|
|
Generates a discrete line of hexels connecting start and end hexels using integer grid mathematics.
Example
val startPt: obj
val endPt: obj
val line: obj
|
|
Generates a filled or outlined hexel polygon covering the region defined by integer vertices.
Example
val boundaryHxls: obj
|
Full Usage:
normalizeWinding clockwise pts
Parameters:
bool
-
True to enforce clockwise winding; false for counterclockwise.
pts : (int * int)[]
-
Array of 2D polygon vertices.
Returns: (int * int)[]
Array of vertices with the specified winding order.
|
Normalizes the vertex winding order of a polygon to clockwise or counterclockwise using signed area calculation.
Example
val cwPolygon: obj
|
Full Usage:
parseCoords value
Parameters:
string
-
Comma-separated coordinate string.
Returns: (int * int) array
Array of integer (x, y) vertices.
|
Parses a comma-separated string of coordinates into rounded integer (int * int) grid vertices.
Example
val coords: obj
|
Full Usage:
parseIslands value
Parameters:
string
-
Hyphen-separated string of island polygon coordinates.
Returns: (int * int) array array
Array of integer island vertex arrays.
|
Parses a hyphen-separated string of island polygons into rounded integer (int * int)[][] grid vertices.
Example
val islandCoords: obj
|
Full Usage:
parsePolyIslands s
Parameters:
string
-
Hyphen-separated string of polygon coordinates.
Returns: (float * float)[][]
Array of float polygon vertex arrays.
|
Parses a hyphen-separated string of polygons (e.g. "0,0,10,10 - 20,20,30,30") representing multiple islands into a 2D array of float points.
Example
val islands: obj
|
Full Usage:
parsePolygon s
Parameters:
string
-
Comma-separated string of coordinates.
Returns: (float * float)[]
Array of (float * float) points.
|
Parses a comma-separated string of coordinate numbers (e.g. "0,0,10,0,10,10,0,10") into an array of 2D float points.
Example
val points: obj
|
Full Usage:
pointInPolygon (arg1, arg1) poly
Parameters:
int
arg1 : int
poly : (int * int)[]
-
Polygon vertex array.
Returns: bool
True if the point is inside the polygon; otherwise false.
|
Tests whether a 2D integer point lies inside or on the boundary of a polygon using the ray casting algorithm.
Example
val isInside: obj
|
Full Usage:
polygonArea pts
Parameters:
(int * int)[]
-
Array of 2D polygon vertices.
Returns: int64
Polygon area as a 64-bit integer.
|
Calculates the area of a simple polygon in logical grid units using Gauss's area formula (Shoelace algorithm).
Example
val area: obj
|
Full Usage:
polygonWithHolesArea outer holes
Parameters:
(int * int)[]
-
Outer boundary polygon vertices.
holes : (int * int)[][]
-
Array of inner hole polygons.
Returns: int64
Net usable area as a 64-bit integer.
|
Calculates the net area of a polygon by subtracting the total area of any interior holes (islands).
Example
val outer: (int * int) array
val hole: (int * int) array
val net: obj
|
Full Usage:
removeCollinear pts
Parameters:
(int * int)[]
-
Array of 2D polygon vertices.
Returns: (int * int)[]
Simplified array of vertices with intermediate collinear points removed.
|
Removes collinear points from a polygon sequence using integer cross products.
Example
val simplified: obj
|
Full Usage:
removeSawtooth sqn arr
Parameters:
Sqn
-
Traversal sequence.
arr : (int * int)[]
-
Array of integer 2D coordinate points.
Returns: (int * int)[]
Filtered array of points with oscillating sawtooth artifacts removed.
|
Removes aliasing/sawtooth artifacts from a sequence of hex coordinates along the primary axis.
Example
val smoothed: obj
|
Hywe