Skip to main content

Helper for Bézier Curves, Triangles, and Higher Order Objects

Linux Build (GitHub Actions) macOS Build (GitHub Actions) Windows Build (GitHub Actions) Code Coverage

Documentation Status Zenodo DOI for ``bezier`` "Journal of Open Source Science" DOI for ``bezier``

This library provides:

Dive in and take a look!

https://raw.githubusercontent.com/dhermes/bezier/2024.6.20/docs/images/triangles6Q_and_7Q.png

Why Bézier?

A Bézier curve (and triangle, etc.) is a parametric curve that uses the Bernstein basis:

https://raw.githubusercontent.com/dhermes/bezier/2024.6.20/docs/images/bernstein_basis.png

to define a curve as a linear combination:

https://raw.githubusercontent.com/dhermes/bezier/2024.6.20/docs/images/bezier_defn.png

This comes from the fact that the weights sum to one:

https://raw.githubusercontent.com/dhermes/bezier/2024.6.20/docs/images/sum_to_unity.png

This can be generalized to higher order by considering three, four, etc. non-negative weights that sum to one (in the above we have the two non-negative weights s and 1 - s).

Due to their simple form, Bézier curves:

  • can easily model geometric objects as parametric curves, triangles, etc.

  • can be computed in an efficient and numerically stable way via de Casteljau’s algorithm

  • can utilize convex optimization techniques for many algorithms (such as curve-curve intersection), since curves (and triangles, etc.) are convex combinations of the basis

Many applications – as well as the history of their development – are described in “The Bernstein polynomial basis: A centennial retrospective”, for example;

  • aids physical analysis using finite element methods (FEM) on isogeometric models by using geometric shape functions called NURBS to represent data

  • used in robust control of dynamic systems; utilizes convexity to create a hull of curves

Installing

The bezier Python package can be installed with pip:

$ python     -m pip install --upgrade bezier
$ python3.12 -m pip install --upgrade bezier
$ # To install optional dependencies, e.g. SymPy
$ python     -m pip install --upgrade bezier[full]

To install a pure Python version (i.e. with no binary extension):

$ BEZIER_NO_EXTENSION=true \
>   python   -m pip install --upgrade bezier --no-binary=bezier

bezier is open-source, so you can alternatively grab the source code from GitHub and install from source.

Getting Started

For example, to create a curve:

>>> import bezier
>>> import numpy as np
>>> nodes1 = np.asfortranarray([
...     [0.0, 0.5, 1.0],
...     [0.0, 1.0, 0.0],
... ])
>>> curve1 = bezier.Curve(nodes1, degree=2)

The intersection (points) between two curves can also be determined:

>>> nodes2 = np.asfortranarray([
...     [0.0, 0.25,  0.5, 0.75, 1.0],
...     [0.0, 2.0 , -2.0, 2.0 , 0.0],
... ])
>>> curve2 = bezier.Curve.from_nodes(nodes2)
>>> intersections = curve1.intersect(curve2)
>>> intersections
array([[0.31101776, 0.68898224, 0. , 1. ],
       [0.31101776, 0.68898224, 0. , 1. ]])
>>> s_vals = np.asfortranarray(intersections[0, :])
>>> points = curve1.evaluate_multi(s_vals)
>>> points
array([[0.31101776, 0.68898224, 0. , 1. ],
       [0.42857143, 0.42857143, 0. , 0. ]])

and then we can plot these curves (along with their intersections):

>>> import seaborn
>>> seaborn.set()
>>>
>>> ax = curve1.plot(num_pts=256)
>>> _ = curve2.plot(num_pts=256, ax=ax)
>>> lines = ax.plot(
...     points[0, :], points[1, :],
...     marker="o", linestyle="None", color="black")
>>> _ = ax.axis("scaled")
>>> _ = ax.set_xlim(-0.125, 1.125)
>>> _ = ax.set_ylim(-0.0625, 0.625)
https://raw.githubusercontent.com/dhermes/bezier/2024.6.20/docs/images/curves1_and_13.png

For API-level documentation, check out the Bézier Python package documentation.

Development

To work on adding a feature or to run the functional tests, see the DEVELOPMENT doc for more information on how to get started.

Citation

For publications that use bezier, there is a JOSS paper that can be cited. The following BibTeX entry can be used:

