public static double GetLength(Pnt p1, Pnt p2) { double dx = p2.x - p1.x; double dy = p2.y - p1.y; return(Math.Sqrt(dx * dx + dy * dy)); }
public static Pnt GetEndPoint(Pnt startP, double alpha, double length) { double x = length * Math.Cos(alpha) + startP.x; double y = length * Math.Sin(alpha) + startP.y; return(new Pnt(x, y)); }
public static int GetClosestPointId(Pnt origin, Pnt[] points) { int id = 0; double val = GetLength(origin, points[0]); for (int i = 1; i < points.Length; i++) { double dist = GetLength(origin, points[1]); if (dist < val) { id = i; val = dist; } } return(id); }
public Vector setStart(Pnt point) { return(move(point.x - x1, point.y - y1)); }
public Vector(Pnt p1, Pnt p2) : this(p1.x, p1.y, p2.x, p2.y) { }