Calculates the area of a polygon given its vertices using the shoelace formula. The vertices should be provided in order (clockwise or counterclockwise) as an array of 2D points.
Computes the centroid of a polygon or point cloud. For polygons (3+ vertices), uses the signed-area weighted formula. For point clouds, returns the arithmetic mean of all coordinates.
Calculates the Chebyshev distance (L-infinity distance) between two points in N-dimensional space. The result is the maximum of the absolute differences of their coordinates.
Syntax
chebyshevDistance(a | b)
Type Signatures
Array, Array
Parameters
Name
Type
Description
a
Array
First point as an array of coordinates
b
Array
Second point as an array of coordinates
Returns
number — The Chebyshev distance between points a and b
Transforms a point between coordinate systems. Supported systems: "cartesian", "polar", "spherical", "cylindrical". For polar: [r, theta]. For spherical (ISO): [r, theta, phi] where theta is the inclination and phi is the azimuth. For cylindrical: [rho, phi, z].
Computes the Delaunay triangulation of a set of 2D points using the Bowyer-Watson algorithm. Returns an array of triangles, each represented as three indices into the original points array.
Syntax
delaunayTriangulation(points)
Parameters
Name
Type
Description
points
Array
Array of 2D points [[x0,y0],[x1,y1],...]
Returns
Array — Array of triangles [[i,j,k],...] with indices into points
Array — Returns the point of intersection of lines/lines-planes
Examples
intersect([0 0
See Also
kdTree
Builds a balanced k-d tree from an array of points for efficient nearest-neighbor and range queries. Returns an object with nearest(point, k) and rangeSearch(point, radius) methods.
Syntax
kdTree(points)
Parameters
Name
Type
Description
points
Array
Array of 2D points [[x0,y0],[x1,y1],...]
Returns
Object — Object with nearest(point, k) and rangeSearch(point, radius)
Calculates the Manhattan distance (L1 distance) between two points in N-dimensional space. The result is the sum of the absolute differences of their coordinates.
Syntax
manhattanDistance(a | b)
Type Signatures
Array, Array
Parameters
Name
Type
Description
a
Array
First point as an array of coordinates
b
Array
Second point as an array of coordinates
Returns
number — The Manhattan distance between points a and b
Calculates the Minkowski distance (Lp distance) between two points in N-dimensional space. Generalizes Euclidean (p=2), Manhattan (p=1), and Chebyshev (p=Infinity) distances.
Syntax
minkowskiDistance(a | b | p)
Type Signatures
Array, Array, number
Parameters
Name
Type
Description
a
Array
First point as an array of coordinates
b
Array
Second point as an array of coordinates
p
number
The order of the Minkowski distance (p >= 1)
Returns
number — The Minkowski distance between points a and b
Calculates the perimeter of a polygon by summing the Euclidean distances between consecutive vertices, including the closing edge from the last vertex back to the first.
Computes the Voronoi diagram of a set of 2D points as the dual of the Delaunay triangulation. Returns an object with vertices (circumcenters) and cells (ordered polygon vertex lists per input point).