1 | // Type definitions for D3JS d3-polygon module 2.0
|
2 | // Project: https://github.com/d3/d3-polygon/, https://d3js.org/d3-polygon
|
3 | // Definitions by: Tom Wanzek <https://github.com/tomwanzek>
|
4 | // Alex Ford <https://github.com/gustavderdrache>
|
5 | // Boris Yankov <https://github.com/borisyankov>
|
6 | // Nathan Bierema <https://github.com/Methuselah96>
|
7 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
8 |
|
9 | // Last module patch version validated against: 2.0.0
|
10 |
|
11 | /**
|
12 | * Returns the signed area of the specified polygon. If the vertices of the polygon are in counterclockwise order
|
13 | * (assuming a coordinate system where the origin <0,0> is in the top-left corner), the returned area is positive;
|
14 | * otherwise it is negative, or zero.
|
15 | *
|
16 | * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
|
17 | */
|
18 | export function polygonArea(polygon: Array<[number, number]>): number;
|
19 |
|
20 | /**
|
21 | * Returns the centroid of the specified polygon.
|
22 | *
|
23 | * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
|
24 | */
|
25 | export function polygonCentroid(polygon: Array<[number, number]>): [number, number];
|
26 |
|
27 | /**
|
28 | * Returns the convex hull of the specified points using Andrew’s monotone chain algorithm.
|
29 | * The returned hull is represented as an array containing a subset of the input points arranged in
|
30 | * counterclockwise order. Returns null if points has fewer than three elements.
|
31 | *
|
32 | * @param points Array of coordinates <x0, y0>, <x1, y1> and so on.
|
33 | */
|
34 | export function polygonHull(points: Array<[number, number]>): Array<[number, number]> | null;
|
35 |
|
36 | /**
|
37 | * Returns true if and only if the specified point is inside the specified polygon.
|
38 | *
|
39 | * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
|
40 | * @param point Coordinates of point <x, y>.
|
41 | */
|
42 | export function polygonContains(polygon: Array<[number, number]>, point: [number, number]): boolean;
|
43 |
|
44 | /**
|
45 | * Returns the length of the perimeter of the specified polygon.
|
46 | *
|
47 | * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
|
48 | */
|
49 | export function polygonLength(polygon: Array<[number, number]>): number;
|