Skip to main content

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

CircleCI Build Travis 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/0.11.0/docs/images/surfaces6Q_and_7Q.png

Why Bézier?

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

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

to define a curve as a linear combination:

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

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

https://raw.githubusercontent.com/dhermes/bezier/0.11.0/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, surfaces, 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 surfaces, 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.8 -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 matplotlib.pyplot as plt
>>> 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)
>>> plt.show()
https://raw.githubusercontent.com/dhermes/bezier/0.11.0/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 0.11.0

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

Built distributions (wheels)

Table of built distributions (wheels) for bezier 0.11.0
File
bezier-0.11.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
bezier-0.11.0-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
bezier-0.11.0-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
bezier-0.11.0-cp38-cp38-manylinux1_i686.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-32 Details
bezier-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
bezier-0.11.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
bezier-0.11.0-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
bezier-0.11.0-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
bezier-0.11.0-cp37-cp37m-manylinux1_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32 Details
bezier-0.11.0-cp37-cp37m-macosx_10_6_intel.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
bezier-0.11.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
bezier-0.11.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
bezier-0.11.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
bezier-0.11.0-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
bezier-0.11.0-cp36-cp36m-macosx_10_6_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386) Details

Total release size: 15.8 MB

Release files / bezier-0.11.0.tar.gz

Download URL bezier-0.11.0.tar.gz
Size 376.6 kB
Tags Source
SHA-256 checksum
How to use checksums
435611058d5250dad0423f28f193bfafce873ef372978da59401697138996116
BLAKE2b-256 checksum
How to use checksums
295d580fee8bd9313bd3cdef4f93fbc74076ed007970e85506f386902a2ced13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

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

Download URL bezier-0.11.0-cp38-cp38-win_amd64.whl
Size 740.6 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
b9702489cdbaa280a1fff9a520a9f840319959226ee1812b1b6f2ac16f77d236
BLAKE2b-256 checksum
How to use checksums
8f738d39f92ffc1c38bec4136e27aa7bfd6b143ffef53e0f2bc11630186db000
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

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

Download URL bezier-0.11.0-cp38-cp38-win32.whl
Size 698.0 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
8b2abb1f9e1d65607edef194277706ff9da653af5fc5d6b9fd692d2664f45c8a
BLAKE2b-256 checksum
How to use checksums
5d900e9b47487c9f71be2b6509441cef21ecf91fac894d015c7d7250a75fbd82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

Release files / bezier-0.11.0-cp38-cp38-manylinux1_x86_64.whl

Download URL bezier-0.11.0-cp38-cp38-manylinux1_x86_64.whl
Size 991.2 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
542873d2c52112b937fed6766e5747aaf2fc9183bea43997142aa0fd6ba21c7e
BLAKE2b-256 checksum
How to use checksums
bdb70ff0df6cce559fc702904f9aa68b073e38a436d3d4f05da16ede7868cb35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

Release files / bezier-0.11.0-cp38-cp38-manylinux1_i686.whl

Download URL bezier-0.11.0-cp38-cp38-manylinux1_i686.whl
Size 770.0 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
c608c0dcd3b422ecd3db97d9799676607de2f3a3b690a4148be58790b0c4656e
BLAKE2b-256 checksum
How to use checksums
aab0e620a99657addcb5b1fdf29f1d6a8ea3b25cc4e568eae1e0a2d27900ff47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

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

Download URL bezier-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl
Size 1.8 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
895502fc2a36f4b1f4243b79f18dee61d1b288171b33cd53324b6af5426258ce
BLAKE2b-256 checksum
How to use checksums
4c431a0da2567e39bea347cb4f3e5b6fe6f6e486ec7dc031aa7270a3cf35502b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

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

Download URL bezier-0.11.0-cp37-cp37m-win_amd64.whl
Size 734.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
533df68f9ca61a16d4883279f3ae22221113ea8f8fac0fa70c72e9b66dddc432
BLAKE2b-256 checksum
How to use checksums
275e60a7cadb9331a1ad5885babebedcf78f5a2318e49a974b292701aaa990e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

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

