matplotlib.bezier
¶
A module providing some utility functions regarding Bezier path manipulation.

class
matplotlib.bezier.
BezierSegment
(control_points)[source]¶ Bases:
object
A ddimensional Bezier segment.
Parameters:  control_points(N, d) array
Location of the N control points.

axis_aligned_extrema
()[source]¶ Return the dimension and location of the curve's interior extrema.
The extrema are the points along the curve where one of its partial derivatives is zero.
Returns:  dimsarray of int
Index \(i\) of the partial derivative which is zero at each interior extrema.
 dzerosarray of float
Of same size as dims. The \(t\) such that \(d/dx_i B(t) = 0\)

property
control_points
¶ The control points of the curve.

property
degree
¶ Degree of the polynomial. One less the number of control points.

property
dimension
¶ The dimension of the curve.

property
polynomial_coefficients
¶ The polynomial coefficients of the Bezier curve.
Warning
Follows opposite convention from
numpy.polyval
.Returns:  (n+1, d) array
Coefficients after expanding in polynomial basis, where \(n\) is the degree of the bezier curve and \(d\) its dimension. These are the numbers (\(C_j\)) such that the curve can be written \(\sum_{j=0}^n C_j t^j\).
Notes
The coefficients are calculated as
\[{n \choose j} \sum_{i=0}^j (1)^{i+j} {j \choose i} P_i\]where \(P_i\) are the control points of the curve.

exception
matplotlib.bezier.
NonIntersectingPathException
[source]¶ Bases:
ValueError

matplotlib.bezier.
check_if_parallel
(dx1, dy1, dx2, dy2, tolerance=1e05)[source]¶ Check if two lines are parallel.
Parameters:  dx1, dy1, dx2, dy2float
The gradients dy/dx of the two lines.
 tolerancefloat
The angular tolerance in radians up to which the lines are considered parallel.
Returns:  is_parallel
 1 if two lines are parallel in same direction.
 1 if two lines are parallel in opposite direction.
 False otherwise.

matplotlib.bezier.
concatenate_paths
(paths)[source]¶ [Deprecated] Concatenate a list of paths into a single path.
Notes
Deprecated since version 3.3.

matplotlib.bezier.
find_bezier_t_intersecting_with_closedpath
(bezier_point_at_t, inside_closedpath, t0=0.0, t1=1.0, tolerance=0.01)[source]¶ Find the intersection of the Bezier curve with a closed path.
The intersection point t is approximated by two parameters t0, t1 such that t0 <= t <= t1.
Search starts from t0 and t1 and uses a simple bisecting algorithm therefore one of the end points must be inside the path while the other doesn't. The search stops when the distance of the points parametrized by t0 and t1 gets smaller than the given tolerance.
Parameters:  bezier_point_at_tcallable
A function returning x, y coordinates of the Bezier at parameter t. It must have the signature:
bezier_point_at_t(t: float) > tuple[float, float]
 inside_closedpathcallable
A function returning True if a given point (x, y) is inside the closed path. It must have the signature:
inside_closedpath(point: tuple[float, float]) > bool
 t0, t1float
Start parameters for the search.
 tolerancefloat
Maximal allowed distance between the final points.
Returns:  t0, t1float
The Bezier path parameters.

matplotlib.bezier.
find_control_points
(c1x, c1y, mmx, mmy, c2x, c2y)[source]¶ Find control points of the Bezier curve passing through (c1x, c1y), (mmx, mmy), and (c2x, c2y), at parametric values 0, 0.5, and 1.

matplotlib.bezier.
get_intersection
(cx1, cy1, cos_t1, sin_t1, cx2, cy2, cos_t2, sin_t2)[source]¶ Return the intersection between the line through (cx1, cy1) at angle t1 and the line through (cx2, cy2) at angle t2.

matplotlib.bezier.
get_normal_points
(cx, cy, cos_t, sin_t, length)[source]¶ For a line passing through (cx, cy) and having an angle t, return locations of the two points located along its perpendicular line at the distance of length.

matplotlib.bezier.
get_parallels
(bezier2, width)[source]¶ Given the quadratic Bezier control points bezier2, returns control points of quadratic Bezier lines roughly parallel to given one separated by width.

matplotlib.bezier.
inside_circle
(cx, cy, r)[source]¶ Return a function that checks whether a point is in a circle with center (cx, cy) and radius r.
The returned function has the signature:
f(xy: tuple[float, float]) > bool

matplotlib.bezier.
make_path_regular
(p)[source]¶ [Deprecated] If the
codes
attribute ofPath
p is None, return a copy of p withcodes
set to (MOVETO, LINETO, LINETO, ..., LINETO); otherwise return p itself.Notes
Deprecated since version 3.3.

matplotlib.bezier.
make_wedged_bezier2
(bezier2, width, w1=1.0, wm=0.5, w2=0.0)[source]¶ Being similar to get_parallels, returns control points of two quadratic Bezier lines having a width roughly parallel to given one separated by width.

matplotlib.bezier.
split_bezier_intersecting_with_closedpath
(bezier, inside_closedpath, tolerance=0.01)[source]¶ Split a Bezier curve into two at the intersection with a closed path.
Parameters:  bezier(N, 2) arraylike
Control points of the Bezier segment. See
BezierSegment
. inside_closedpathcallable
A function returning True if a given point (x, y) is inside the closed path. See also
find_bezier_t_intersecting_with_closedpath
. tolerancefloat
The tolerance for the intersection. See also
find_bezier_t_intersecting_with_closedpath
.
Returns:  left, right
Lists of control points for the two Bezier segments.