This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.d.ts
44 lines (39 loc) · 1.9 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Type definitions for D3JS d3-polygon module v1.0.1
// Project: https://github.com/d3/d3-polygon/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Returns the signed area of the specified polygon. If the vertices of the polygon are in counterclockwise order (
* assuming a coordinate system where the origin ⟨0,0⟩ is in the top-left corner), the returned area is positive;
* otherwise it is negative, or zero.
*
* @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
*/
export function polygonArea(polygon: Array<[number, number]>): number;
/**
* Returns the centroid of the specified polygon.
*
* @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
*/
export function polygonCentroid(polygon: Array<[number, number]>): [number, number];
/**
* Returns the convex hull of the specified points using Andrew’s monotone chain algorithm.
* The returned hull is represented as an array containing a subset of the input points arranged in
* counterclockwise order. Returns null if points has fewer than three elements.
*
* @param points Array of coordinates <x0, y0>, <x1, y1> and so on.
*/
export function polygonHull(points: Array<[number, number]>): Array<[number, number]> | null;
/**
* Returns true if and only if the specified point is inside the specified polygon.
*
* @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
* @param point Coordinates of point <x, y>
*/
export function polygonContains(polygon: Array<[number, number]>, point: [number, number]): boolean;
/**
* Returns the length of the perimeter of the specified polygon.
*
* @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
*/
export function polygonLength(polygon: Array<[number, number]>): number;