public void AddPoint(Point point) { points.Add(point); }
private Line GetClosestLine(Point point) { return lines.Count == 0 ? null : lines.MinBy(x => GetLinesDistance(x, point)).First(); }
private Point GetClosestPoint(Point point) { return points.Count == 0 ? null : points.MinBy(x => GetPointsDistance(x, point)).First(); }
private static double GetLinesDistance(Line line, Point point) { return Math.Sqrt(Math.Pow(line.CentrePoint.X - point.X, 2) + Math.Pow(line.CentrePoint.Y - point.Y, 2)); }
private static double GetPointsDistance(Point point1, Point point2) { return Math.Sqrt(Math.Pow(point1.X - point2.X, 2) + Math.Pow(point1.Y - point2.Y, 2)); }
private static Point GetOtherPoint(Line line, Point point) { return line.Point1 == point ? line.Point2 : line.Point1; }