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
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).
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.

Create and evaluate a quadratic Bézier curve defined by three control points.

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))