Table of Contents

Struct JTriangle

Namespace
Jitter2.LinearMath
Assembly
Jitter2.dll

Represents a triangle defined by three vertices.

public struct JTriangle : IEquatable<JTriangle>
Implements
Inherited Members

Constructors

JTriangle(in JVector, in JVector, in JVector)

Represents a triangle defined by three vertices.

public JTriangle(in JVector v0, in JVector v1, in JVector v2)

Parameters

v0 JVector
v1 JVector
v2 JVector

Fields

V0

The first vertex of the triangle.

public JVector V0

Field Value

JVector

V1

The second vertex of the triangle.

public JVector V1

Field Value

JVector

V2

The third vertex of the triangle.

public JVector V2

Field Value

JVector

Methods

ClosestPoint(JVector)

Finds the closest point on the triangle surface to a specified point.

public readonly JVector ClosestPoint(JVector point)

Parameters

point JVector

The query point.

Returns

JVector

The point on the triangle closest to the query point.

Equals(JTriangle)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(JTriangle other)

Parameters

other JTriangle

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetArea()

Calculates the area of the triangle.

public readonly float GetArea()

Returns

float

GetBoundingBox()

Calculates the axis-aligned bounding box (AABB) of this triangle.

public readonly JBoundingBox GetBoundingBox()

Returns

JBoundingBox

GetCenter()

Calculates the geometric center (centroid) of the triangle.

public readonly JVector GetCenter()

Returns

JVector

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetNormal()

Calculates the face normal of the triangle. The direction follows the Right-Hand Rule (counter-clockwise winding).

public readonly JVector GetNormal()

Returns

JVector

The non-normalized normal vector.

RayIntersect(in JVector, in JVector, CullMode, out JVector, out float)

Checks if a ray intersects the triangle.

public readonly bool RayIntersect(in JVector origin, in JVector direction, JTriangle.CullMode cullMode, out JVector normal, out float lambda)

Parameters

origin JVector

The starting point (origin) of the ray.

direction JVector

The direction vector of the ray.

cullMode JTriangle.CullMode

Determines whether to ignore triangles based on their winding order (Front/Back facing).

normal JVector

Output: The normalized surface normal at the point of intersection.

lambda float

Output: The distance along the direction vector where the intersection occurs (hit point = origin + lambda * direction).

Returns

bool

true if the ray intersects the triangle; otherwise, false.

ToString()

Returns a string representation of the JTriangle.

public override readonly string ToString()

Returns

string

Operators

operator ==(JTriangle, JTriangle)

public static bool operator ==(JTriangle left, JTriangle right)

Parameters

left JTriangle
right JTriangle

Returns

bool

operator !=(JTriangle, JTriangle)

public static bool operator !=(JTriangle left, JTriangle right)

Parameters

left JTriangle
right JTriangle

Returns

bool