@@ -856,6 +856,10 @@ def arc(cls, theta1, theta2, n=None, is_wedge=False):
856
856
Return an arc on the unit circle from angle
857
857
*theta1* to angle *theta2* (in degrees).
858
858
859
+ *theta2* is unwrapped to produce the shortest arc within 360 degrees.
860
+ That is, if *theta2* > *theta1* + 360, the arc will be from *theta1* to
861
+ *theta2* - 360 and not a full circle plus some extra overlap.
862
+
859
863
If *n* is provided, it is the number of spline segments to make.
860
864
If *n* is not provided, the number of spline segments is
861
865
determined based on the delta between *theta1* and *theta2*.
@@ -864,14 +868,15 @@ def arc(cls, theta1, theta2, n=None, is_wedge=False):
864
868
polylines, quadratic or cubic Bezier curves
865
869
<http://www.spaceroots.org/documents/ellipse/index.html>`_.
866
870
"""
867
- theta1 , theta2 = np .deg2rad ([theta1 , theta2 ])
868
-
869
- twopi = np .pi * 2.0
870
871
halfpi = np .pi * 0.5
871
872
872
- eta1 = np .arctan2 (np .sin (theta1 ), np .cos (theta1 ))
873
- eta2 = np .arctan2 (np .sin (theta2 ), np .cos (theta2 ))
874
- eta2 -= twopi * np .floor ((eta2 - eta1 ) / twopi )
873
+ eta1 = theta1
874
+ eta2 = theta2 - 360 * np .floor ((theta2 - theta1 ) / 360 )
875
+ # Ensure 2pi range is not flattened to 0 due to floating-point errors,
876
+ # but don't try to expand existing 0 range.
877
+ if theta2 != theta1 and eta2 <= eta1 :
878
+ eta2 += 360
879
+ eta1 , eta2 = np .deg2rad ([eta1 , eta2 ])
875
880
876
881
# number of curve segments to make
877
882
if n is None :
@@ -930,6 +935,10 @@ def wedge(cls, theta1, theta2, n=None):
930
935
Return a wedge of the unit circle from angle
931
936
*theta1* to angle *theta2* (in degrees).
932
937
938
+ *theta2* is unwrapped to produce the shortest wedge within 360 degrees.
939
+ That is, if *theta2* > *theta1* + 360, the wedge will be from *theta1*
940
+ to *theta2* - 360 and not a full circle plus some extra overlap.
941
+
933
942
If *n* is provided, it is the number of spline segments to make.
934
943
If *n* is not provided, the number of spline segments is
935
944
determined based on the delta between *theta1* and *theta2*.
0 commit comments