@article{Hermes2017,
  doi = {10.21105/joss.00267},
  url = {https://doi.org/10.21105%2Fjoss.00267},
  year = {2017},
  month = {Aug},
  publisher = {The Open Journal},
  volume = {2},
  number = {16},
  pages = {267},
  author = {Danny Hermes},
  title = {Helper for B{\'{e}}zier Curves, Triangles, and Higher Order Objects},
  journal = {The Journal of Open Source Software}
}

A particular version of this library can be cited via a Zenodo DOI; see a full list by version.

License

bezier is made available under the Apache 2.0 License. For more details, see the LICENSE.

Release files for bezier 2024.6.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bezier 2024.6.20
File Size Uploaded
bezier-2024.6.20.tar.gz 354.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for bezier 2024.6.20
File
bezier-2024.6.20-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
bezier-2024.6.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
bezier-2024.6.20-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
bezier-2024.6.20-cp312-cp312-macosx_14_0_x86_64.whl CPython 3.12 CPython 3.12 macOS 14.0+ x86-64 Details
bezier-2024.6.20-cp312-cp312-macosx_14_0_arm64.whl CPython 3.12 CPython 3.12 macOS 14.0+ ARM64 Details
bezier-2024.6.20-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
bezier-2024.6.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
bezier-2024.6.20-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
bezier-2024.6.20-cp311-cp311-macosx_14_0_x86_64.whl CPython 3.11 CPython 3.11 macOS 14.0+ x86-64 Details
bezier-2024.6.20-cp311-cp311-macosx_14_0_arm64.whl CPython 3.11 CPython 3.11 macOS 14.0+ ARM64 Details
bezier-2024.6.20-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
bezier-2024.6.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
bezier-2024.6.20-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64 Details
bezier-2024.6.20-cp310-cp310-macosx_14_0_x86_64.whl CPython 3.10 CPython 3.10 macOS 14.0+ x86-64 Details
bezier-2024.6.20-cp310-cp310-macosx_14_0_arm64.whl CPython 3.10 CPython 3.10 macOS 14.0+ ARM64 Details

Total release size:28.8 MB

Release files / bezier-2024.6.20.tar.gz

Download URL bezier-2024.6.20.tar.gz
Size 354.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0b46357eb6019f969a583093f66e6b73747d5e41c10d9f3dfe327b2aa43dff8c
BLAKE2b-256 checksum
How to use checksums
1d1a28aa7a72a5029f416c7d04c5cdae1b0b00d1c6c72a986689458e8e586446
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp312-cp312-win_amd64.whl

Download URL bezier-2024.6.20-cp312-cp312-win_amd64.whl
Size 1.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
8cf8c3e373440f799a48ccdf51bdd6428ceef5e1dd9bae9eb01711a0a73b8fdc
BLAKE2b-256 checksum
How to use checksums
113c713170cd340a8fc81cc9acb88a5c371f9aaf43102bcdfec9e543843faee4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL bezier-2024.6.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.6 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
21241b81f75739e2cfb2f705a9bb6e55489cc2d8a1d2a514b68ca55514aa5f09
BLAKE2b-256 checksum
How to use checksums
00a5dfa67b0de68ca25f37eeef3b85686f191991e8f20f76fdbde870dacb1c56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL bezier-2024.6.20-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.0 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
5199407fb9ad8bbae313dde49119ee33d684c2f81358082edea97345df6f493c
BLAKE2b-256 checksum
How to use checksums
f13c326228895c155a657079ac0094e8a3d225986332cc5b4c838f48ec18fbad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp312-cp312-macosx_14_0_x86_64.whl

Download URL bezier-2024.6.20-cp312-cp312-macosx_14_0_x86_64.whl
Size 1.9 MB
Tags CPython 3.12 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
bbe9e09dfee5cd23033aa4caf3b32b3d05d5977604b95b9c4e0220376c3c34b6
BLAKE2b-256 checksum
How to use checksums
034da71c92270739cba039bc110e0c805c3b2f2c8360d7fac3ec861842443571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp312-cp312-macosx_14_0_arm64.whl

Download URL bezier-2024.6.20-cp312-cp312-macosx_14_0_arm64.whl
Size 1.2 MB
Tags CPython 3.12 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
e18733c1fcf01a08822e6e8a6f86eb6e56067f368e4b09653d25368881765d7d
BLAKE2b-256 checksum
How to use checksums
0d4bdcfed092496f53565d40f7c3846db030babb227d9e25e44c7e1d4371713f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp311-cp311-win_amd64.whl

Download URL bezier-2024.6.20-cp311-cp311-win_amd64.whl
Size 1.8 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
ab942ec30c73425d7b7020cbde4e1b7bd7792e914fac585565786b205ef54c94
BLAKE2b-256 checksum
How to use checksums
709bcab28cdae18f739122905088845f8285f6271af3332e46b051c536804289
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL bezier-2024.6.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.6 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3d3205f96f982f0dc45e1776d8995d572e228b0dbeab234c0acf4618a2e8dce0
BLAKE2b-256 checksum
How to use checksums
0eec836adeee81afaabd7f41f7bc3840ffc7e8b50ac1b3ffdf6f6894a13cbcd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL bezier-2024.6.20-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.0 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
29bbecca56d6d152cd566ba626ceab1a95bbaf05205acf680da6d4d5beb0e87b
BLAKE2b-256 checksum
How to use checksums
aa81b22deec7817ebdc2da7c45920687b5697830bc0961c83a1d2a72856b3ac7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp311-cp311-macosx_14_0_x86_64.whl

Download URL bezier-2024.6.20-cp311-cp311-macosx_14_0_x86_64.whl
Size 1.9 MB
Tags CPython 3.11 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
28c50de2b7bc7afd19b3115e3f8ecad36bc281bf4eafbc335a7651b801dd3544
BLAKE2b-256 checksum
How to use checksums
f4e090eeab82f5e5c2c1f63e2ad7bf9ec188e0c699a410f4df1d886bd6a4b1b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp311-cp311-macosx_14_0_arm64.whl

Download URL bezier-2024.6.20-cp311-cp311-macosx_14_0_arm64.whl
Size 1.2 MB
Tags CPython 3.11 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
c860cc0e777a06cda9afa019824b9f48578b2964b0ae18ea7cbbe9d1a02066b6
BLAKE2b-256 checksum
How to use checksums
96d502911e75ada6f740910a7203510920947acec31c7e910c8cac521ce897bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp310-cp310-win_amd64.whl

Download URL bezier-2024.6.20-cp310-cp310-win_amd64.whl
Size 1.8 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
191a3c9081d16b36425cc66297f6a8e4460c1b2d43c2ddcd271014fdf99b1e46
BLAKE2b-256 checksum
How to use checksums
889d8a08db203aef6289c174bdc9566a2a7a8ff60e5fabbb8c1170b9ff2261ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL bezier-2024.6.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
fd1d4776212bdd9aa08ad57fb6a82978d50d0eba6f58f68fad9b83446fe895f3
BLAKE2b-256 checksum
How to use checksums
db704ecdf9758fd680fdf423051b58ca2e64b6ff4cdd04f62dc1baceed0e0adf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL bezier-2024.6.20-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.9 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
4b8c081eacc25c840b1991a11961421cdb0ec41906df015db9ff08322cf63486
BLAKE2b-256 checksum
How to use checksums
b6200984381a3c9042810b2f9cf39dedac2acffe0546ded10a56cfa43ec4914b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp310-cp310-macosx_14_0_x86_64.whl

Download URL bezier-2024.6.20-cp310-cp310-macosx_14_0_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
ad7ec863f3fa70bd0774ea49cd8f9ad6310251055ee127917b9b8dce085a9e91
BLAKE2b-256 checksum
How to use checksums
9f72055a5a2f3988fe6ab9dad8f9ba6cfa59af0bbddd6972a76a3659b90ec281
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2024.6.20-cp310-cp310-macosx_14_0_arm64.whl

Download URL bezier-2024.6.20-cp310-cp310-macosx_14_0_arm64.whl
Size 1.2 MB
Tags CPython 3.10 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
65d12159b919e3076c6a1b90c811b740cb1eb557d250947edb7bbc9a2157490d
BLAKE2b-256 checksum
How to use checksums
e3266fe7391f422fb18ce258c904cd951f1cedd4e0e13fc4f664b9eec240fc36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page