Struct SimplexSolver
Implements the Gilbert-Johnson-Keerthi (GJK) simplex solver for finding the closest point to the origin on a simplex (point, line segment, triangle, or tetrahedron).
public struct SimplexSolver
- Inherited Members
Remarks
This solver iteratively reduces the simplex to the feature closest to the origin. It handles degeneracy by falling back to lower-dimensional features when the current simplex is near-degenerate.
Complexity: O(1) per vertex addition for point/segment, O(1) for triangle, O(1) for tetrahedron with early-out optimizations.
Methods
AddVertex(in JVector, out JVector)
Adds a vertex to the simplex and computes the new closest point to the origin.
public bool AddVertex(in JVector vertex, out JVector closest)
Parameters
vertexJVectorThe vertex to add (a point on the Minkowski difference).
closestJVectorWhen this method returns, contains the point on the reduced simplex closest to the origin.
Returns
- bool
trueif the origin is not contained within the simplex (continue iterating);falseif the origin is enclosed by the tetrahedron (collision detected).
Reset()
Resets the solver to an empty simplex.
public void Reset()