class Geometry · Computations

Triangles

Computations on triangles: area, right angle and equilateral tests, containment, the outer circle, and triangles made from a pin.

Static methods

areastatic

static area(triangle: Triangle | ShapeLike, result?: Real | null): Real

Computes the area of the specified triangle.

triangle
The triangle to compute the area of.
result optional
Optional preallocated area to store the result.

Returns The area of the triangle.

boundingBoxstatic

static boundingBox(triangle: Triangle | ShapeLike, result?: Box | null): Box

Computes the axis-aligned bounding box of the specified triangle.

triangle
The triangle whose bounding box is computed.
result optional
Optional box to store the result; if null, a new box is created.

Returns A box representing the bounds of the triangle.

copystatic

static copy(triangle: Triangle | ShapeLike, result?: Triangle | null): Triangle

Creates a copy of the specified triangle.

triangle
The triangle to copy.
result optional
Optional triangle to store the result; if null, a new triangle is created.

Returns A copy of the specified triangle.

fromPinstatic

static fromPin(pin: Pin | PinLike, baseWidth: Real | NumberLike, result?: Triangle | null): Triangle

Creates a triangle from a pin, e.g. an arrowhead: the tip is the pin's tip, the base of width baseWidth lies across the pin at its position. Triangles.fromPin(Pins.fromSegment(a, b), 8, head) points from a to b.

The pin's length is the height of the triangle. The corners are: the tip, then the base corner left and the one right of the pin (as seen on the screen). A pin of length 0 has no direction: the base corners are NaN.

pin
The base center (position), height (length) and direction of the triangle.
baseWidth
The width of the base.
result optional
Optional Triangle to write the result into; it is returned. Without it, a new Triangle is returned.

Returns The triangle.

hasRightAnglestatic

static hasRightAngle(triangle: Triangle | ShapeLike, result?: Bool | null): Bool

Determines whether the triangle has a right angle.

triangle
The triangle to check.
result optional
Optional preallocated boolean to store the result.

Returns True if the triangle has a right angle; otherwise, false.

isEquilateralstatic

static isEquilateral(triangle: Triangle | ShapeLike, result?: Bool | null): Bool

Determines whether the triangle is equilateral (all sides equal).

triangle
The triangle to check.
result optional
Optional preallocated boolean to store the result.

Returns True if the triangle is equilateral; otherwise, false.

pointInTrianglestatic

static pointInTriangle(triangle: Triangle | ShapeLike, p: Point | VectorLike, result?: Bool | null): Bool

Determines whether a given point lies inside the triangle.

triangle
The triangle to test.
p
The point to test.
result optional
Optional preallocated boolean to store the result.

Returns True if the point lies inside the triangle; otherwise, false.

toOuterCirclestatic

static toOuterCircle(triangle: Triangle | ShapeLike, result?: Circle | null): Circle

Computes the outer (circum) circle of the triangle.

triangle
The triangle to compute the circumcircle for.
result optional
Optional preallocated circle to store the result.

Returns The circumcircle of the triangle.

trianglestatic

static triangle(p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike, result?: Triangle | null): Triangle

Creates a triangle from its three corners.

p1
The first corner.
p2
The second corner.
p3
The third corner.
result optional
Optional Triangle to write the result into; it is returned. Without it, a new Triangle is returned.

Returns The triangle.