Polygon
Class Polygon
A polygon defined by its vertex points.
Implements GeoShape
Accessor .signedArea : number
The (signed) area of this polygon. The result is positive if the vertices are ordered clockwise, and negative otherwise.
Method .centerAt (on: Point): Polygon
Center this polygon on a given point or the origin
Name | Type | Default | Description |
---|---|---|---|
on | Point | … |
Method .contains (p: Point): boolean
Checks if a point p lies inside this polygon, by using a ray-casting algorithm and calculating the number of intersections.
Name | Type | Default | Description |
---|---|---|---|
p | Point |
Method .cut (line: Line): Array<Polygon>
Cut this polygon along a line, and return multiple parts.
Name | Type | Default | Description |
---|---|---|---|
line | Line |
Method .equals (other: Polygon, tolerance: number, oriented: boolean): boolean
Name | Type | Default | Description |
---|---|---|---|
other | Polygon | ||
tolerance | number | ||
oriented | boolean |
Method .rotate (a: number, center: Point): Polygon
Rotates this polygon by a given angle (in radians), optionally around point center
.
Name | Type | Default | Description |
---|---|---|---|
a | number | ||
center | Point | … |
static Method .collision (p1: Polygon, p2: Polygon): boolean
Checks if two polygons p1 and p2 collide.
Name | Type | Default | Description |
---|---|---|---|
p1 | Polygon | ||
p2 | Polygon |
static Method .convexHull (points: Array<Point>): Polygon
Name | Type | Default | Description |
---|---|---|---|
points | Array<Point> |
static Method .interpolate (p1: Polygon, p2: Polygon, t: number): Polygon
Interpolates the points of two polygons
Name | Type | Default | Description |
---|---|---|---|
p1 | Polygon | ||
p2 | Polygon | ||
t | number | 0.5 |
static Method .regular (n: number, radius: number): Polygon
Creates a regular polygon.
Name | Type | Default | Description |
---|---|---|---|
n | number | ||
radius | number | 1 |
Class Polyline
A polyline defined by its vertex points.
Extends Polygon