@@ -949,36 +949,70 @@ def unit_circle_righthalf(cls):
949
949
return cls ._unit_circle_righthalf
950
950
951
951
@classmethod
952
- def arc (cls ,theta1 ,theta2 ,n = None ,is_wedge = False ):
952
+ def arc (cls ,theta1 ,theta2 ,n = None ,is_wedge = False , wrap = True ):
953
953
"""
954
954
Return a `Path` for the unit circle arc from angles *theta1* to
955
955
*theta2* (in degrees).
956
956
957
- *theta2* is unwrapped to produce the shortest arc within 360 degrees.
958
- That is, if *theta2* > *theta1* + 360, the arc will be from *theta1* to
959
- *theta2* - 360 and not a full circle plus some extra overlap.
960
-
961
- If *n* is provided, it is the number of spline segments to make.
962
- If *n* is not provided, the number of spline segments is
963
- determined based on the delta between *theta1* and *theta2*.
957
+ Parameters
958
+ ----------
959
+ theta1, theta2 : float
960
+ The angles (in degrees) of the start and end of the arc. If the
961
+ arc is greater than 360 degrees, then the arc will be wrapped to
962
+ fit between theta1 and theta1 + 360, if *wrap* is True.
963
+
964
+ n : int, optional
965
+ The number of spline segments to make. If not provided, the number
966
+ of spline segments is determined based on the delta between
967
+ *theta1* and *theta2*.
968
+
969
+ is_wedge : bool, default: False
970
+ If True, the arc is a wedge. The first vertex is the center of the
971
+ wedge, the second vertex is the start of the arc, and the last
972
+ vertex is the end of the arc. The wedge is closed with a line
973
+ segment to the center of the wedge. If False, the arc is a
974
+ polyline. The first vertex is the start of the arc, and the last
975
+ vertex is the end of the arc. The arc is closed with a line
976
+ segment to the start of the arc. The wedge is not closed with a
977
+ line segment to the start of the arc.
978
+
979
+ wrap : bool, default: True
980
+ If True, the arc is wrapped to fit between *theta1* and *theta1* +
981
+ 360 degrees. If False, the arc is not wrapped. The arc will be
982
+ drawn from *theta1* to *theta2*.
964
983
965
- Masionobe, L. 2003. `Drawing an elliptical arc using
966
- polylines, quadratic or cubic Bezier curves
984
+ Notes
985
+ -----
986
+ The arc is approximated using cubic Bézier curves, as described in
987
+ Masionobe, L. 2003. `Drawing an elliptical arc using polylines,
988
+ quadratic or cubic Bezier curves
967
989
<https://web.archive.org/web/20190318044212/http://www.spaceroots.org/documents/ellipse/index.html>`_.
968
990
"""
969
- halfpi = np .pi * 0.5
970
991
971
992
eta1 = theta1
972
- eta2 = theta2 - 360 * np .floor ((theta2 - theta1 )/ 360 )
973
- # Ensure 2pi range is not flattened to 0 due to floating-point errors,
974
- # but don't try to expand existing 0 range.
975
- if theta2 != theta1 and eta2 <= eta1 :
976
- eta2 += 360
993
+ if wrap :
994
+ # Wrap theta2 to 0-360 degrees from theta1.
995
+ eta2 = np .mod (theta2 - theta1 ,360.0 )+ theta1
996
+ print ('Eta1, Eta20' ,eta1 ,eta2 )
997
+ # Ensure 360-deg range is not flattened to 0 due to floating-point
998
+ # errors, but don't try to expand existing 0 range.
999
+ if theta2 != theta1 and eta2 <= eta1 :
1000
+ eta2 += 360
1001
+ print ('Eta1, Eta2' ,eta1 ,eta2 )
1002
+ else :
1003
+ eta2 = theta2
977
1004
eta1 ,eta2 = np .deg2rad ([eta1 ,eta2 ])
978
1005
979
1006
# number of curve segments to make
980
1007
if n is None :
981
- n = int (2 ** np .ceil ((eta2 - eta1 )/ halfpi ))
1008
+ if np .abs (eta2 - eta1 )<= 2.2 * np .pi :
1009
+ # this doesn't need to grow exponentially, but we have left
1010
+ # this way for back compatibility
1011
+ n = int (2 ** np .ceil (2 * np .abs (eta2 - eta1 )/ np .pi ))
1012
+ print ('Here' )
1013
+ else :
1014
+ # this will not grow exponentially if we allow wrapping arcs:
1015
+ n = int (2 * np .ceil (2 * np .abs (eta2 - eta1 )/ np .pi ))
982
1016
if n < 1 :
983
1017
raise ValueError ("n must be >= 1 or None" )
984
1018
@@ -1028,22 +1062,29 @@ def arc(cls, theta1, theta2, n=None, is_wedge=False):
1028
1062
return cls (vertices ,codes ,readonly = True )
1029
1063
1030
1064
@classmethod
1031
- def wedge (cls ,theta1 ,theta2 ,n = None ):
1065
+ def wedge (cls ,theta1 ,theta2 ,n = None , wrap = True ):
1032
1066
"""
1033
1067
Return a `Path` for the unit circle wedge from angles *theta1* to
1034
1068
*theta2* (in degrees).
1035
1069
1036
- *theta2* is unwrapped to produce the shortest wedge within 360 degrees.
1037
- That is, if *theta2* > *theta1* + 360, the wedge will be from *theta1*
1038
- to *theta2* - 360 and not a full circle plus some extra overlap.
1039
-
1040
- If *n* is provided, it is the number of spline segments to make.
1041
- If *n* is not provided, the number of spline segments is
1042
- determined based on the delta between *theta1* and *theta2*.
1043
-
1044
- See `Path.arc` for the reference on the approximation used.
1045
- """
1046
- return cls .arc (theta1 ,theta2 ,n ,True )
1070
+ Parameters
1071
+ ----------
1072
+ theta1, theta2 : float
1073
+ The angles (in degrees) of the start and end of the arc. If the
1074
+ arc is greater than 360 degrees, then the arc will be wrapped to
1075
+ fit between theta1 and theta1 + 360, if *wrap* is True.
1076
+
1077
+ n : int, optional
1078
+ The number of spline segments to make. If not provided, the number
1079
+ of spline segments is determined based on the delta between
1080
+ *theta1* and *theta2*.
1081
+
1082
+ wrap : bool, default: True
1083
+ If True, the arc is wrapped to fit between *theta1* and *theta1* +
1084
+ 360 degrees. If False, the arc is not wrapped. The arc will be
1085
+ drawn from *theta1* to *theta2*.
1086
+ """
1087
+ return cls .arc (theta1 ,theta2 ,n ,wedge = True ,wrap = wrap )
1047
1088
1048
1089
@staticmethod
1049
1090
@lru_cache (8 )