# Triangle

## Description

`struct` `Tinman.Core.Math.Triangle`

Pre-computed coefficients for performing intersection tests with a triangle.

## Public / Constructors

### Triangle

`public` `constructor` `Triangle` → `(3)`

v1 in : Vec3D

First triangle vertex.

v2 in : Vec3D

Second triangle vertex.

v3 in : Vec3D

Third triangle vertex.

Creates a new instance of Triangle.

## Public / Methods

### Intersect​Ray

`[Pure]`
`public` `method` `IntersectRay` → `(4)`

origin in : Vec3D

The ray origin.

direction in : Vec3D

The ray direction.

weights out : Vec3D

The barycentric weights of the found intersection point of or Vec3D.Undefined if there is no intersection.

maximum opt : float64 = Maths.MaxDouble

The maximum distance to return as an intersection.

returns → float64

The distance between the origin in and the found intersection point, divided by the length of direction in. Will be negative iff there is no intersection.

Computes the intersection between the given ray and this triangle.

### Intersect​Ray​X

`[Pure]`
`public` `method` `IntersectRayX` → `(4)`

originX in : float64

X-coordinate of the ray origin.

originY in : float64

Y-coordinate of the ray origin.

originZ in : float64

Z-coordinate of the ray origin.

maximum opt : float64 = Maths.MaxDouble

The maximum distance to return as an intersection.

returns → float64

The distance between the origin and the found intersection point. Will be negative iff there is no intersection.

Computes the intersection between the ray `(1,0,0)` and this triangle.

### Intersect​Ray​Y

`[Pure]`
`public` `method` `IntersectRayY` → `(4)`

originX in : float64

X-coordinate of the ray origin.

originY in : float64

Y-coordinate of the ray origin.

originZ in : float64

Z-coordinate of the ray origin.

maximum opt : float64 = Maths.MaxDouble

The maximum distance to return as an intersection.

returns → float64

The distance between the origin and the found intersection point. Will be negative iff there is no intersection.

Computes the intersection between the ray `(0,1,0)` and this triangle.

### Intersect​Ray​Z

`[Pure]`
`public` `method` `IntersectRayZ` → `(4)`

originX in : float64

X-coordinate of the ray origin.

originY in : float64

Y-coordinate of the ray origin.

originZ in : float64

Z-coordinate of the ray origin.

maximum opt : float64 = Maths.MaxDouble

The maximum distance to return as an intersection.

returns → float64

The distance between the origin and the found intersection point. Will be negative iff there is no intersection.

Computes the intersection between the ray `(0,0,1)` and this triangle.

## Public / Attributes

### Is​Undefined

`public` `attribute` `IsUndefined` → `(get)`

value : bool

`true` if the triangle is undefined, i.e. some coefficients are not regular numbers,
`false` if the triangle is well-defined.

Checks if this triangle is undefined.