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
boundingBoxstatic
static boundingBox(triangle: Triangle | ShapeLike, result?: Box | null): BoxComputes the axis-aligned bounding box of the specified triangle.
triangle- The triangle whose bounding box is computed.
resultoptional- Optional box to store the result; if null, a new box is created.
Returns A box representing the bounds of the triangle.
copystatic
fromPinstatic
static fromPin(pin: Pin | PinLike, baseWidth: Real | NumberLike, result?: Triangle | null): TriangleCreates 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.
resultoptional- Optional
Triangleto write the result into; it is returned. Without it, a newTriangleis returned.
Returns The triangle.
hasRightAnglestatic
isEquilateralstatic
static isEquilateral(triangle: Triangle | ShapeLike, result?: Bool | null): BoolDetermines whether the triangle is equilateral (all sides equal).
triangle- The triangle to check.
resultoptional- 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): BoolDetermines whether a given point lies inside the triangle.
triangle- The triangle to test.
p- The point to test.
resultoptional- Optional preallocated boolean to store the result.
Returns True if the point lies inside the triangle; otherwise, false.
toOuterCirclestatic
trianglestatic
static triangle(p1: Point | VectorLike, p2: Point | VectorLike, p3: Point | VectorLike, result?: Triangle | null): TriangleCreates a triangle from its three corners.
p1- The first corner.
p2- The second corner.
p3- The third corner.
resultoptional- Optional
Triangleto write the result into; it is returned. Without it, a newTriangleis returned.
Returns The triangle.
