Helper for Bézier Curves, Triangles, and Higher Order Objects
Project description
Helper for Bézier Curves, Triangles, and Higher Order Objects
This library provides:
Dive in and take a look!
Why Bézier?
A Bézier curve (and triangle, etc.) is a parametric curve that uses the Bernstein basis:
to define a curve as a linear combination:
This comes from the fact that the weights sum to one:
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;
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 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)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for bezier-2020.2.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa8fc849750d7e27958da52e1e1e26ffdf0bc76e91a93d78400b61e213e443ed |
|
MD5 | 3bf27238b11a132f680990ba11d335ec |
|
BLAKE2b-256 | 4893f85b6495247e10288cf16ab780b05cf0abbf4fd920e7b44cded91fd8d932 |
Hashes for bezier-2020.2.3-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 211bb41549e182fecf1cb46c2e1dfabe9d5d0dbe97b5d331a99e63dc99f5c35f |
|
MD5 | 41c00f6f281c0670a464532e18398357 |
|
BLAKE2b-256 | 4afbf418c439ce666cd5f6bb57d9e994e56d54568ab18f12ea63a9e6969a28d3 |
Hashes for bezier-2020.2.3-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0221ec6362e03044db803f713220266f1350f52c5c3a9509d1fabad2ed30cf2c |
|
MD5 | c03b6395659edb1f3a259b11750e75d7 |
|
BLAKE2b-256 | 01571038c40c2b57d705d91f5b9162751472462548f98cdf556158f169cb8bad |
Hashes for bezier-2020.2.3-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 789d770d54a4b949c05a1a90010aa7510fd610c292fd36bf39a3c1eae53e8545 |
|
MD5 | cbaa8269d977063d93b14a7dc7350d2e |
|
BLAKE2b-256 | 95bda4d19b91fe42d4b188f0aa05a6e24af41a9d5060915efe64687f243abbf9 |
Hashes for bezier-2020.2.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49d823adb71731a8e16db988f5c15cf2e4597b0ce0d7e4285ef4758551bcbe42 |
|
MD5 | 7782244047a46ab948a7513f99fcc5d3 |
|
BLAKE2b-256 | 6fcaccc907eda5f2674a6389dd13486eb0177ea85409a9dd5aeba174f379c57a |
Hashes for bezier-2020.2.3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63c580911f5b30aa676824626e695ec1baae1ea3391096bfbbbc124a9f0779cd |
|
MD5 | 145b980a6b3fa568ea3f8d2a93417159 |
|
BLAKE2b-256 | 8452ccc7a4093e8536a9b6b2eec32de6acbb5fe7748bc665b1eed41ef11050a1 |
Hashes for bezier-2020.2.3-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b663d868cb74c0db43185d475b78bcc3e30fc87233b866e2ac1c660ecd937c61 |
|
MD5 | f0201bf4822b5e7811d94246bf7f3692 |
|
BLAKE2b-256 | 36fdef7f6f6685625f7e5f3d80343485b18fa5e3a6347975f51476ee75c80ad4 |
Hashes for bezier-2020.2.3-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cb232e047bcf8156f6286e6fd8276303554747689f7fd2fdb4d48b8808b9485 |
|
MD5 | c717764482e6da07fababc8e65f43f9c |
|
BLAKE2b-256 | 63c53f0a9c03e6851f315006cc60f4e320e279f6413764df93d9cc320e7bf847 |
Hashes for bezier-2020.2.3-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5f9ed2c254488fbb025baa9411b7bcaaede8761f8136103458e8186b33cbab4 |
|
MD5 | 20a27a16cc2e20f439dab8c0d510e1a3 |
|
BLAKE2b-256 | 069924f058158cd63f700e186004231886c88241e04100e7b36e0af81f225168 |
Hashes for bezier-2020.2.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56a13d962c2602daaa6eac6bdbcee50d8bcd3bc4c17feb9048462dd208c688b1 |
|
MD5 | 4a40253f91c32368c1602d39cb3946c6 |
|
BLAKE2b-256 | cc0bb60505bcf6ec6261343972e7221245acee1a03ce197bcb1b73856cbee363 |
Hashes for bezier-2020.2.3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 381e96f9e92057036498821ad7e45bacfb5d5f5e56ab9ea547dfdb0cb89ee93e |
|
MD5 | cadc582b97d6f6c4b425b2d3a11d1b38 |
|
BLAKE2b-256 | 3c824af6f53cce53b91055abbd09066158bce392dab2ed89adb9cc34125b5060 |
Hashes for bezier-2020.2.3-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dd23b15f286c541e5b0ad28607d516680ba8bba2fac470b83ed0f45262202c3 |
|
MD5 | 93a5db84ae155d668d13903d83e6ef0b |
|
BLAKE2b-256 | ec6191a0261f6ede97b78853dd0e58ac3dddce3f91513eb0978a318a290f3180 |
Hashes for bezier-2020.2.3-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16562d0d5906e7e270c8b22e98f7509c135908da144a6b84eaa14d4b1730cd2a |
|
MD5 | 777174ff2925c5ed83ceab7b1bafc131 |
|
BLAKE2b-256 | b2e0416107adeaf3bc05c414f6081193007b8ed765310af0185c33f71bc930d0 |
Hashes for bezier-2020.2.3-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3472756ac857136865a5fa5f3fcf176ec0ef4c5d1343553f4aee76a0c3c1f408 |
|
MD5 | 3c313584e9486c896ed03fc4924c58f5 |
|
BLAKE2b-256 | 0ade309ffe6be7d1f660bb661dae2682eaff983e75785a57e7f0bea9d5010fc5 |
Hashes for bezier-2020.2.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19101cf830f6316e2e8808816017b5661bbbea276f7099ff3a0b6712b6c95d6f |
|
MD5 | 998afd36e65a591be46255853275f581 |
|
BLAKE2b-256 | 18dbb15ece2068ac42a80f84dd715cdefcb501d93c4e2aaee421f68cffa7422e |