public static GetSquaredDistanceFromPointToLine ( System.Vector3 &p, System.Vector3 &a, System.Vector3 &b ) : float | ||
p | System.Vector3 | Point to check against the line. |
a | System.Vector3 | First point on the line. |
b | System.Vector3 | Second point on the line. |
리턴 | float |
public static float GetSquaredDistanceFromPointToLine(ref Vector3 p, ref Vector3 a, ref Vector3 b)
{
Vector3 ap, ab;
Vector3.Subtract(ref p, ref a, out ap);
Vector3.Subtract(ref b, ref a, out ab);
float e;
Vector3.Dot(ref ap, ref ab, out e);
return ap.LengthSquared() - e * e / ab.LengthSquared();
}