File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -239,15 +239,20 @@ def __init__(self, control_points):
239
239
coeff = [math .factorial (self ._N - 1 )
240
240
// (math .factorial (i ) * math .factorial (self ._N - 1 - i ))
241
241
for i in range (self ._N )]
242
- self ._px = self ._cpoints .T * coeff
242
+ self ._px = ( self ._cpoints .T * coeff ). T
243
243
244
244
def __call__ (self , t ):
245
- return self .point_at_t (t )
245
+ t = np .array (t )
246
+ orders_shape = (1 ,)* t .ndim + self ._orders .shape
247
+ t_shape = t .shape + (1 ,) # self._orders.ndim == 1
248
+ orders = np .reshape (self ._orders , orders_shape )
249
+ rev_orders = np .reshape (self ._orders [::- 1 ], orders_shape )
250
+ t = np .reshape (t , t_shape )
251
+ return ((1 - t )** rev_orders * t ** orders ) @ self ._px
246
252
247
253
def point_at_t (self , t ):
248
254
"""Return the point on the Bezier curve for parameter *t*."""
249
- return tuple (
250
- self ._px @ (((1 - t ) ** self ._orders )[::- 1 ] * t ** self ._orders ))
255
+ return tuple (self (t ))
251
256
252
257
@property
253
258
def control_points (self ):
You can’t perform that action at this time.
0 commit comments