10.1.4.1. Bezier

Module to implement Bézier curve.

For resources on Bézier curve see this section.

class Patro.GeometryEngine.Bezier.BezierMixin2D[source]

Bases: Patro.GeometryEngine.Primitive.Primitive2DMixin

Mixin to implements 2D Bezier Curve.

LineInterpolationPrecision = 0.05
_logger = <Logger Patro.GeometryEngine.Bezier.BezierMixin2D (WARNING)>
_map_to_line(line)[source]
distance_to_point(point)[source]
interpolated_length(dt=None)[source]

Length of the curve obtained via line interpolation

length_at_t(t, cache=False)[source]

Compute the length of the curve at t.

non_parametric_curve(line)[source]

Return the non-parametric Bezier curve D(ti, di(t)) where di(t) is the distance of the curve from the baseline of the fat-line, ti is equally spaced in [0, 1].

split_at_two_t(t1, t2)[source]
t_at_length(length, precision=1e-06)[source]

Compute t for the given length. Length must lie in [0, curve length] range].

class Patro.GeometryEngine.Bezier.CubicBezier2D(p0, p1, p2, p3)[source]

Bases: Patro.GeometryEngine.Bezier.BezierMixin2D, Patro.GeometryEngine.Primitive.Primitive4P

Class to implements 2D Cubic Bezier Curve.

BASIS = array([[ 1, -3, 3, -1], [ 0, 3, -6, 3], [ 0, 0, 3, -3], [ 0, 0, 0, 1]])
INVERSE_BASIS = array([[1. , 1. , 1. , 1. ], [0. , 0.33333333, 0.66666667, 1. ], [0. , 0. , 0.33333333, 1. ], [0. , 0. , 0. , 1. ]])
InterpolationPrecision = 0.001
__init__(p0, p1, p2, p3)[source]

Initialize self. See help(type(self)) for accurate signature.

__repr__()[source]

Return repr(self).

static _clip_convex_hull(hull_top, hull_bottom, d_min, d_max)[source]
static _clip_convex_hull_part(part, top, threshold)[source]

Clip the bottom or top part of the convex hull.

part is a list of points, top is a boolean flag to indicate if it corresponds to the top part, threshold is d_min if top part else d_max.

_clipping_convex_hull()[source]
_d01()[source]

Return the distance between 0 and 1 quadratic aproximations

static _instersect_curve(curve1, curve2, t_min=0, t_max=1, u_min=0, u_max=1, old_delta_t=1, reverse=False, recursion=0, recursion_limit=32, t_limit=0.8, locations=[])[source]

Compute the intersection of two Bézier curves.

Code inspired from

_logger = <Logger Patro.GeometryEngine.Bezier.CubicMixin2D (WARNING)>
_q_point()[source]

Return the control point for mid-point quadratic approximation

_t_max()[source]

Return the split point for adaptive quadratic approximation

adaptive_length_approximation()[source]

Return the length of the adaptive quadratic approximation

area

Compute the area delimited by the curve and the segment across the start and stop point.

closest_point(point)[source]

Return the closest point on the curve to the given point.

For more details see this section.

fat_line()[source]
intersect_line(line)[source]

Find the intersections of the curve with a line.

is_flat_enough(flatness)[source]

Determines if a curve is sufficiently flat, meaning it appears as a straight line and has curve-time that is enough linear, as specified by the given flatness parameter.

For more details see this section.

length
mid_point_quadratic_approximation()[source]

Return the mid-point quadratic approximation

point_at_t(t)[source]
q_length()[source]

Return the length of the mid-point quadratic approximation

split_at_t(t)[source]

Split the curve at given position

tangent1
tangent_at(t)[source]
to_spline()[source]
class Patro.GeometryEngine.Bezier.QuadraticBezier2D(p0, p1, p2)[source]

Bases: Patro.GeometryEngine.Bezier.BezierMixin2D, Patro.GeometryEngine.Primitive.Primitive3P

Class to implements 2D Quadratic Bezier Curve.

BASIS = array([[ 1, -2, 1], [ 0, 2, -2], [ 0, 0, 1]])
INVERSE_BASIS = array([[-2, 1, -2], [-1, -3, 1], [-1, -1, -2]])
__init__(p0, p1, p2)[source]

Initialize self. See help(type(self)) for accurate signature.

__repr__()[source]

Return repr(self).

_logger = <Logger Patro.GeometryEngine.Bezier.QuadraticBezier2D (WARNING)>
closest_point(point)[source]

Return the closest point on the curve to the given point.

For more details see this section.

fat_line()[source]
intersect_line(line)[source]

Find the intersections of the curve with a line.

For more details see this section.

length

Compute the length of the curve.

For more details see this section.

normal0
point_at_t(t)[source]
split_at_t(t)[source]

Split the curve at given position

tangent0
tangent1
tangent_at(t)[source]
to_cubic()[source]

Elevate the quadratic Bézier curve to a cubic Bézier cubic with the same shape.

For more details see this section.