bool PointOnSegment(Vertex A, Vertex B, Vertex P, float distanceEpsilon, float parametricEpsilon, out float pointSegmentDistance) { // Determines whether P lies within the segment A-B float segmentLength = Vertex.Distance(A, B); float tangentABdist = Vertex.Dot(Vertex.Normalize(B - A), Vertex.Normalize(P - A)) * (P - A).Length(); float u = tangentABdist / segmentLength; if (u < parametricEpsilon || u > 1.0 - parametricEpsilon) { pointSegmentDistance = float.MaxValue; return(false); } Vertex isect = A + (B - A) * u; float dist = (P - isect).Length(); pointSegmentDistance = dist; if (dist > distanceEpsilon * segmentLength) { return(false); } return(true); }
public void BoundingCircunference(out Vertex center, out float radius) { center = (max + min) * 0.5f; radius = Vertex.Distance(center, min); }