public static Vector2D Truncate(this Vector2D v, double max) { if (v.Length() > max) { var normalized = v.Normalize(); return(normalized * max); } return(v.Clone()); }
/** * Returns the distance from current position to the given target */ public double Distance(Vector2D target) { Vector2D ToTarget = target.Clone().Sub(this); return(ToTarget.Length()); }