@@ -168,24 +168,17 @@ def __init__(self, control_points):
168168 """
169169 _o = len (control_points )
170170 self ._orders = np .arange (_o )
171- _coeff = BezierSegment ._binom_coeff [_o - 1 ]
172-
173- _control_points = np .asarray (control_points )
174- xx = _control_points [:, 0 ]
175- yy = _control_points [:, 1 ]
176171
172+ _coeff = BezierSegment ._binom_coeff [_o - 1 ]
173+ xx , yy = np .asarray (control_points ).T
177174 self ._px = xx * _coeff
178175 self ._py = yy * _coeff
179176
180177 def point_at_t (self , t ):
181178 "evaluate a point at t"
182- one_minus_t_powers = np .power (1. - t , self ._orders )[::- 1 ]
183- t_powers = np .power (t , self ._orders )
184-
185- tt = one_minus_t_powers * t_powers
186- _x = sum (tt * self ._px )
187- _y = sum (tt * self ._py )
188-
179+ tt = ((1 - t ) ** self ._orders )[::- 1 ] * t ** self ._orders
180+ _x = np .dot (tt , self ._px )
181+ _y = np .dot (tt , self ._py )
189182 return _x , _y
190183
191184
@@ -245,7 +238,6 @@ def split_path_inout(path, inside, tolerence=0.01, reorder_inout=False):
245238 ctl_points , command = next (path_iter )
246239 begin_inside = inside (ctl_points [- 2 :]) # true if begin point is inside
247240
248- bezier_path = None
249241 ctl_points_old = ctl_points
250242
251243 concat = np .concatenate
@@ -259,16 +251,13 @@ def split_path_inout(path, inside, tolerence=0.01, reorder_inout=False):
259251 if inside (ctl_points [- 2 :]) != begin_inside :
260252 bezier_path = concat ([ctl_points_old [- 2 :], ctl_points ])
261253 break
262-
263254 ctl_points_old = ctl_points
255+ else :
256+ raise ValueError ("The path does not intersect with the patch" )
264257
265- if bezier_path is None :
266- raise ValueError ("The path does not seem to intersect with the patch" )
267-
268- bp = list (zip (bezier_path [::2 ], bezier_path [1 ::2 ]))
269- left , right = split_bezier_intersecting_with_closedpath (bp ,
270- inside ,
271- tolerence )
258+ bp = bezier_path .reshape ((- 1 , 2 ))
259+ left , right = split_bezier_intersecting_with_closedpath (
260+ bp , inside , tolerence )
272261 if len (left ) == 2 :
273262 codes_left = [Path .LINETO ]
274263 codes_right = [Path .MOVETO , Path .LINETO ]
@@ -279,7 +268,7 @@ def split_path_inout(path, inside, tolerence=0.01, reorder_inout=False):
279268 codes_left = [Path .CURVE4 , Path .CURVE4 , Path .CURVE4 ]
280269 codes_right = [Path .MOVETO , Path .CURVE4 , Path .CURVE4 , Path .CURVE4 ]
281270 else :
282- raise ValueError ( )
271+ raise AssertionError ( "This should never be reached" )
283272
284273 verts_left = left [1 :]
285274 verts_right = right [:]
0 commit comments