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.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)
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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size bezier-2021.2.12-cp37-cp37m-macosx_10_9_x86_64.whl (1.7 MB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp37-cp37m-manylinux2010_i686.whl (1.3 MB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp37-cp37m-manylinux2010_x86_64.whl (1.4 MB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp37-cp37m-win32.whl (677.0 kB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp37-cp37m-win_amd64.whl (672.4 kB) | File type Wheel | Python version cp37 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp38-cp38-macosx_10_9_x86_64.whl (1.7 MB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp38-cp38-manylinux2010_i686.whl (1.4 MB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp38-cp38-manylinux2010_x86_64.whl (1.4 MB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp38-cp38-win32.whl (681.7 kB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp38-cp38-win_amd64.whl (677.9 kB) | File type Wheel | Python version cp38 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp39-cp39-macosx_10_9_x86_64.whl (1.7 MB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp39-cp39-manylinux2010_i686.whl (1.4 MB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp39-cp39-manylinux2010_x86_64.whl (1.4 MB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp39-cp39-win32.whl (681.8 kB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size bezier-2021.2.12-cp39-cp39-win_amd64.whl (677.9 kB) | File type Wheel | Python version cp39 | Upload date | Hashes View |
Filename, size bezier-2021.2.12.tar.gz (313.9 kB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for bezier-2021.2.12-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2812bc93acecefa3b7ae4b539bd59b91db98fb1b2f4e98f3bbf337c8481d1dd |
|
MD5 | a4525d578dec6af4a9057ed5c0cf8c92 |
|
BLAKE2-256 | 35b21c5a99ee8eb9456827ac1423413d0d946e62ce71d0c9d0f837a044d4783a |
Hashes for bezier-2021.2.12-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a431c9834b431d91d93e8785e1b85cbf25707e1fb1f61382c39f3f49eeab5d4 |
|
MD5 | f5610db0e4e76f59bbdf14596e605a71 |
|
BLAKE2-256 | 3e3cf218b3f180b79a5af5bb3c3b172596bbf4dad79db1db6395fcd2d5629325 |
Hashes for bezier-2021.2.12-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5c51c2bf84ca4b6576e9e04158c8f8cdecd3cbc2002e03fc8a6cad0f9ad35ac |
|
MD5 | 8f0d3b7f3d31c71f837db34695129b93 |
|
BLAKE2-256 | 3d04ad9e6977779678c0a435c4093e5c9182fb8a96feec7bb6b297fab2eac84b |
Hashes for bezier-2021.2.12-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aebedd462c7f10e528a89e64c4df1e90aded3cf4a66ad98e7e96689a81c11aa |
|
MD5 | 7fd557715ff78857dac81aeef47f1d08 |
|
BLAKE2-256 | 6d3fe67d1b3fd889e330cfc3b2ed8d54065871ba36795a63d30c94a4085d4f02 |
Hashes for bezier-2021.2.12-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3c23a001024011a4dbe2fc34ac7b9d8a163206ff1b5381426379f63eb0a484d |
|
MD5 | e0afb867ef8c4c5279f4147dcf287e41 |
|
BLAKE2-256 | 37cb2dcd1f7b88e6081412b4d9f2ca9c4404fcb152a8945ed22c8f1ea2b38ed8 |
Hashes for bezier-2021.2.12-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcee7f18dcef5d3f2730cad2201323955fbd9226d6e90723e8d512535a291bf6 |
|
MD5 | fba05ed9c6cdc50876350f8748d61a08 |
|
BLAKE2-256 | 3b5143f763903495b3e877ea2f590dcdbfadbbb199d226e17325504e0878cd2d |
Hashes for bezier-2021.2.12-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 584c324a3c0b8cb3e2285456857b10bc3417625db6d8a0a8ffe9f28ede2b6076 |
|
MD5 | 9cc69fce190ace67d2d6182626202eb6 |
|
BLAKE2-256 | 38ab53066d69bde797fe3ed55d309e992c2170c39d5adcffd0a31e5eb77a72f2 |
Hashes for bezier-2021.2.12-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e87ce290bfdadc5e5f92f95b016c71cf68a61c273c353a84b48a40ea37b82240 |
|
MD5 | 22a4ee26ad99ecbe4458535abdd95dd0 |
|
BLAKE2-256 | 516e9b2d2ff062a7709d28e66a1f37294dfb78a9fd4a6aae6d7e6d4ba70fff0b |
Hashes for bezier-2021.2.12-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ce274c22e98729b464a1850a66266b04de2d1a67f6804b3c448bfe5cacf651a |
|
MD5 | e3ce936e8340289e0ce8048a6441adea |
|
BLAKE2-256 | a594d566fcf5d32bb5f71cab2a92e6e4883ffce7e06b6a011aa0758cc2385bea |
Hashes for bezier-2021.2.12-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d01aa9c685bee5e344e5936124bd732f5ff25337ee163737901a02a6c837e9cc |
|
MD5 | 6db4957bd859d3cd1aac2a1f81d188ca |
|
BLAKE2-256 | 441db70387e6f97d54f63334b946ef4fc4eef8623a42612cbe6b4645bc6b491c |
Hashes for bezier-2021.2.12-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65b128bfb55a618ab63464a5387387f8aa577c95f91faa0f94d0efc5d037cd22 |
|
MD5 | da9923fcec072814d5496928397b6b60 |
|
BLAKE2-256 | 3b48651cd0a23c80d3b8594dd2bc0825f84fb0cd7bf7d046a24580632a1a1489 |
Hashes for bezier-2021.2.12-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b929375f79c91d52517c0e25c250f342c473e7fc74d4b7a740d8693a2de6372d |
|
MD5 | 7787a9b711c878567ee04c0023545b0d |
|
BLAKE2-256 | 0c46fd94973dbc10638a16b60b0890e0f0f69c8e6143f088b4ad5d4ffac22989 |
Hashes for bezier-2021.2.12-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2d18fd54d92d461c6e843e3eaca7d54926288efd8f60625c31ef88fcc6132a4 |
|
MD5 | 3c8eceee717ac039f2e0e90a79ecaf84 |
|
BLAKE2-256 | 65120db4447c4eae0b81d3c0c9d485199d8de7c798f834984c87d92390344e19 |
Hashes for bezier-2021.2.12-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c667bfd8f6e52aebaca7672f047c79f420777cfd2a50c65c50bcf6ad07906c1 |
|
MD5 | 2cd06f4ab0ac7fb3e0de762810b1ae45 |
|
BLAKE2-256 | 612b190a448e8b3abd23ff3e94152a83d8cb25b47d68335eb2498c8e92bc3b95 |
Hashes for bezier-2021.2.12-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03a08de391be1ba035b31721c98457a7aac0e879149d80fb96ef211afa676161 |
|
MD5 | ae4a22d9ccc3c10e5b38527dad3eedb6 |
|
BLAKE2-256 | 92021b2037399d5783ae3d929c5b9faecdabd1c2c01dbcb95f8c290837a67d96 |