graphics.bezier_curve¶
Classes¶
Bezier curve is a weighted sum of a set of control points. |
Module Contents¶
- class graphics.bezier_curve.BezierCurve(list_of_points: list[tuple[float, float]])¶
Bezier curve is a weighted sum of a set of control points. Generate Bezier curves from a given set of control points. This implementation works only for 2d coordinates in the xy plane.
- basis_function(t: float) list[float] ¶
- The basis function determines the weight of each control point at time t.
- t: time value between 0 and 1 inclusive at which to evaluate the basis of
the curve.
returns the x, y values of basis function at time t
>>> curve = BezierCurve([(1,1), (1,2)]) >>> [float(x) for x in curve.basis_function(0)] [1.0, 0.0] >>> [float(x) for x in curve.basis_function(1)] [0.0, 1.0]
- bezier_curve_function(t: float) tuple[float, float] ¶
- The function to produce the values of the Bezier curve at time t.
t: the value of time t at which to evaluate the Bezier function
- Returns the x, y coordinates of the Bezier curve at time t.
The first point in the curve is when t = 0. The last point in the curve is when t = 1.
>>> curve = BezierCurve([(1,1), (1,2)]) >>> tuple(float(x) for x in curve.bezier_curve_function(0)) (1.0, 1.0) >>> tuple(float(x) for x in curve.bezier_curve_function(1)) (1.0, 2.0)
- plot_curve(step_size: float = 0.01)¶
- Plots the Bezier curve using matplotlib plotting capabilities.
step_size: defines the step(s) at which to evaluate the Bezier curve. The smaller the step size, the finer the curve produced.
- degree¶
- list_of_points¶