Triangle

class Triangle(var a: Vector3 = Vector3(), var b: Vector3 = Vector3(), var c: Vector3 = Vector3())

A geometric triangle as defined by three vectors representing its three corners.

Triangles are mutable and not thread-safe; confine an instance (and any object graph holding it) to a single thread, exactly as in three.js. Most methods mutate this and return it for chaining.

The constructor stores the given Vector3 instances by reference, so Triangle(v, v, v) shares v across all three corners.

Constructors

Link copied to clipboard
constructor(a: Vector3 = Vector3(), b: Vector3 = Vector3(), c: Vector3 = Vector3())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
var a: Vector3

The first corner of the triangle.

Link copied to clipboard
var b: Vector3

The second corner of the triangle.

Link copied to clipboard
var c: Vector3

The third corner of the triangle.

Functions

Link copied to clipboard

Returns a new triangle with copied values from this instance.

Link copied to clipboard

Returns the closest point on the triangle to the given point.

Link copied to clipboard

Returns true if the given point, when projected onto the plane of the triangle, lies within the triangle.

Link copied to clipboard
fun copy(triangle: Triangle): Triangle

Copies the values of the given triangle to this instance.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Returns true if this triangle is equal with the given one.

Link copied to clipboard

Computes the area of the triangle.

Link copied to clipboard
fun getBarycoord(point: Vector3, target: Vector3): Vector3?

Computes a barycentric coordinates from the given vector. Returns null if the triangle is degenerate.

Link copied to clipboard
fun getInterpolation(point: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, target: Vector3): Vector3?

Computes the value barycentrically interpolated for the given point on the triangle. Returns null if the triangle is degenerate.

Link copied to clipboard

Computes the midpoint of the triangle.

Link copied to clipboard
fun getNormal(target: Vector3): Vector3

Computes the normal of the triangle.

Link copied to clipboard
fun getPlane(target: Plane): Plane

Computes a plane the triangle lies within.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Returns true if this triangle intersects with the given box.

Link copied to clipboard
fun isFrontFacing(direction: Vector3): Boolean

Returns true if the triangle is oriented towards the given direction.

Link copied to clipboard

Sets the triangle's vertices by copying the given values.

Link copied to clipboard

Sets the triangle's vertices by copying the given attribute values.

Link copied to clipboard
fun setFromPointsAndIndices(points: List<Vector3>, i0: Int, i1: Int, i2: Int): Triangle

Sets the triangle's vertices by copying the given array values.

Link copied to clipboard
open override fun toString(): String