Link Search Menu Expand Document

Polygon

polygon.ts#L17

Class Polygon

A polygon defined by its vertex points.

Implements GeoShape

constructor (points: Array<Point>): Polygon

Name Type Default Description
points Array<Point>    

readonly Property .points

readonly Property .type : string

Default value: 'polygon'

Accessor .area : number

Accessor .centroid : Point

Accessor .circumference : number

Accessor .edges

Accessor .oriented : this

The oriented version of this polygon (vertices in clockwise order).

Accessor .radius : number

Accessor .signedArea : number

The (signed) area of this polygon. The result is positive if the vertices are ordered clockwise, and negative otherwise.

Method .at (t: number): Point

Name Type Default Description
t number    

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): boolean

Name Type Default Description
_other Polygon    

Method .project (p: Point): Point

Name Type Default Description
p Point    

Method .reflect (line: Line): Polygon

Name Type Default Description
line Line    

Method .rotate (a: number, center: Point): Polygon

Name Type Default Description
a number    
center Point  

Method .scale (sx: number, sy: number): Polygon

Name Type Default Description
sx number    
sy number  

Method .shift (x: number, y: number): Polygon

Name Type Default Description
x number    
y number  

Method .transform (m: TransformMatrix): Polygon

Name Type Default Description
m TransformMatrix    

Method .translate (p: Point): Polygon

Name Type Default Description
p 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 .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  
polygon.ts#L293

Class Polyline

A polyline defined by its vertex points.

Extends Polygon

readonly Property .type

Default value: 'polyline'

Accessor .length : number

polygon.ts#L316

Class Triangle

A triangle defined by its three vertices.

Extends Polygon

readonly Property .type

Default value: 'triangle'

Accessor .circumcircle : Circle

Accessor .incircle : Circle

Accessor .orthocenter : Point


Copyright © 2021 Mathigon.org