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/2023.7.28/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/2023.7.28/docs/images/bernstein_basis.png

to define a curve as a linear combination:

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

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

https://raw.githubusercontent.com/dhermes/bezier/2023.7.28/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.11 -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/2023.7.28/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.

Metadata

Release files for bezier 2023.7.28

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 2023.7.28
File Size Uploaded
bezier-2023.7.28.tar.gz 348.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for bezier 2023.7.28
File
bezier-2023.7.28-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
bezier-2023.7.28-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-2023.7.28-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
bezier-2023.7.28-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
bezier-2023.7.28-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details
bezier-2023.7.28-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
bezier-2023.7.28-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-2023.7.28-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64 Details
bezier-2023.7.28-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
bezier-2023.7.28-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
bezier-2023.7.28-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
bezier-2023.7.28-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
bezier-2023.7.28-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ ARM64 Details
bezier-2023.7.28-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
bezier-2023.7.28-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
bezier-2023.7.28-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
bezier-2023.7.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
bezier-2023.7.28-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ ARM64 Details
bezier-2023.7.28-cp38-cp38-macosx_11_0_arm64.whl CPython 3.8 CPython 3.8 macOS 11.0+ ARM64 Details
bezier-2023.7.28-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details

Total release size: 33.6 MB

Release files / bezier-2023.7.28.tar.gz

Download URL bezier-2023.7.28.tar.gz
Size 348.9 kB
Tags Source
SHA-256 checksum
How to use checksums
853256d1e1e9cd82cbb3d1543be906e9d54e8491e3020a90c084a9d18021f63b
BLAKE2b-256 checksum
How to use checksums
cbb4bc9fcd3ea73fb084a1686b11313e91276168a53d85ecc161d3bab8832c6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

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

Download URL bezier-2023.7.28-cp311-cp311-win_amd64.whl
Size 709.8 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
355947a0b3bd1a8b978ad992ff8ac538fd46b7dcd6858af62b471445541c38b2
BLAKE2b-256 checksum
How to use checksums
98a6fe2da06010937970a1e151c9fc71708bee8815192a04b8f8d3efa3d103f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

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

Download URL bezier-2023.7.28-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
17201989272725921b6133ff89ab29f08c5f1c18b29b0bbfe64d95fc61f50a40
BLAKE2b-256 checksum
How to use checksums
4f47cb4fd6e9eb3bf8c83499d09c1a36c25c1074d86109f16675f5a4ab365ab0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

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

Download URL bezier-2023.7.28-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
aa43e1721f252f99a1d8bc06f66e89e5433604f1b0338fe7e025e4cd4dd579ff
BLAKE2b-256 checksum
How to use checksums
7600c94fccce7423da88c0b453ff0a89eed083f1eb75b435415b455970a6dfd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp311-cp311-macosx_11_0_arm64.whl

Download URL bezier-2023.7.28-cp311-cp311-macosx_11_0_arm64.whl
Size 1.2 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ed0cc6441da427a2ae40dd32eb6b567c1a3e48ccbeecabdb03f93370da762c68
BLAKE2b-256 checksum
How to use checksums
a55bf0ce45e3d82622632a7ba53b70085bb9221ba580eb6875659c571f987832
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp311-cp311-macosx_10_9_x86_64.whl

Download URL bezier-2023.7.28-cp311-cp311-macosx_10_9_x86_64.whl
Size 1.9 MB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
e8b8a0d049eef63774b805c2e1078337d206b35599e74a43554b687eb650cfd3
BLAKE2b-256 checksum
How to use checksums
b3065d943bf358835b6c49b6873c88710d6d930abc5380f70f2bdb422e255cef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

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

Download URL bezier-2023.7.28-cp310-cp310-win_amd64.whl
Size 709.3 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
32d6d38d7b3b9cbbea53ed0814b348da8d70718c85213ff48d418968fcf11dd9
BLAKE2b-256 checksum
How to use checksums
1edd16754d0fbca66813ea5ef65387ee34bd72887c96a2ee02c86203fc79e752
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

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

Download URL bezier-2023.7.28-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
9af82b42143e5fda2c101308166bc55f4b31ddcbd4e315b25f766668ab87e1b7
BLAKE2b-256 checksum
How to use checksums
07048f146767fef25dfed8bb4285372382a85ae47460d5dc4e53b16de2b0be79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

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

Download URL bezier-2023.7.28-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
3db780501aa0ed9224582c28d1b4b35eab764a58096a405fc749691972986cba
BLAKE2b-256 checksum
How to use checksums
043f5c66e135cccc490844f88e38f7286bc9b932456b5d22c83ab54515a42da7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp310-cp310-macosx_11_0_arm64.whl

