Skip to main content

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

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bezier-2024.6.20.tar.gz (354.6 kB view details)

Uploaded Source

Built Distributions

bezier-2024.6.20-cp312-cp312-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.12 Windows x86-64

bezier-2024.6.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

bezier-2024.6.20-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

bezier-2024.6.20-cp312-cp312-macosx_14_0_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12 macOS 14.0+ x86-64

bezier-2024.6.20-cp312-cp312-macosx_14_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

bezier-2024.6.20-cp311-cp311-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.11 Windows x86-64

bezier-2024.6.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

bezier-2024.6.20-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

bezier-2024.6.20-cp311-cp311-macosx_14_0_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11 macOS 14.0+ x86-64

bezier-2024.6.20-cp311-cp311-macosx_14_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

bezier-2024.6.20-cp310-cp310-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.10 Windows x86-64

bezier-2024.6.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

bezier-2024.6.20-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

bezier-2024.6.20-cp310-cp310-macosx_14_0_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10 macOS 14.0+ x86-64

bezier-2024.6.20-cp310-cp310-macosx_14_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.10 macOS 14.0+ ARM64

File details

Details for the file bezier-2024.6.20.tar.gz.

File metadata

  • Download URL: bezier-2024.6.20.tar.gz
  • Upload date:
  • Size: 354.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for bezier-2024.6.20.tar.gz
Algorithm Hash digest
SHA256 0b46357eb6019f969a583093f66e6b73747d5e41c10d9f3dfe327b2aa43dff8c
MD5 6f30f305628b2b6cb9f5615f5c0608ff
BLAKE2b-256 1d1a28aa7a72a5029f416c7d04c5cdae1b0b00d1c6c72a986689458e8e586446

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8cf8c3e373440f799a48ccdf51bdd6428ceef5e1dd9bae9eb01711a0a73b8fdc
MD5 608a754031a38dfd03885e83cf01a9d6
BLAKE2b-256 113c713170cd340a8fc81cc9acb88a5c371f9aaf43102bcdfec9e543843faee4

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21241b81f75739e2cfb2f705a9bb6e55489cc2d8a1d2a514b68ca55514aa5f09
MD5 98348e01c59eeaf53183968df3b08083
BLAKE2b-256 00a5dfa67b0de68ca25f37eeef3b85686f191991e8f20f76fdbde870dacb1c56

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5199407fb9ad8bbae313dde49119ee33d684c2f81358082edea97345df6f493c
MD5 fc9b1f88ded08efc116cd7e6b768360d
BLAKE2b-256 f13c326228895c155a657079ac0094e8a3d225986332cc5b4c838f48ec18fbad

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp312-cp312-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp312-cp312-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 bbe9e09dfee5cd23033aa4caf3b32b3d05d5977604b95b9c4e0220376c3c34b6
MD5 f5c13d4b3cae8ee251cdcb414d707687
BLAKE2b-256 034da71c92270739cba039bc110e0c805c3b2f2c8360d7fac3ec861842443571

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e18733c1fcf01a08822e6e8a6f86eb6e56067f368e4b09653d25368881765d7d
MD5 c5e36136fa1cf2c2aa2299b510ae619d
BLAKE2b-256 0d4bdcfed092496f53565d40f7c3846db030babb227d9e25e44c7e1d4371713f

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ab942ec30c73425d7b7020cbde4e1b7bd7792e914fac585565786b205ef54c94
MD5 612649ee06e9de01060373f597b97849
BLAKE2b-256 709bcab28cdae18f739122905088845f8285f6271af3332e46b051c536804289

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d3205f96f982f0dc45e1776d8995d572e228b0dbeab234c0acf4618a2e8dce0
MD5 996e7f66ca8158561ccd37d480ce4c6e
BLAKE2b-256 0eec836adeee81afaabd7f41f7bc3840ffc7e8b50ac1b3ffdf6f6894a13cbcd4

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 29bbecca56d6d152cd566ba626ceab1a95bbaf05205acf680da6d4d5beb0e87b
MD5 71f0d3ef4b8cc1af83186eea0bbf22d0
BLAKE2b-256 aa81b22deec7817ebdc2da7c45920687b5697830bc0961c83a1d2a72856b3ac7

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp311-cp311-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp311-cp311-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 28c50de2b7bc7afd19b3115e3f8ecad36bc281bf4eafbc335a7651b801dd3544
MD5 37f83074c54a586465c054fb4c1e3584
BLAKE2b-256 f4e090eeab82f5e5c2c1f63e2ad7bf9ec188e0c699a410f4df1d886bd6a4b1b4

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c860cc0e777a06cda9afa019824b9f48578b2964b0ae18ea7cbbe9d1a02066b6
MD5 cf3ecd022f510f73f78ee3585cb2f1af
BLAKE2b-256 96d502911e75ada6f740910a7203510920947acec31c7e910c8cac521ce897bc

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 191a3c9081d16b36425cc66297f6a8e4460c1b2d43c2ddcd271014fdf99b1e46
MD5 65b8cefaf209e381c2945591293b7d33
BLAKE2b-256 889d8a08db203aef6289c174bdc9566a2a7a8ff60e5fabbb8c1170b9ff2261ab

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fd1d4776212bdd9aa08ad57fb6a82978d50d0eba6f58f68fad9b83446fe895f3
MD5 b333df4a9134d26a55997a50160698a5
BLAKE2b-256 db704ecdf9758fd680fdf423051b58ca2e64b6ff4cdd04f62dc1baceed0e0adf

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4b8c081eacc25c840b1991a11961421cdb0ec41906df015db9ff08322cf63486
MD5 9a04cb18dc129a770bb96f591adc78f9
BLAKE2b-256 b6200984381a3c9042810b2f9cf39dedac2acffe0546ded10a56cfa43ec4914b

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp310-cp310-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp310-cp310-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 ad7ec863f3fa70bd0774ea49cd8f9ad6310251055ee127917b9b8dce085a9e91
MD5 f63e7d927a35199814b3e2f9dadbbc49
BLAKE2b-256 9f72055a5a2f3988fe6ab9dad8f9ba6cfa59af0bbddd6972a76a3659b90ec281

See more details on using hashes here.

File details

Details for the file bezier-2024.6.20-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for bezier-2024.6.20-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 65d12159b919e3076c6a1b90c811b740cb1eb557d250947edb7bbc9a2157490d
MD5 36af0abf1052d49aed9986f0bd77f9cf
BLAKE2b-256 e3266fe7391f422fb18ce258c904cd951f1cedd4e0e13fc4f664b9eec240fc36

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page