Skip to main content

DistanceToLine

A static class in Root.Township, the global namespace.

Maths helpers for the distance from a point to a line segment, in 3D or 2D.

Methods​

MemberWhat it is
static float Evaluate(Vector3 point, Vector3 start, Vector3 end)Distance from the point to the segment; can also give how far along it the closest point is and the point itself.
static float Evaluate(Vector3 point, Vector3 start, Vector3 end, out float lineProgress)Distance from the point to the segment; can also give how far along it the closest point is and the point itself.
static float Evaluate(Vector3 point, Vector3 start, Vector3 end, out float lineProgress, out Vector3 closest)Distance from the point to the segment; can also give how far along it the closest point is and the point itself.
static float Evaluate(Vector2 point, Vector2 start, Vector2 end)Distance from the point to the segment; can also give how far along it the closest point is and the point itself.
static float Evaluate(Vector2 point, Vector2 start, Vector2 end, out float lineProgress)Distance from the point to the segment; can also give how far along it the closest point is and the point itself.
static float Evaluate(Vector2 point, Vector2 start, Vector2 end, out float lineProgress, out Vector2 closest)Distance from the point to the segment; can also give how far along it the closest point is and the point itself.
static float EvaluateSquared(Vector3 point, Vector3 start, Vector3 end)Same as Evaluate but returns the squared distance.
static float EvaluateSquared(Vector3 point, Vector3 start, Vector3 end, out float lineProgress)Same as Evaluate but returns the squared distance.
static float EvaluateSquared(Vector3 point, Vector3 start, Vector3 end, out float lineProgress, out Vector3 closest)Same as Evaluate but returns the squared distance.
static float EvaluateSquared(Vector2 point, Vector2 start, Vector2 end)Same as Evaluate but returns the squared distance.
static float EvaluateSquared(Vector2 point, Vector2 start, Vector2 end, out float lineProgress)Same as Evaluate but returns the squared distance.
static float EvaluateSquared(Vector2 point, Vector2 start, Vector2 end, out float lineProgress, out Vector2 closest)Same as Evaluate but returns the squared distance.