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)>¶
-
-
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¶
-
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.
-
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
- https://github.com/paperjs/paper.js/blob/master/src/path/Curve.js
- http://nbviewer.jupyter.org/gist/hkrish/0a128f21a5b9e5a7a914 The Bezier Clipping Algorithm
- https://gist.github.com/hkrish/5ef0f2da7f9882341ee5 hkrish/bezclip_manual.py
-
_logger
= <Logger Patro.GeometryEngine.Bezier.CubicMixin2D (WARNING)>¶
-
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.
-
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
¶
-
tangent1
¶
-
-
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]])¶
-
_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.
-
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
¶
-
tangent0
¶
-
tangent1
¶
-
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.
-