@@ -145,7 +145,7 @@ def find_bezier_t_intersecting_with_closedpath(
145
145
146
146
class BezierSegment (object ):
147
147
"""
148
- A simple class of a 2 -dimensional bezier segment
148
+ A D -dimensional Bezier segment.
149
149
"""
150
150
151
151
# Higher order bezier lines can be supported by simplying adding
@@ -156,24 +156,21 @@ class BezierSegment(object):
156
156
157
157
def __init__ (self , control_points ):
158
158
"""
159
- *control_points* : location of contol points. It needs have a
160
- shape of n * 2, where n is the order of the bezier line. 1<=
161
- n <= 3 is supported.
159
+ Parameters
160
+ ----------
161
+ control_points : (N, D) array
162
+ Location of control points. N = 2, 3 and 4 (linear, quadratic, and
163
+ cubic Beziers) are supported.
162
164
"""
163
165
_o = len (control_points )
164
166
self ._orders = np .arange (_o )
165
-
166
167
_coeff = BezierSegment ._binom_coeff [_o - 1 ]
167
- xx , yy = np .asarray (control_points ).T
168
- self ._px = xx * _coeff
169
- self ._py = yy * _coeff
168
+ self ._px = np .asarray (control_points ).T * _coeff
170
169
171
170
def point_at_t (self , t ):
172
- "evaluate a point at t"
173
- tt = ((1 - t ) ** self ._orders )[::- 1 ] * t ** self ._orders
174
- _x = np .dot (tt , self ._px )
175
- _y = np .dot (tt , self ._py )
176
- return _x , _y
171
+ """Return the point on the Bezier curve for parameter *t*."""
172
+ return tuple (
173
+ self ._px @ (((1 - t ) ** self ._orders )[::- 1 ] * t ** self ._orders ))
177
174
178
175
179
176
@cbook ._rename_parameter ("3.1" , "tolerence" , "tolerance" )
0 commit comments