Download URL bezier-0.11.0-cp37-cp37m-win32.whl
Size 691.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
5d58f6b3b8ad7232b8212d9f726abd604652cb00f7bef6e4666e006554c089e2
BLAKE2b-256 checksum
How to use checksums
4998884e04990432535128a2fbfe6630a01bc559e59437dfd2347115c23a7097
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

Release files / bezier-0.11.0-cp37-cp37m-manylinux1_x86_64.whl

Download URL bezier-0.11.0-cp37-cp37m-manylinux1_x86_64.whl
Size 995.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
1dcd6fcb1985293850c67f69fd71010ac13a33b6a80e9c9892e51dd8b4a9e7ec
BLAKE2b-256 checksum
How to use checksums
076f0e55e3d0801b4da5c01b7a782bc29b49e0b46d25461d080b2bd062aed9b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

Release files / bezier-0.11.0-cp37-cp37m-manylinux1_i686.whl

Download URL bezier-0.11.0-cp37-cp37m-manylinux1_i686.whl
Size 771.3 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
3a15d5b2cfb67959650d3401b27a1f86aa6e1140f1fb7f64b51d76fb80b1669b
BLAKE2b-256 checksum
How to use checksums
f9078abdcd80ab710745aea8fdef4c663677ee561eb326a916fc159466ffda59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

Release files / bezier-0.11.0-cp37-cp37m-macosx_10_6_intel.whl

Download URL bezier-0.11.0-cp37-cp37m-macosx_10_6_intel.whl
Size 2.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
1953c5a8421c7aca719bb7068defa654e454ccbd96dad373145e021a71bb336c
BLAKE2b-256 checksum
How to use checksums
205c436f712c63be53295a05fb79645cce47492a3b21f51cf49dc4bdedafb7d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

Release files / bezier-0.11.0-cp36-cp36m-win_amd64.whl

Download URL bezier-0.11.0-cp36-cp36m-win_amd64.whl
Size 734.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
44ac68991d60b48b8f56d8a4e3137277e23515a54b7eaa92a103f0d98e1b4477
BLAKE2b-256 checksum
How to use checksums
90787349b078cc03936dacb543ee19933b9148909f8ea1048da0b218f103243f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

Release files / bezier-0.11.0-cp36-cp36m-win32.whl

Download URL bezier-0.11.0-cp36-cp36m-win32.whl
Size 691.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
cf12315e0e84586a158a3f71c0ed58a6cc404400c331a1911e20be6155d20d83
BLAKE2b-256 checksum
How to use checksums
ed24719e02671f10c1249c7b85d2cb7b1de75b03f153d2a91547549708f505bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

Release files / bezier-0.11.0-cp36-cp36m-manylinux1_x86_64.whl

Download URL bezier-0.11.0-cp36-cp36m-manylinux1_x86_64.whl
Size 997.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
170dcd8c442bc5ccb498d31ce687c4750be723d91c873a94ecd00e19fee66ca7
BLAKE2b-256 checksum
How to use checksums
0c98ff15b1bbdb07806b1a59b2032664d7b67e71ad42147d48bc7b14b070800f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

Release files / bezier-0.11.0-cp36-cp36m-manylinux1_i686.whl

Download URL bezier-0.11.0-cp36-cp36m-manylinux1_i686.whl
Size 772.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
452527d5efa2fc71eb0ed8ba90678b050e10ea4325d5376dfab8b5c2de646792
BLAKE2b-256 checksum
How to use checksums
889d42f6839a7f0ca4bd10f6444c8bb966768957a0771fe39a93ee7eb4ec18dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5

Release files / bezier-0.11.0-cp36-cp36m-macosx_10_6_intel.whl

Download URL bezier-0.11.0-cp36-cp36m-macosx_10_6_intel.whl
Size 2.0 MB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
188db1e5265a2b499dc98b82928987d45f9ada38badf14678a8eafe3459e36a0
BLAKE2b-256 checksum
How to use checksums
74e033975b1a3459685e7a7ee1cfdaa01b89f5c7414883b0b48e0c65d687a7fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.5
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