public bool GetPointClosestToOrigin(ref RaySimplex simplex, out Vector3 point)
{
//This method finds the closest point on the simplex to the origin.
//Barycentric coordinates are assigned to the MinimumNormCoordinates as necessary to perform the inclusion calculation.
//If the simplex is a tetrahedron and found to be overlapping the origin, the function returns true to tell the caller to terminate.
//Elements of the simplex that are not used to determine the point of minimum norm are removed from the simplex.
switch (State)
{
case SimplexState.Point:
point = A;
break;
case SimplexState.Segment:
GetPointOnSegmentClosestToOrigin(ref simplex, out point);
break;
case SimplexState.Triangle:
GetPointOnTriangleClosestToOrigin(ref simplex, out point);
break;
case SimplexState.Tetrahedron:
return GetPointOnTetrahedronClosestToOrigin(ref simplex, out point);
default:
point = Toolbox.ZeroVector;
break;
}
return false;
}