@@ -94,16 +94,15 @@ def split_de_casteljau(beta, t):
94
94
return left_beta , right_beta
95
95
96
96
97
- # FIXME spelling mistake in the name of the parameter ``tolerence``
98
- def find_bezier_t_intersecting_with_closedpath (bezier_point_at_t ,
99
- inside_closedpath ,
100
- t0 = 0. , t1 = 1. , tolerence = 0.01 ):
97
+ @cbook ._rename_parameter ("3.1" , "tolerence" , "tolerance" )
98
+ def find_bezier_t_intersecting_with_closedpath (
99
+ bezier_point_at_t , inside_closedpath , t0 = 0. , t1 = 1. , tolerance = 0.01 ):
101
100
""" Find a parameter t0 and t1 of the given bezier path which
102
101
bounds the intersecting points with a provided closed
103
102
path(*inside_closedpath*). Search starts from *t0* and *t1* and it
104
103
uses a simple bisecting algorithm therefore one of the end point
105
104
must be inside the path while the orther doesn't. The search stop
106
- when |t0-t1| gets smaller than the given tolerence .
105
+ when |t0-t1| gets smaller than the given tolerance .
107
106
value for
108
107
109
108
- bezier_point_at_t : a function which returns x, y coordinates at *t*
@@ -125,8 +124,8 @@ def find_bezier_t_intersecting_with_closedpath(bezier_point_at_t,
125
124
126
125
while True :
127
126
128
- # return if the distance is smaller than the tolerence
129
- if np .hypot (start [0 ] - end [0 ], start [1 ] - end [1 ]) < tolerence :
127
+ # return if the distance is smaller than the tolerance
128
+ if np .hypot (start [0 ] - end [0 ], start [1 ] - end [1 ]) < tolerance :
130
129
return t0 , t1
131
130
132
131
# calculate the middle point
@@ -177,9 +176,9 @@ def point_at_t(self, t):
177
176
return _x , _y
178
177
179
178
180
- def split_bezier_intersecting_with_closedpath ( bezier ,
181
- inside_closedpath ,
182
- tolerence = 0.01 ):
179
+ @ cbook . _rename_parameter ( "3.1" , "tolerence" , "tolerance" )
180
+ def split_bezier_intersecting_with_closedpath (
181
+ bezier , inside_closedpath , tolerance = 0.01 ):
183
182
184
183
"""
185
184
bezier : control points of the bezier segment
@@ -190,17 +189,17 @@ def split_bezier_intersecting_with_closedpath(bezier,
190
189
bz = BezierSegment (bezier )
191
190
bezier_point_at_t = bz .point_at_t
192
191
193
- t0 , t1 = find_bezier_t_intersecting_with_closedpath (bezier_point_at_t ,
194
- inside_closedpath ,
195
- tolerence = tolerence )
192
+ t0 , t1 = find_bezier_t_intersecting_with_closedpath (
193
+ bezier_point_at_t , inside_closedpath , tolerance = tolerance )
196
194
197
195
_left , _right = split_de_casteljau (bezier , (t0 + t1 ) / 2. )
198
196
return _left , _right
199
197
200
198
201
- def find_r_to_boundary_of_closedpath (inside_closedpath , xy ,
202
- cos_t , sin_t ,
203
- rmin = 0. , rmax = 1. , tolerence = 0.01 ):
199
+ @cbook .deprecated ("3.1" )
200
+ @cbook ._rename_parameter ("3.1" , "tolerence" , "tolerance" )
201
+ def find_r_to_boundary_of_closedpath (
202
+ inside_closedpath , xy , cos_t , sin_t , rmin = 0. , rmax = 1. , tolerance = 0.01 ):
204
203
"""
205
204
Find a radius r (centered at *xy*) between *rmin* and *rmax* at
206
205
which it intersect with the path.
@@ -216,14 +215,14 @@ def find_r_to_boundary_of_closedpath(inside_closedpath, xy,
216
215
def _f (r ):
217
216
return cos_t * r + cx , sin_t * r + cy
218
217
219
- find_bezier_t_intersecting_with_closedpath (_f , inside_closedpath ,
220
- t0 = rmin , t1 = rmax ,
221
- tolerence = tolerence )
218
+ find_bezier_t_intersecting_with_closedpath (
219
+ _f , inside_closedpath , t0 = rmin , t1 = rmax , tolerance = tolerance )
222
220
223
221
# matplotlib specific
224
222
225
223
226
- def split_path_inout (path , inside , tolerence = 0.01 , reorder_inout = False ):
224
+ @cbook ._rename_parameter ("3.1" , "tolerence" , "tolerance" )
225
+ def split_path_inout (path , inside , tolerance = 0.01 , reorder_inout = False ):
227
226
""" divide a path into two segment at the point where inside(x, y)
228
227
becomes False.
229
228
"""
@@ -252,7 +251,7 @@ def split_path_inout(path, inside, tolerence=0.01, reorder_inout=False):
252
251
253
252
bp = bezier_path .reshape ((- 1 , 2 ))
254
253
left , right = split_bezier_intersecting_with_closedpath (
255
- bp , inside , tolerence )
254
+ bp , inside , tolerance )
256
255
if len (left ) == 2 :
257
256
codes_left = [Path .LINETO ]
258
257
codes_right = [Path .MOVETO , Path .LINETO ]
@@ -305,7 +304,8 @@ def get_cos_sin(x0, y0, x1, y1):
305
304
return dx / d , dy / d
306
305
307
306
308
- def check_if_parallel (dx1 , dy1 , dx2 , dy2 , tolerence = 1.e-5 ):
307
+ @cbook ._rename_parameter ("3.1" , "tolerence" , "tolerance" )
308
+ def check_if_parallel (dx1 , dy1 , dx2 , dy2 , tolerance = 1.e-5 ):
309
309
""" returns
310
310
* 1 if two lines are parralel in same direction
311
311
* -1 if two lines are parralel in opposite direction
@@ -314,9 +314,9 @@ def check_if_parallel(dx1, dy1, dx2, dy2, tolerence=1.e-5):
314
314
theta1 = np .arctan2 (dx1 , dy1 )
315
315
theta2 = np .arctan2 (dx2 , dy2 )
316
316
dtheta = np .abs (theta1 - theta2 )
317
- if dtheta < tolerence :
317
+ if dtheta < tolerance :
318
318
return 1
319
- elif np .abs (dtheta - np .pi ) < tolerence :
319
+ elif np .abs (dtheta - np .pi ) < tolerance :
320
320
return - 1
321
321
else :
322
322
return False
0 commit comments