public static DistancePointToLine ( Vector2 p, Vector2 a, Vector2 b ) : float | ||
p | Vector2 | |
a | Vector2 | |
b | Vector2 | |
Résultat | float |
public static float DistancePointToLine(Vector2 p, Vector2 a, Vector2 b)
{
Vector2 vector = b - a;
return (Mathf.Abs((float) (((b.x - a.x) * (a.y - p.y)) - ((a.x - p.x) * (b.y - a.y)))) / vector.magnitude);
}