Bezier
raw JSON → 2024.6.20 verified Sat May 09 auth: no python
Helper for Bézier Curves, Triangles, and Higher Order Objects. Pure Python and compiled backend for computing with Bézier curves, triangles, surfaces, and volumes. Current version 2024.6.20, requires Python >=3.10. Released approximately yearly since 2017.
pip install bezier Common errors
error ModuleNotFoundError: No module named 'bezier' ↓
cause Package not installed or installed in wrong environment.
fix
Run
pip install bezier in the correct Python environment. error ValueError: nodes must be 2D array (num_axes, num_nodes) ↓
cause Nodes array not shaped as (num_axes, num_nodes) or not Fortran-contiguous.
fix
Ensure nodes is 2D with shape (dims, points) and convert to Fortran order using
np.asfortranarray(nodes). Warnings
breaking Surface class renamed to Triangle in v2020.1.14. Code using `Surface` will break. ↓
fix Replace `Surface` with `Triangle` in imports and usage.
gotcha Nodes array must be Fortran-contiguous (column-major). Use `np.asfortranarray` or ensure array is C-contiguous with correct shape. ↓
fix Always pass nodes as Fortran-contiguous arrays: `nodes = np.asfortranarray(...)`
deprecated Python 3.9 support dropped, requires >=3.10 as of v2024.6.20. ↓
fix Upgrade Python to 3.10 or later.
Imports
- BezierCurve wrong
from bezier import BezierCurvecorrectfrom bezier import Curve - Triangle wrong
from bezier import Surfacecorrectfrom bezier import Triangle - intersections wrong
from bezier import intersectcorrectfrom bezier import intersection_curves_curves
Quickstart
import numpy as np
from bezier import Curve
nodes = np.asfortranarray([
[0.0, 0.5, 1.0],
[0.0, 1.0, 0.0],
])
curve = Curve(nodes, degree=2)
print(curve.evaluate(0.5))