UNPKG

1.67 kBTypeScriptView Raw
1// Last module patch version validated against: 3.0.1
2
3/**
4 * Returns the signed area of the specified polygon. If the vertices of the polygon are in counterclockwise order
5 * (assuming a coordinate system where the origin <0,0> is in the top-left corner), the returned area is positive;
6 * otherwise it is negative, or zero.
7 *
8 * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
9 */
10export function polygonArea(polygon: Array<[number, number]>): number;
11
12/**
13 * Returns the centroid of the specified polygon.
14 *
15 * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
16 */
17export function polygonCentroid(polygon: Array<[number, number]>): [number, number];
18
19/**
20 * Returns the convex hull of the specified points using Andrew’s monotone chain algorithm.
21 * The returned hull is represented as an array containing a subset of the input points arranged in
22 * counterclockwise order. Returns null if points has fewer than three elements.
23 *
24 * @param points Array of coordinates <x0, y0>, <x1, y1> and so on.
25 */
26export function polygonHull(points: Array<[number, number]>): Array<[number, number]> | null;
27
28/**
29 * Returns true if and only if the specified point is inside the specified polygon.
30 *
31 * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
32 * @param point Coordinates of point <x, y>.
33 */
34export function polygonContains(polygon: Array<[number, number]>, point: [number, number]): boolean;
35
36/**
37 * Returns the length of the perimeter of the specified polygon.
38 *
39 * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
40 */
41export function polygonLength(polygon: Array<[number, number]>): number;