Triangle
-
Cmn
abstract class Triangle
ImmutableTriangle |
An immutable triangle, defined by its three corners |
MutableTriangle |
Represents a mutable triangle, defined by its three corners |
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 |
Cmn
|
MutableBox |
computeBoundingBox(outBox: MutableBox)Populates |
Cmn
|
ImmutableSegment |
computeEdge(index: @IntRange(from = 0, to = 2) Int)Returns the segment of the Triangle between the point at |
Cmn
|
MutableSegment |
computeEdge(index: @IntRange(from = 0, to = 2) Int, outSegment: MutableSegment)Fills |
Cmn
|
Float |
Return the signed area of the |
Cmn
|
operator Boolean |
Returns true if the given point is contained within the Triangle. |
Cmn
|
Boolean |
isAlmostEqual(other: Triangle, tolerance: @FloatRange(from = 0.0) Float) |
Cmn
|
abstract ImmutableTriangle |
Returns an immutable copy of this object. |
Cmn
|
Public properties |
||
|---|---|---|
abstract Vec |
One of the three points that define the |
Cmn
|
abstract Vec |
One of the three points that define the |
Cmn
|
abstract Vec |
One of the three points that define the |
Cmn
|
Public functions
computeBoundingBox
fun computeBoundingBox(): ImmutableBox
Returns the minimum bounding box containing the Triangle.
computeBoundingBox
fun computeBoundingBox(outBox: MutableBox): MutableBox
Populates outBox with the minimum bounding box containing the Triangle and returns outBox.
computeEdge
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
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
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
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.
toImmutable
abstract fun toImmutable(): ImmutableTriangle
Returns an immutable copy of this object. This will return itself if called on an immutable instance.