/// <summary> /// Creates an arc with the given center, start, and end points. Performs a check /// at the given precision to make sure that both the start and end points are /// the same distance from the center, throwing an exception if they're not. Note /// that because radius is generated from start point, the resultant arc's start /// point will be more accurate than the end point. /// </summary> /// <param name="center">Center of the arc.</param> /// <param name="startPoint">Start point of the arc.</param> /// <param name="endPoint">Point that end angle is projected through.</param> /// <param name="decimals">Precision at which to check the distance of the endpoints to the center. /// A negative value will perform an exact check.</param> public Arc2D(Point2D center, Point2D startPoint, Point2D endPoint, int decimals = 15) : this(center, center.DistanceTo(startPoint), 0, 0) { if ((decimals < 0 && center.DistanceTo(endPoint) != Radius) || (decimals >= 0 && center.DistanceTo(endPoint).RoundFromZero(decimals) != Radius.RoundFromZero(decimals))) { throw new Exception("Can't create arc from center and endpoints because endpoints have different distances from the center!"); } _startAngle = Circle.AngleThroughPoint(startPoint); _endAngle = Circle.AngleThroughPoint(endPoint); }
/// <summary> /// Creates an arc on the given circle with the start angle projected through /// the start point and the end angle projected through the end point. /// </summary> /// <param name="c">Circle that the arc lies on.</param> /// <param name="startPoint">Point that start angle is projected through.</param> /// <param name="endPoint">Point that end angle is projected through.</param> public Arc2D(Circle2D c, Point2D startPoint, Point2D endPoint) { this.Circle = c; _startAngle = c.AngleThroughPoint(startPoint); _endAngle = c.AngleThroughPoint(endPoint); }