Skip to main content

bezier

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

CircleCI Build GitHub Actions Build AppVeyor CI Build 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/2021.2.12/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/2021.2.12/docs/images/bernstein_basis.png

to define a curve as a linear combination:

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

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

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

>>> 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/2021.2.12/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 2021.2.12

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

Built distributions (wheels)

Table of built distributions (wheels) for bezier 2021.2.12
File
bezier-2021.2.12-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
bezier-2021.2.12-cp39-cp39-win32.whl CPython 3.9 CPython 3.9 Windows x86-32 Details
bezier-2021.2.12-cp39-cp39-manylinux2010_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.12+ x86-64 Details
bezier-2021.2.12-cp39-cp39-manylinux2010_i686.whl CPython 3.9 CPython 3.9 Linux glibc 2.12+ x86-32 Details
bezier-2021.2.12-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
bezier-2021.2.12-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
bezier-2021.2.12-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
bezier-2021.2.12-cp38-cp38-manylinux2010_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-64 Details
bezier-2021.2.12-cp38-cp38-manylinux2010_i686.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-32 Details
bezier-2021.2.12-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
bezier-2021.2.12-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
bezier-2021.2.12-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
bezier-2021.2.12-cp37-cp37m-manylinux2010_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Details
bezier-2021.2.12-cp37-cp37m-manylinux2010_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-32 Details
bezier-2021.2.12-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details

Total release size: 17.7 MB

Release files / bezier-2021.2.12.tar.gz

Download URL bezier-2021.2.12.tar.gz
Size 313.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d0f752aeb420057ab761f962259c7ca00d925750e324c9bb729f2f10ad39529a
BLAKE2b-256 checksum
How to use checksums
cbe80073ac3f92cbe8ced10e5e5822594a8f63b9a3dc91258c681b7ee96b80b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

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

Download URL bezier-2021.2.12-cp39-cp39-win_amd64.whl
Size 677.9 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
03a08de391be1ba035b31721c98457a7aac0e879149d80fb96ef211afa676161
BLAKE2b-256 checksum
How to use checksums
92021b2037399d5783ae3d929c5b9faecdabd1c2c01dbcb95f8c290837a67d96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.6

Release files / bezier-2021.2.12-cp39-cp39-win32.whl

Download URL bezier-2021.2.12-cp39-cp39-win32.whl
Size 681.8 kB
Tags CPython 3.9 Windows x86-32
SHA-256 checksum
How to use checksums
6c667bfd8f6e52aebaca7672f047c79f420777cfd2a50c65c50bcf6ad07906c1
BLAKE2b-256 checksum
How to use checksums
612b190a448e8b3abd23ff3e94152a83d8cb25b47d68335eb2498c8e92bc3b95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.6

Release files / bezier-2021.2.12-cp39-cp39-manylinux2010_x86_64.whl

Download URL bezier-2021.2.12-cp39-cp39-manylinux2010_x86_64.whl
Size 1.4 MB
Tags CPython 3.9 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
d2d18fd54d92d461c6e843e3eaca7d54926288efd8f60625c31ef88fcc6132a4
BLAKE2b-256 checksum
How to use checksums
65120db4447c4eae0b81d3c0c9d485199d8de7c798f834984c87d92390344e19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

Release files / bezier-2021.2.12-cp39-cp39-manylinux2010_i686.whl

Download URL bezier-2021.2.12-cp39-cp39-manylinux2010_i686.whl
Size 1.4 MB
Tags CPython 3.9 Linux glibc 2.12+ x86-32
SHA-256 checksum
How to use checksums
b929375f79c91d52517c0e25c250f342c473e7fc74d4b7a740d8693a2de6372d
BLAKE2b-256 checksum
How to use checksums
0c46fd94973dbc10638a16b60b0890e0f0f69c8e6143f088b4ad5d4ffac22989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

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

Download URL bezier-2021.2.12-cp39-cp39-macosx_10_9_x86_64.whl
Size 1.7 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
65b128bfb55a618ab63464a5387387f8aa577c95f91faa0f94d0efc5d037cd22
BLAKE2b-256 checksum
How to use checksums
3b48651cd0a23c80d3b8594dd2bc0825f84fb0cd7bf7d046a24580632a1a1489
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

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

Download URL bezier-2021.2.12-cp38-cp38-win_amd64.whl
Size 677.9 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
d01aa9c685bee5e344e5936124bd732f5ff25337ee163737901a02a6c837e9cc
BLAKE2b-256 checksum
How to use checksums
441db70387e6f97d54f63334b946ef4fc4eef8623a42612cbe6b4645bc6b491c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.6

