abstract class Triangle

Known direct subclasses
ImmutableTriangle

An immutable triangle, defined by its three corners p0, p1 and p2 in order.

MutableTriangle

Represents a mutable triangle, defined by its three corners p0, p1 and p2 in order.


A triangle defined by its three corners p0, p1 and p2. The order of these points matter - a triangle with p0, p1, p2 is not the same as the permuted p1, p0, p2, or even the rotated p2, p0, p1.

A Triangle may be degenerate, meaning it is constructed with its 3 points colinear. One way that a Triangle may be degenerate is if two or three of its points are at the same location (coincident).

This is a read-only interface that has mutable and immutable implementations. See MutableTriangle and ImmutableTriangle.

Summary

Public functions

ImmutableBox

Returns the minimum bounding box containing the Triangle.

MutableBox

Populates outBox with the minimum bounding box containing the Triangle and returns outBox.

ImmutableSegment
computeEdge(index: @IntRange(from = 0, to = 2) Int)

Returns the segment of the Triangle between the point at index and the point at index + 1 modulo 3.

MutableSegment
computeEdge(index: @IntRange(from = 0, to = 2) Int, outSegment: MutableSegment)

Fills outSegment with the segment of the Triangle between the point at index and the point at index + 1 modulo 3.

Float

Return the signed area of the Triangle.

operator Boolean
contains(point: Vec)

Returns true if the given point is contained within the Triangle.

Boolean
isAlmostEqual(other: Triangle, tolerance: @FloatRange(from = 0.0) Float)

Public properties

abstract Vec

One of the three points that define the Triangle.

abstract Vec

One of the three points that define the Triangle.

abstract Vec

One of the three points that define the Triangle.

Public functions

computeBoundingBox

Added in 1.0.0-alpha01
fun computeBoundingBox(): ImmutableBox

Returns the minimum bounding box containing the Triangle.

computeBoundingBox

Added in 1.0.0-alpha01
fun computeBoundingBox(outBox: MutableBox): MutableBox

Populates outBox with the minimum bounding box containing the Triangle and returns outBox.

computeEdge

Added in 1.0.0-alpha01
fun computeEdge(index: @IntRange(from = 0, to = 2) Int): ImmutableSegment

Returns the segment of the Triangle between the point at index and the point at index + 1 modulo 3.

computeEdge

Added in 1.0.0-alpha01
fun computeEdge(index: @IntRange(from = 0, to = 2) Int, outSegment: MutableSegment): MutableSegment

Fills outSegment with the segment of the Triangle between the point at index and the point at index + 1 modulo 3. Returns outSegment.

computeSignedArea

Added in 1.0.0-alpha01
fun computeSignedArea(): Float

Return the signed area of the Triangle. If the Triangle is degenerate, meaning its 3 points are all colinear, then the result will be zero. If its points wind in a positive direction (as defined by Angle), then the result will be positive. Otherwise, it will be negative.

contains

Added in 1.0.0-alpha01
operator fun contains(point: Vec): Boolean

Returns true if the given point is contained within the Triangle. Points that lie exactly on the Triangle's boundary are considered to be contained.

isAlmostEqual

Added in 1.0.0-alpha01
fun isAlmostEqual(other: Triangle, tolerance: @FloatRange(from = 0.0) Float): Boolean

Public properties

p0

Added in 1.0.0-alpha01
abstract val p0Vec

One of the three points that define the Triangle.

p1

Added in 1.0.0-alpha01
abstract val p1Vec

One of the three points that define the Triangle.

p2

Added in 1.0.0-alpha01
abstract val p2Vec

One of the three points that define the Triangle.