raygeo.geo.shape.bezier
Cubic bezier curve queries and conversions.
Provides point evaluation at a parameter t, splitting into two halves, bounding rectangle computation, flattening to line segments (both fixed-step and adaptive subdivision), rectangle clipping, flatness testing, perpendicular distance measurement, and conversion from cubic to quadratic form.
Functions
bezier_flatness_sq()
bezier_flatness_sq(a: Point3D, b: Point3D, c: Point3D, d: Point3D) -> float
Compute the flatness squared of a cubic bezier.
Returns: Flatness squared value.
| Parameter | Type | Description |
|---|---|---|
a | Point3D | Start point (x, y, z). |
b | Point3D | First control point (x, y, z). |
c | Point3D | Second control point (x, y, z). |
d | Point3D | End point (x, y, z). |
| Returns | float |
clip_bezier_with_rect()
clip_bezier_with_rect(p0: Point, p1: Point, p2: Point, p3: Point, rect: Rect) -> list[tuple[Point, Point, Point, Point]]
Clip a cubic bezier with a rectangle.
Returns: List of bezier segments inside the rectangle.
| Parameter | Type | Description |
|---|---|---|
p0 | Point | Start control point (x, y). |
p1 | Point | First control point (x, y). |
p2 | Point | Second control point (x, y). |
p3 | Point | End control point (x, y). |
rect | Rect | Clipping rectangle (x_min, y_min, x_max, y_max). |
| Returns | list[tuple[Point, Point, Point, Point]] |