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

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-2023.7.28.tar.gz (348.9 kB view details)

Uploaded Source

Built Distributions

bezier-2023.7.28-cp311-cp311-win_amd64.whl (709.8 kB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

bezier-2023.7.28-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

bezier-2023.7.28-cp311-cp311-macosx_10_9_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

bezier-2023.7.28-cp310-cp310-win_amd64.whl (709.3 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

bezier-2023.7.28-cp310-cp310-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

bezier-2023.7.28-cp310-cp310-macosx_10_9_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

bezier-2023.7.28-cp39-cp39-win_amd64.whl (709.9 kB view details)

Uploaded CPython 3.9Windows x86-64

bezier-2023.7.28-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

bezier-2023.7.28-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

bezier-2023.7.28-cp39-cp39-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

bezier-2023.7.28-cp39-cp39-macosx_10_9_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

bezier-2023.7.28-cp38-cp38-win_amd64.whl (710.0 kB view details)

Uploaded CPython 3.8Windows x86-64

bezier-2023.7.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

bezier-2023.7.28-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

bezier-2023.7.28-cp38-cp38-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

bezier-2023.7.28-cp38-cp38-macosx_10_9_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for bezier-2023.7.28.tar.gz
Algorithm Hash digest
SHA256 853256d1e1e9cd82cbb3d1543be906e9d54e8491e3020a90c084a9d18021f63b
MD5 d8052824738e6f2f16ae679c1d45a68e
BLAKE2b-256 cbb4bc9fcd3ea73fb084a1686b11313e91276168a53d85ecc161d3bab8832c6a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bezier-2023.7.28-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 709.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for bezier-2023.7.28-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 355947a0b3bd1a8b978ad992ff8ac538fd46b7dcd6858af62b471445541c38b2
MD5 19da82a8f6f9aae2a3829318a46296a1
BLAKE2b-256 98a6fe2da06010937970a1e151c9fc71708bee8815192a04b8f8d3efa3d103f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-2023.7.28-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 17201989272725921b6133ff89ab29f08c5f1c18b29b0bbfe64d95fc61f50a40
MD5 e052faa563b65caa09f3cf4c10633d53
BLAKE2b-256 4f47cb4fd6e9eb3bf8c83499d09c1a36c25c1074d86109f16675f5a4ab365ab0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-2023.7.28-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 aa43e1721f252f99a1d8bc06f66e89e5433604f1b0338fe7e025e4cd4dd579ff
MD5 aeebaef0d438c39afc7adcef4c8888ce
BLAKE2b-256 7600c94fccce7423da88c0b453ff0a89eed083f1eb75b435415b455970a6dfd5

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed0cc6441da427a2ae40dd32eb6b567c1a3e48ccbeecabdb03f93370da762c68
MD5 ccfa91a19b240765249774a4ed2c68a0
BLAKE2b-256 a55bf0ce45e3d82622632a7ba53b70085bb9221ba580eb6875659c571f987832

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e8b8a0d049eef63774b805c2e1078337d206b35599e74a43554b687eb650cfd3
MD5 0b75bc15a9cd8db41f7c9368afcdf6cb
BLAKE2b-256 b3065d943bf358835b6c49b6873c88710d6d930abc5380f70f2bdb422e255cef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bezier-2023.7.28-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 709.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for bezier-2023.7.28-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 32d6d38d7b3b9cbbea53ed0814b348da8d70718c85213ff48d418968fcf11dd9
MD5 65eb30e2eb07c66f66dd26f00ab3bab4
BLAKE2b-256 1edd16754d0fbca66813ea5ef65387ee34bd72887c96a2ee02c86203fc79e752

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-2023.7.28-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9af82b42143e5fda2c101308166bc55f4b31ddcbd4e315b25f766668ab87e1b7
MD5 b44358283b607ca3dfad113a57953369
BLAKE2b-256 07048f146767fef25dfed8bb4285372382a85ae47460d5dc4e53b16de2b0be79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-2023.7.28-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3db780501aa0ed9224582c28d1b4b35eab764a58096a405fc749691972986cba
MD5 e2d4bfc091a311d44d4b32d4ae565f63
BLAKE2b-256 043f5c66e135cccc490844f88e38f7286bc9b932456b5d22c83ab54515a42da7

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 412b15c606183a0aaf9cbc40d4e1069638e60d6a8a80460fb3bd7fb69f92a6b8
MD5 46fd72b7c5ba7005f5ff8a491f25ca44
BLAKE2b-256 84daabaea567be7198e407f71fba80011bac535a223194258a1e01d1ddad6b55

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5846838f53b1f63fc53a2fb6273966eeaf0e8d6ed81a25368bfda8cc4bfb1f0c
MD5 50e30cc0980ce47b77aa5178b3c30233
BLAKE2b-256 ee30d8eb5e170b78743752b183c0f987590afff43167233441fc60f815b264ef

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: bezier-2023.7.28-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 709.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for bezier-2023.7.28-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 24fc2c33b98101321906092600a9821b495abe877a029f973882a8e88932d88a
MD5 1a87ee607f368dc566a9f24358d00124
BLAKE2b-256 7f12cc0ea4cb05db7d4117f59ed627634823964700fd5c6194a3a26a56f56401

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ae58e466335c5808e8841c46afdd8ac449915895f28d9bd526b19110a6d4caa
MD5 7c90992727fa962cd40527b5b8e6ce85
BLAKE2b-256 d1681e2cae4c2327073a1c4312a9e7efc48e0f0735c84edcf3401265386982c3

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 787023b8e1a5d9056bbb3422ecc84b276cfb03f37e359676e523ca70446c8a33
MD5 06fd20fb8004891abc1c01e3f4b4467e
BLAKE2b-256 c0fdadfb5be257d9a7d3d6e0403b768bef8cc4c840f3262c8959d4658ebf239c

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c52b5f083540250da00d586ce5f4e8d8d2434c63b5b815625c5b3e1a602c2e8
MD5 d8411ac8293dc4de442890f345a1f335
BLAKE2b-256 3bda4fd16519cae797cf41e7074a73cafcafab6796445a88edfaf19232066695

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 962d93f7dbfdc37c1fa2f930f304810eff79ef30d067a36c65bbdce0a6356afe
MD5 ab4baebb5e013118073d49005e9c32d9
BLAKE2b-256 a73600b638b0cb1f95a51c0de7a6a90f53f3ac6b948fd2b3255325f7a9dde356

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: bezier-2023.7.28-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 710.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for bezier-2023.7.28-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 922055eb437d46e13a0d20cc2b9ebed093dbbe3a55afb8d30136ffff5ce47620
MD5 82a01c51e611becbc7fac5462a6524b6
BLAKE2b-256 8a4f2db6b792595f5c4860236172ca78b98101b46b730cb9b0729328ac42ff2e

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e247d82ac271b451974e9cc5e8c50a46e0196e1e35ffddee8e90d27bd5e86242
MD5 58c5e0df1ccb2cb436aa89e3acb243cb
BLAKE2b-256 ec0a3282ff43228b5a776fd4324f49e115700cc5c7acdcc5f35587fa1c03c27a

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 750e239d40e0d8d4b906b2509cf8c3448afabaa5779b3d5642cdc8d1b754fc48
MD5 c73b9000004d7c37155f10e6d9820da0
BLAKE2b-256 50e117f4e8a128df601ec07a289ac26457a0d4681dcd8664a7f24cb98bf4032f

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9bde270818247331db5c99ef42bf33981c7568825269d5463d28325bbc5d5998
MD5 f7b9d3800c250a59065e58004967b741
BLAKE2b-256 f4214e978cf8b9c9229a78fea25804962ba3e08e507b1a132db0eaccd28508eb

See more details on using hashes here.

File details

Details for the file bezier-2023.7.28-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for bezier-2023.7.28-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b6931d16897a76aecd8d427896af2ea24d00332941cb8f8a6a71ffeb15440800
MD5 4f03ba97e291950fd684c33a928c313b
BLAKE2b-256 1f8a9b5c82db19f13fa20cb79957769840f57494205943b203116d98d2da722c

See more details on using hashes here.

Supported by

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