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
Fields
V0
The first vertex of the triangle.
public JVector V0
Field Value
V1
The second vertex of the triangle.
public JVector V1
Field Value
V2
The third vertex of the triangle.
public JVector V2
Field Value
Methods
ClosestPoint(JVector)
Finds the closest point on the triangle surface to a specified point.
public readonly JVector ClosestPoint(JVector point)
Parameters
pointJVectorThe 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
otherJTriangleAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
GetBoundingBox()
Calculates the axis-aligned bounding box (AABB) of this triangle.
public readonly JBoundingBox GetBoundingBox()
Returns
GetCenter()
Calculates the geometric center (centroid) of the triangle.
public readonly JVector GetCenter()
Returns
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
originJVectorThe starting point (origin) of the ray.
directionJVectorThe direction vector of the ray.
cullModeJTriangle.CullModeDetermines whether to ignore triangles based on their winding order (Front/Back facing).
normalJVectorOutput: The normalized surface normal at the point of intersection.
lambdafloatOutput: The distance along the
directionvector where the intersection occurs (hit point = origin + lambda * direction).
Returns
- bool
trueif the ray intersects the triangle; otherwise,false.
ToString()
Returns a string representation of the JTriangle.
public override readonly string ToString()
Returns
Operators
operator ==(JTriangle, JTriangle)
public static bool operator ==(JTriangle left, JTriangle right)
Parameters
Returns
operator !=(JTriangle, JTriangle)
public static bool operator !=(JTriangle left, JTriangle right)