Release files / bezier-2021.2.12-cp38-cp38-win32.whl

Download URL bezier-2021.2.12-cp38-cp38-win32.whl
Size 681.7 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
9ce274c22e98729b464a1850a66266b04de2d1a67f6804b3c448bfe5cacf651a
BLAKE2b-256 checksum
How to use checksums
a594d566fcf5d32bb5f71cab2a92e6e4883ffce7e06b6a011aa0758cc2385bea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.6

Release files / bezier-2021.2.12-cp38-cp38-manylinux2010_x86_64.whl

Download URL bezier-2021.2.12-cp38-cp38-manylinux2010_x86_64.whl
Size 1.4 MB
Tags CPython 3.8 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
e87ce290bfdadc5e5f92f95b016c71cf68a61c273c353a84b48a40ea37b82240
BLAKE2b-256 checksum
How to use checksums
516e9b2d2ff062a7709d28e66a1f37294dfb78a9fd4a6aae6d7e6d4ba70fff0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

Release files / bezier-2021.2.12-cp38-cp38-manylinux2010_i686.whl

Download URL bezier-2021.2.12-cp38-cp38-manylinux2010_i686.whl
Size 1.4 MB
Tags CPython 3.8 Linux glibc 2.12+ x86-32
SHA-256 checksum
How to use checksums
584c324a3c0b8cb3e2285456857b10bc3417625db6d8a0a8ffe9f28ede2b6076
BLAKE2b-256 checksum
How to use checksums
38ab53066d69bde797fe3ed55d309e992c2170c39d5adcffd0a31e5eb77a72f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

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

Download URL bezier-2021.2.12-cp38-cp38-macosx_10_9_x86_64.whl
Size 1.7 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
dcee7f18dcef5d3f2730cad2201323955fbd9226d6e90723e8d512535a291bf6
BLAKE2b-256 checksum
How to use checksums
3b5143f763903495b3e877ea2f590dcdbfadbbb199d226e17325504e0878cd2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

Release files / bezier-2021.2.12-cp37-cp37m-win_amd64.whl

Download URL bezier-2021.2.12-cp37-cp37m-win_amd64.whl
Size 672.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
b3c23a001024011a4dbe2fc34ac7b9d8a163206ff1b5381426379f63eb0a484d
BLAKE2b-256 checksum
How to use checksums
37cb2dcd1f7b88e6081412b4d9f2ca9c4404fcb152a8945ed22c8f1ea2b38ed8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.6

Release files / bezier-2021.2.12-cp37-cp37m-win32.whl

Download URL bezier-2021.2.12-cp37-cp37m-win32.whl
Size 677.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
1aebedd462c7f10e528a89e64c4df1e90aded3cf4a66ad98e7e96689a81c11aa
BLAKE2b-256 checksum
How to use checksums
6d3fe67d1b3fd889e330cfc3b2ed8d54065871ba36795a63d30c94a4085d4f02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.6

Release files / bezier-2021.2.12-cp37-cp37m-manylinux2010_x86_64.whl

Download URL bezier-2021.2.12-cp37-cp37m-manylinux2010_x86_64.whl
Size 1.4 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
b5c51c2bf84ca4b6576e9e04158c8f8cdecd3cbc2002e03fc8a6cad0f9ad35ac
BLAKE2b-256 checksum
How to use checksums
3d04ad9e6977779678c0a435c4093e5c9182fb8a96feec7bb6b297fab2eac84b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

Release files / bezier-2021.2.12-cp37-cp37m-manylinux2010_i686.whl

Download URL bezier-2021.2.12-cp37-cp37m-manylinux2010_i686.whl
Size 1.3 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-32
SHA-256 checksum
How to use checksums
7a431c9834b431d91d93e8785e1b85cbf25707e1fb1f61382c39f3f49eeab5d4
BLAKE2b-256 checksum
How to use checksums
3e3cf218b3f180b79a5af5bb3c3b172596bbf4dad79db1db6395fcd2d5629325
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

Release files / bezier-2021.2.12-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL bezier-2021.2.12-cp37-cp37m-macosx_10_9_x86_64.whl
Size 1.7 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
d2812bc93acecefa3b7ae4b539bd59b91db98fb1b2f4e98f3bbf337c8481d1dd
BLAKE2b-256 checksum
How to use checksums
35b21c5a99ee8eb9456827ac1423413d0d946e62ce71d0c9d0f837a044d4783a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
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