1
1
"""
2
- A module providing some utility functions regarding Bezier path manipulation.
2
+ A module providing some utility functions regarding Bézier path manipulation.
3
3
"""
4
4
5
5
from functools import lru_cache
@@ -94,7 +94,7 @@ def _de_casteljau1(beta, t):
94
94
95
95
def split_de_casteljau (beta , t ):
96
96
"""
97
- Split a Bezier segment defined by its control points *beta* into two
97
+ Split a Bézier segment defined by its control points *beta* into two
98
98
separate segments divided at *t* and return their control points.
99
99
"""
100
100
beta = np .asarray (beta )
@@ -113,7 +113,7 @@ def split_de_casteljau(beta, t):
113
113
def find_bezier_t_intersecting_with_closedpath (
114
114
bezier_point_at_t , inside_closedpath , t0 = 0. , t1 = 1. , tolerance = 0.01 ):
115
115
"""
116
- Find the intersection of the Bezier curve with a closed path.
116
+ Find the intersection of the Bézier curve with a closed path.
117
117
118
118
The intersection point *t* is approximated by two parameters *t0*, *t1*
119
119
such that *t0* <= *t* <= *t1*.
@@ -126,7 +126,7 @@ def find_bezier_t_intersecting_with_closedpath(
126
126
Parameters
127
127
----------
128
128
bezier_point_at_t : callable
129
- A function returning x, y coordinates of the Bezier at parameter *t*.
129
+ A function returning x, y coordinates of the Bézier at parameter *t*.
130
130
It must have the signature::
131
131
132
132
bezier_point_at_t(t: float) -> tuple[float, float]
@@ -146,7 +146,7 @@ def find_bezier_t_intersecting_with_closedpath(
146
146
Returns
147
147
-------
148
148
t0, t1 : float
149
- The Bezier path parameters.
149
+ The Bézier path parameters.
150
150
"""
151
151
start = bezier_point_at_t (t0 )
152
152
end = bezier_point_at_t (t1 )
@@ -180,7 +180,7 @@ def find_bezier_t_intersecting_with_closedpath(
180
180
181
181
class BezierSegment :
182
182
"""
183
- A d-dimensional Bezier segment.
183
+ A d-dimensional Bézier segment.
184
184
185
185
Parameters
186
186
----------
@@ -199,7 +199,7 @@ def __init__(self, control_points):
199
199
200
200
def __call__ (self , t ):
201
201
"""
202
- Evaluate the Bezier curve at point(s) t in [0, 1].
202
+ Evaluate the Bézier curve at point(s) *t* in [0, 1].
203
203
204
204
Parameters
205
205
----------
@@ -239,15 +239,15 @@ def degree(self):
239
239
@property
240
240
def polynomial_coefficients (self ):
241
241
r"""
242
- The polynomial coefficients of the Bezier curve.
242
+ The polynomial coefficients of the Bézier curve.
243
243
244
244
.. warning:: Follows opposite convention from `numpy.polyval`.
245
245
246
246
Returns
247
247
-------
248
248
(n+1, d) array
249
249
Coefficients after expanding in polynomial basis, where :math:`n`
250
- is the degree of the bezier curve and :math:`d` its dimension.
250
+ is the degree of the Bézier curve and :math:`d` its dimension.
251
251
These are the numbers (:math:`C_j`) such that the curve can be
252
252
written :math:`\sum_{j=0}^n C_j t^j`.
253
253
@@ -308,12 +308,12 @@ def axis_aligned_extrema(self):
308
308
def split_bezier_intersecting_with_closedpath (
309
309
bezier , inside_closedpath , tolerance = 0.01 ):
310
310
"""
311
- Split a Bezier curve into two at the intersection with a closed path.
311
+ Split a Bézier curve into two at the intersection with a closed path.
312
312
313
313
Parameters
314
314
----------
315
315
bezier : (N, 2) array-like
316
- Control points of the Bezier segment. See `.BezierSegment`.
316
+ Control points of the Bézier segment. See `.BezierSegment`.
317
317
inside_closedpath : callable
318
318
A function returning True if a given point (x, y) is inside the
319
319
closed path. See also `.find_bezier_t_intersecting_with_closedpath`.
@@ -324,7 +324,7 @@ def split_bezier_intersecting_with_closedpath(
324
324
Returns
325
325
-------
326
326
left, right
327
- Lists of control points for the two Bezier segments.
327
+ Lists of control points for the two Bézier segments.
328
328
"""
329
329
330
330
bz = BezierSegment (bezier )
@@ -461,13 +461,13 @@ def check_if_parallel(dx1, dy1, dx2, dy2, tolerance=1.e-5):
461
461
462
462
def get_parallels (bezier2 , width ):
463
463
"""
464
- Given the quadratic Bezier control points *bezier2*, returns
465
- control points of quadratic Bezier lines roughly parallel to given
464
+ Given the quadratic Bézier control points *bezier2*, returns
465
+ control points of quadratic Bézier lines roughly parallel to given
466
466
one separated by *width*.
467
467
"""
468
468
469
469
# The parallel Bezier lines are constructed by following ways.
470
- # c1 and c2 are control points representing the begin and end of the
470
+ # c1 and c2 are control points representing the start and end of the
471
471
# Bezier line.
472
472
# cm is the middle point
473
473
@@ -485,7 +485,7 @@ def get_parallels(bezier2, width):
485
485
cos_t2 , sin_t2 = cos_t1 , sin_t1
486
486
else :
487
487
# t1 and t2 is the angle between c1 and cm, cm, c2. They are
488
- # also a angle of the tangential line of the path at c1 and c2
488
+ # also an angle of the tangential line of the path at c1 and c2
489
489
cos_t1 , sin_t1 = get_cos_sin (c1x , c1y , cmx , cmy )
490
490
cos_t2 , sin_t2 = get_cos_sin (cmx , cmy , c2x , c2y )
491
491
@@ -535,7 +535,7 @@ def get_parallels(bezier2, width):
535
535
536
536
def find_control_points (c1x , c1y , mmx , mmy , c2x , c2y ):
537
537
"""
538
- Find control points of the Bezier curve passing through (*c1x*, *c1y*),
538
+ Find control points of the Bézier curve passing through (*c1x*, *c1y*),
539
539
(*mmx*, *mmy*), and (*c2x*, *c2y*), at parametric values 0, 0.5, and 1.
540
540
"""
541
541
cmx = .5 * (4 * mmx - (c1x + c2x ))
@@ -545,8 +545,8 @@ def find_control_points(c1x, c1y, mmx, mmy, c2x, c2y):
545
545
546
546
def make_wedged_bezier2 (bezier2 , width , w1 = 1. , wm = 0.5 , w2 = 0. ):
547
547
"""
548
- Being similar to get_parallels, returns control points of two quadratic
549
- Bezier lines having a width roughly parallel to given one separated by
548
+ Being similar to ` get_parallels` , returns control points of two quadratic
549
+ Bézier lines having a width roughly parallel to given one separated by
550
550
*width*.
551
551
"""
552
552
@@ -556,7 +556,7 @@ def make_wedged_bezier2(bezier2, width, w1=1., wm=0.5, w2=0.):
556
556
c3x , c3y = bezier2 [2 ]
557
557
558
558
# t1 and t2 is the angle between c1 and cm, cm, c3.
559
- # They are also a angle of the tangential line of the path at c1 and c3
559
+ # They are also an angle of the tangential line of the path at c1 and c3
560
560
cos_t1 , sin_t1 = get_cos_sin (c1x , c1y , cmx , cmy )
561
561
cos_t2 , sin_t2 = get_cos_sin (cmx , cmy , c3x , c3y )
562
562
0 commit comments