Triangle

Triangle class provides static functions to create and operate on trianges. A triange is a polygon represented as a Group of 3 Pts. You can use the static functions as-is, or apply the Group.op or Pt.op to enable functional programming. See Op guide for details.

Class in src/Op.ts

Methods

STATIC altitude ( tri, index )

Get a triangle's altitude, which is a line from a triangle's point to its opposite side, and perpendicular to its opposite side.

parameters
tri: PtIterable

a Group or an Iterable representing a triangle

index: number

a Pt on the triangle group

returns
Group

a Group that represents the altitude line

source

STATIC circumcenter ( tri )

Get circumcenter, which is the intersection point of its 3 perpendicular bisectors lines ( each of which divides a side in half and is perpendicular to the side).

parameters
tri: PtIterable

a Group or an Iterable representing a triangle

returns
Pt

the circumcenter as a Pt

source

STATIC circumcircle ( tri, center )

Get circumcenter, which is the intersection point of its 3 perpendicular bisectors lines ( each of which divides a side in half and is perpendicular to the side).

parameters
tri: PtIterable

a Group or an Iterable representing a triangle

center: Pt

Optional parameter if the circumcenter is already known. Otherwise, leave it empty and the circumcenter will be calculated

returns
Group

source

STATIC fromCenter ( pt, size )

Create an equilateral triangle based on a center point and a size.

parameters
pt: PtLike

the center point

size: number

size is the magnitude of lines from center to the triangle's vertices, like a "radius".

returns
Group

source

STATIC fromCircle ( circle )

Create a triangle that fits within a circle.

parameters
circle: PtIterable

a Group or an Iterable with 2 Pt representing a circle

returns
Group

source

STATIC fromRect ( rect )

Create a triangle from a rectangle. The triangle will be isosceles, with the bottom of the rectangle as its base.

parameters
rect: PtIterable

a Group or an Iterable with 2 Pt representing a rectangle

returns
Group

source

STATIC incenter ( tri )

Get incenter, which is the center point of its inner circle, and also the intersection point of its 3 angle bisector lines (each of which cuts one of the 3 angles in half).

parameters
tri: PtIterable

a Group or an Iterable representing a triangle

returns
Pt

the incenter as a Pt

source

STATIC incircle ( tri, center )

Get an interior circle, which is the largest circle completed enclosed by this triangle.

parameters
tri: PtIterable

a Group or an Iterable representing a triangle

center: Pt

Optional parameter if the incenter is already known. Otherwise, leave it empty and the incenter will be calculated

returns
Group

source

STATIC medial ( tri )

Get the medial, which is an inner triangle formed by connecting the midpoints of this triangle's sides.

parameters
tri: PtIterable

a Group or an Iterable representing a triangle

returns
Group

a Group representing a medial triangle

source

STATIC oppositeSide ( tri, index )

Given a point of the triangle, the opposite side is the side which the point doesn't touch.

parameters
tri: PtIterable

a Group or an Iterable representing a triangle

index: number

a Pt on the triangle group

returns
Group

a Group that represents a line of the opposite side

source

STATIC orthocenter ( tri )

Get orthocenter, which is the intersection point of a triangle's 3 altitudes (the 3 lines that are perpendicular to its 3 opposite sides).

parameters
tri: PtIterable

a Group or an Iterable representing a triangle

returns
Pt

the orthocenter as a Pt

source