TerrainDisplay.Collision.Intersection.SqDistPointSegment C# (CSharp) Method

SqDistPointSegment() public static method

public static SqDistPointSegment ( System.Vector3 a, System.Vector3 b, System.Vector3 c ) : float
a System.Vector3
b System.Vector3
c System.Vector3
return float
        public static float SqDistPointSegment(Vector3 a, Vector3 b, Vector3 c)
        {
            var vector = b - a;
            var vector2 = c - a;
            var vector3 = c - b;
            var num = Vector3.Dot(vector2, vector);
            if (num <= 0f)
            {
                return Vector3.Dot(vector2, vector2);
            }
            var num2 = Vector3.Dot(vector, vector);
            if (num >= num2)
            {
                return Vector3.Dot(vector3, vector3);
            }
            return (Vector3.Dot(vector2, vector2) - ((num * num) / num2));
        }