/// <summary> /// The square distance between the given point and the line, defined by this segment. /// </summary> /// <param name="p">The point.</param> /// <returns>Returns the square distance between the given point and the line, defined by this segment.</returns> public double LineDistanceSqr(Vector2d p) { var ap = p - a; var dotprod = ab.Dot(ap); var projLenSq = dotprod * dotprod / ab.SqrMagnitude(); return(ap.SqrMagnitude() - projLenSq); }
public static double Angle(Vector2d from, Vector2d to) { return(Mathd.Acos(Mathd.Clamp(Vector2d.Dot(from.normalized, to.normalized), -1d, 1d)) * 57.29578d); }