public Arc2D(Point2D center, Point2D start, Point2D end) { if (Math.Abs(center.GetDistanceTo(start) - center.GetDistanceTo(end))>0.0001) { throw new Exception("Radius length is not equal!"); } this.CenterPt = center; this.StartPt = start; this.EndPt = end; }
private void button1_Click(object sender, EventArgs e) { try { Vector2D vec1 = new Vector2D(); Vector2D vec2 = new Vector2D(); Point2D center = new Point2D(2003.4945, 1103.6469); Point2D start = new Point2D(2494.6048, 982.6129); Point2D end = new Point2D(1499.1729, 1142.3536); Debug.WriteLine("distance between p1 p2 is : " + center.GetDistanceTo(start).ToString()); Debug.WriteLine("distance between p2 p3 is : " + end.GetDistanceTo(start).ToString()); Arc2D arc1 = new Arc2D(center, start, end); vec1 = center.GetVector2DTo(start); vec2 = center.GetVector2DTo(end); } catch (System.Exception ex) { Debug.WriteLine(ex.Message); } }
public Vector2D GetVector2DTo(Point2D p) { return new Vector2D(p.X - this.X, p.Y - this.Y); }
public Double GetDistanceTo(Point2D p) { Double dx = this.X - p.X; Double dy = this.Y - p.Y; return Math.Sqrt(dx * dx + dy * dy); }
public LineSegment2D(Point2D p1, Point2D p2) { this.StartPt = p1; this.EndPt = p2; }