[ Web Proxy ]
URL:
Viewing: https://matplotlib.org/stable/api/_as_gen/../../gallery/animation/../misc/../../api/bezier_api.html [Back]  [Original]

matplotlib.bezier — Matplotlib 3.11.2 documentation
Back to top
Search the docs ...:

matplotlib.bezier#

A module providing some utility functions regarding Bzier path manipulation.

class matplotlib.bezier.BezierSegment(control_points)[source]#

Bases: object

A d-dimensional Bzier segment.

A BezierSegment can be called with an argument, either a scalar or an array-like object, to evaluate the curve at that/those location(s).

Parameters:
control_points(N, d) array

Location of the N control points.

__call__(t)[source]#

Evaluate the Bzier curve at point(s) t in [0, 1].

Parameters:
t(k,) array-like

Points at which to evaluate the curve.

Returns:
(k, d) array

Value of the curve for each point in t.

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.

point_at_t(t)[source]#

[Deprecated] Evaluate the curve at a single point, returning a tuple of d floats.

Notes

Deprecated since version 3.11: Use Call the BezierSegment object with an argument. instead.

property polynomial_coefficients#

The polynomial coefficients of the Bzier 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 Bzier 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=1e-05)[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.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 Bzier 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 Bzier 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 Bzier path parameters.

matplotlib.bezier.find_control_points(c1x, c1y, mmx, mmy, c2x, c2y)[source]#

Find control points of the Bzier curve passing through (c1x, c1y), (mmx, mmy), and (c2x, c2y), at parametric values 0, 0.5, and 1.

matplotlib.bezier.get_cos_sin(x0, y0, x1, y1)[source]#
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 Bzier control points bezier2, returns control points of quadratic Bzier 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_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 Bzier 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 Bzier curve into two at the intersection with a closed path.

Parameters:
bezier(N, 2) array-like

Control points of the Bzier 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 Bzier segments.

matplotlib.bezier.split_de_casteljau(beta, t)[source]#

Split a Bzier segment defined by its control points beta into two separate segments divided at t and return their control points.

matplotlib.bezier.split_path_inout(path, inside, tolerance=0.01, reorder_inout=False)[source]#

Divide a path into two segments at the point where inside(x, y) becomes False.


Web Proxy Viewer  |  New URL  |  Original Page