Download URL bezier-2023.7.28-cp310-cp310-macosx_11_0_arm64.whl
Size 1.2 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
412b15c606183a0aaf9cbc40d4e1069638e60d6a8a80460fb3bd7fb69f92a6b8
BLAKE2b-256 checksum
How to use checksums
84daabaea567be7198e407f71fba80011bac535a223194258a1e01d1ddad6b55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp310-cp310-macosx_10_9_x86_64.whl

Download URL bezier-2023.7.28-cp310-cp310-macosx_10_9_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
5846838f53b1f63fc53a2fb6273966eeaf0e8d6ed81a25368bfda8cc4bfb1f0c
BLAKE2b-256 checksum
How to use checksums
ee30d8eb5e170b78743752b183c0f987590afff43167233441fc60f815b264ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp39-cp39-win_amd64.whl

Download URL bezier-2023.7.28-cp39-cp39-win_amd64.whl
Size 709.9 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
24fc2c33b98101321906092600a9821b495abe877a029f973882a8e88932d88a
BLAKE2b-256 checksum
How to use checksums
7f12cc0ea4cb05db7d4117f59ed627634823964700fd5c6194a3a26a56f56401
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

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

Release files / bezier-2023.7.28-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL bezier-2023.7.28-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.9 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
787023b8e1a5d9056bbb3422ecc84b276cfb03f37e359676e523ca70446c8a33
BLAKE2b-256 checksum
How to use checksums
c0fdadfb5be257d9a7d3d6e0403b768bef8cc4c840f3262c8959d4658ebf239c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp39-cp39-macosx_11_0_arm64.whl

Download URL bezier-2023.7.28-cp39-cp39-macosx_11_0_arm64.whl
Size 1.2 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6c52b5f083540250da00d586ce5f4e8d8d2434c63b5b815625c5b3e1a602c2e8
BLAKE2b-256 checksum
How to use checksums
3bda4fd16519cae797cf41e7074a73cafcafab6796445a88edfaf19232066695
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp39-cp39-macosx_10_9_x86_64.whl

Download URL bezier-2023.7.28-cp39-cp39-macosx_10_9_x86_64.whl
Size 1.9 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
962d93f7dbfdc37c1fa2f930f304810eff79ef30d067a36c65bbdce0a6356afe
BLAKE2b-256 checksum
How to use checksums
a73600b638b0cb1f95a51c0de7a6a90f53f3ac6b948fd2b3255325f7a9dde356
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp38-cp38-win_amd64.whl

Download URL bezier-2023.7.28-cp38-cp38-win_amd64.whl
Size 710.0 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
922055eb437d46e13a0d20cc2b9ebed093dbbe3a55afb8d30136ffff5ce47620
BLAKE2b-256 checksum
How to use checksums
8a4f2db6b792595f5c4860236172ca78b98101b46b730cb9b0729328ac42ff2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL bezier-2023.7.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.6 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e247d82ac271b451974e9cc5e8c50a46e0196e1e35ffddee8e90d27bd5e86242
BLAKE2b-256 checksum
How to use checksums
ec0a3282ff43228b5a776fd4324f49e115700cc5c7acdcc5f35587fa1c03c27a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL bezier-2023.7.28-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.0 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
750e239d40e0d8d4b906b2509cf8c3448afabaa5779b3d5642cdc8d1b754fc48
BLAKE2b-256 checksum
How to use checksums
50e117f4e8a128df601ec07a289ac26457a0d4681dcd8664a7f24cb98bf4032f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp38-cp38-macosx_11_0_arm64.whl

Download URL bezier-2023.7.28-cp38-cp38-macosx_11_0_arm64.whl
Size 1.2 MB
Tags CPython 3.8 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9bde270818247331db5c99ef42bf33981c7568825269d5463d28325bbc5d5998
BLAKE2b-256 checksum
How to use checksums
f4214e978cf8b9c9229a78fea25804962ba3e08e507b1a132db0eaccd28508eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / bezier-2023.7.28-cp38-cp38-macosx_10_9_x86_64.whl

Download URL bezier-2023.7.28-cp38-cp38-macosx_10_9_x86_64.whl
Size 1.9 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
b6931d16897a76aecd8d427896af2ea24d00332941cb8f8a6a71ffeb15440800
BLAKE2b-256 checksum
How to use checksums
1f8a9b5c82db19f13fa20cb79957769840f57494205943b203116d98d2da722c
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