Class Distance
- Namespace
- MathAssertions.Geometry3D
- Assembly
- MathAssertions.dll
Closest-point distance functions from a Vector3 to selected geometry
primitives. Implemented as extension methods so call sites read naturally
(point.DistanceFrom(plane), point.DistanceFrom(segment)).
public static class Distance
- Inheritance
-
Distance
- Inherited Members
Methods
DistanceFrom(Vector3, LineSegment3D)
Closest-point distance from point to the finite line segment
seg. The closest point is either an interior projection (when
the projection parameter is in [0, 1]) or the nearer endpoint (otherwise).
public static double DistanceFrom(this Vector3 point, LineSegment3D seg)
Parameters
pointVector3Point to measure from.
segLineSegment3DSegment to measure to.
Returns
- double
The unsigned closest-point distance.
Remarks
Reference: Ericson, Real-Time Collision Detection, §5.1.2.
DistanceFrom(Vector3, Triangle3D)
Closest-point distance from point to triangle.
The closest point is on the triangle's interior, on one of its three edges, or at
one of its three vertices; the implementation classifies which Voronoi region
contains point's projection and returns the corresponding
distance.
public static double DistanceFrom(this Vector3 point, Triangle3D triangle)
Parameters
pointVector3Point to measure from.
triangleTriangle3DTriangle to measure to.
Returns
- double
The unsigned closest-point distance.
Remarks
Reference: Ericson, Real-Time Collision Detection, §5.1.5. The barycentric classification is the standard one; for degenerate triangles the result may be NaN when the projection lands in the interior path (the underlying division by zero produces NaN), but degenerate inputs that exit through the vertex or edge branches return a finite distance. Callers needing a well-defined verdict on degenerate geometry should guard with IsDegenerate(Triangle3D, double).
DistanceFrom(Vector3, Plane)
Perpendicular distance from point to plane.
Assumes the plane normal is unit-length (the standard Plane
convention from Plane.CreateFromVertices); otherwise the result is scaled
by the normal's magnitude.
public static double DistanceFrom(this Vector3 point, Plane plane)
Parameters
Returns
- double
The unsigned perpendicular distance.