Struct Triangle
Represents a triangle in 3D space that supports raycasting
Namespace: AnyPath.Graphs.Extra
Assembly: AnyPath.dll
Syntax
public struct Triangle
Constructors
Triangle(Vector3, Vector3, Vector3)
Declaration
public Triangle(Vector3 a, Vector3 b, Vector3 c)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | a | |
| Vector3 | b | |
| Vector3 | c |
Fields
a
Declaration
public float3 a
Field Value
| Type | Description |
|---|---|
| float3 |
b
Declaration
public float3 b
Field Value
| Type | Description |
|---|---|
| float3 |
c
Declaration
public float3 c
Field Value
| Type | Description |
|---|---|
| float3 |
Properties
Centroid
Declaration
public float3 Centroid { get; }
Property Value
| Type | Description |
|---|---|
| float3 |
Normal
Declaration
public float3 Normal { get; }
Property Value
| Type | Description |
|---|---|
| float3 |
Methods
ClosestPoint(float3)
Returns the closest point to p on this triangle
Declaration
public float3 ClosestPoint(float3 p)
Parameters
| Type | Name | Description |
|---|---|---|
| float3 | p | The point to get the closest point to |
Returns
| Type | Description |
|---|---|
| float3 | The closest point on this triangle |
IsDegenerate()
Declaration
public bool IsDegenerate()
Returns
| Type | Description |
|---|---|
| bool |
ProjectPointOntoPlane(float3)
Projects a point in 3D space onto the plane this triangle lies in
Declaration
public float3 ProjectPointOntoPlane(float3 point)
Parameters
| Type | Name | Description |
|---|---|---|
| float3 | point | The point to project |
Returns
| Type | Description |
|---|---|
| float3 | The closest point on the plane of this triangle, it's possible for the returned point to be outside of the triangle itself. |
Raycast(Ray, out float)
Checks if the specified ray hits the triangle. Möller–Trumbore ray-triangle intersection algorithm implementation.
Declaration
public bool Raycast(Ray ray, out float hitT)
Parameters
| Type | Name | Description |
|---|---|---|
| Ray | ray | The ray to test hit for. |
| float | hitT | how far along the ray was the triangle hit |
Returns
| Type | Description |
|---|---|
| bool |
|
Raycast(Ray, out float3)
Checks if the specified ray hits the triangle. Möller–Trumbore ray-triangle intersection algorithm implementation.
Declaration
public bool Raycast(Ray ray, out float3 point)
Parameters
| Type | Name | Description |
|---|---|---|
| Ray | ray | The ray to test hit for. |
| float3 | point | The point where the triangle was hit. |
Returns
| Type | Description |
|---|---|
| bool |
|