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

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.

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

Uploaded Source

Built Distributions

bezier-0.11.0-cp38-cp38-win_amd64.whl (740.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

bezier-0.11.0-cp38-cp38-win32.whl (698.0 kB view details)

Uploaded CPython 3.8 Windows x86

bezier-0.11.0-cp38-cp38-manylinux1_x86_64.whl (991.2 kB view details)

Uploaded CPython 3.8

bezier-0.11.0-cp38-cp38-manylinux1_i686.whl (770.0 kB view details)

Uploaded CPython 3.8

bezier-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

bezier-0.11.0-cp37-cp37m-win_amd64.whl (734.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

bezier-0.11.0-cp37-cp37m-win32.whl (691.4 kB view details)

Uploaded CPython 3.7m Windows x86

bezier-0.11.0-cp37-cp37m-manylinux1_x86_64.whl (995.2 kB view details)

Uploaded CPython 3.7m

bezier-0.11.0-cp37-cp37m-manylinux1_i686.whl (771.3 kB view details)

Uploaded CPython 3.7m

bezier-0.11.0-cp37-cp37m-macosx_10_6_intel.whl (2.0 MB view details)

Uploaded CPython 3.7m macOS 10.6+ Intel (x86-64, i386)

bezier-0.11.0-cp36-cp36m-win_amd64.whl (734.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

bezier-0.11.0-cp36-cp36m-win32.whl (691.5 kB view details)

Uploaded CPython 3.6m Windows x86

bezier-0.11.0-cp36-cp36m-manylinux1_x86_64.whl (997.7 kB view details)

Uploaded CPython 3.6m

bezier-0.11.0-cp36-cp36m-manylinux1_i686.whl (772.8 kB view details)

Uploaded CPython 3.6m

bezier-0.11.0-cp36-cp36m-macosx_10_6_intel.whl (2.0 MB view details)

Uploaded CPython 3.6m macOS 10.6+ Intel (x86-64, i386)

File details

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

File metadata

  • Download URL: bezier-0.11.0.tar.gz
  • Upload date:
  • Size: 376.6 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0.tar.gz
Algorithm Hash digest
SHA256 435611058d5250dad0423f28f193bfafce873ef372978da59401697138996116
MD5 df74b591ed99edb6cef0c66f56cace99
BLAKE2b-256 295d580fee8bd9313bd3cdef4f93fbc74076ed007970e85506f386902a2ced13

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bezier-0.11.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 740.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b9702489cdbaa280a1fff9a520a9f840319959226ee1812b1b6f2ac16f77d236
MD5 bd12f315f352624ccd9d10c3a5863033
BLAKE2b-256 8f738d39f92ffc1c38bec4136e27aa7bfd6b143ffef53e0f2bc11630186db000

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp38-cp38-win32.whl.

File metadata

  • Download URL: bezier-0.11.0-cp38-cp38-win32.whl
  • Upload date:
  • Size: 698.0 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 8b2abb1f9e1d65607edef194277706ff9da653af5fc5d6b9fd692d2664f45c8a
MD5 4714a396d446152e6ef10fb447e16441
BLAKE2b-256 5d900e9b47487c9f71be2b6509441cef21ecf91fac894d015c7d7250a75fbd82

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: bezier-0.11.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 991.2 kB
  • Tags: CPython 3.8
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 542873d2c52112b937fed6766e5747aaf2fc9183bea43997142aa0fd6ba21c7e
MD5 aa1b2687a45cf0ac44713b9160436961
BLAKE2b-256 bdb70ff0df6cce559fc702904f9aa68b073e38a436d3d4f05da16ede7868cb35

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp38-cp38-manylinux1_i686.whl.

File metadata

  • Download URL: bezier-0.11.0-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 770.0 kB
  • Tags: CPython 3.8
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 c608c0dcd3b422ecd3db97d9799676607de2f3a3b690a4148be58790b0c4656e
MD5 7011a643b3c5bf183fb4e31ae8bcceee
BLAKE2b-256 aab0e620a99657addcb5b1fdf29f1d6a8ea3b25cc4e568eae1e0a2d27900ff47

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bezier-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 895502fc2a36f4b1f4243b79f18dee61d1b288171b33cd53324b6af5426258ce
MD5 6aa1f18ee83b333ed4d6e4b5bb045f6f
BLAKE2b-256 4c431a0da2567e39bea347cb4f3e5b6fe6f6e486ec7dc031aa7270a3cf35502b

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: bezier-0.11.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 734.5 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 533df68f9ca61a16d4883279f3ae22221113ea8f8fac0fa70c72e9b66dddc432
MD5 9eea9068a3a3b6af08c9cdbcde221d74
BLAKE2b-256 275e60a7cadb9331a1ad5885babebedcf78f5a2318e49a974b292701aaa990e5

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp37-cp37m-win32.whl.

File metadata

  • Download URL: bezier-0.11.0-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 691.4 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 5d58f6b3b8ad7232b8212d9f726abd604652cb00f7bef6e4666e006554c089e2
MD5 76c32a4fc9e5d0e3a9b0631dc3252df6
BLAKE2b-256 4998884e04990432535128a2fbfe6630a01bc559e59437dfd2347115c23a7097

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: bezier-0.11.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 995.2 kB
  • Tags: CPython 3.7m
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1dcd6fcb1985293850c67f69fd71010ac13a33b6a80e9c9892e51dd8b4a9e7ec
MD5 d6b106375874e477e891651d6e09b6c4
BLAKE2b-256 076f0e55e3d0801b4da5c01b7a782bc29b49e0b46d25461d080b2bd062aed9b4

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: bezier-0.11.0-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 771.3 kB
  • Tags: CPython 3.7m
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 3a15d5b2cfb67959650d3401b27a1f86aa6e1140f1fb7f64b51d76fb80b1669b
MD5 6f5d98fb835f33ad745b53219f3d806e
BLAKE2b-256 f9078abdcd80ab710745aea8fdef4c663677ee561eb326a916fc159466ffda59

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: bezier-0.11.0-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.7m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 1953c5a8421c7aca719bb7068defa654e454ccbd96dad373145e021a71bb336c
MD5 3ea629aca29a44df0342400ef9e25796
BLAKE2b-256 205c436f712c63be53295a05fb79645cce47492a3b21f51cf49dc4bdedafb7d0

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: bezier-0.11.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 734.5 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 44ac68991d60b48b8f56d8a4e3137277e23515a54b7eaa92a103f0d98e1b4477
MD5 a513ac9db39351f5724b0072cc5e0461
BLAKE2b-256 90787349b078cc03936dacb543ee19933b9148909f8ea1048da0b218f103243f

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp36-cp36m-win32.whl.

File metadata

  • Download URL: bezier-0.11.0-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 691.5 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 cf12315e0e84586a158a3f71c0ed58a6cc404400c331a1911e20be6155d20d83
MD5 7ddea86b7f7d08c5df73abdd1e8ebad1
BLAKE2b-256 ed24719e02671f10c1249c7b85d2cb7b1de75b03f153d2a91547549708f505bd

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: bezier-0.11.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 997.7 kB
  • Tags: CPython 3.6m
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 170dcd8c442bc5ccb498d31ce687c4750be723d91c873a94ecd00e19fee66ca7
MD5 607c98a5f1952fbdeae1ed29ad6a62c0
BLAKE2b-256 0c98ff15b1bbdb07806b1a59b2032664d7b67e71ad42147d48bc7b14b070800f

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: bezier-0.11.0-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 772.8 kB
  • Tags: CPython 3.6m
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 452527d5efa2fc71eb0ed8ba90678b050e10ea4325d5376dfab8b5c2de646792
MD5 cbda0773ec6d7f81c036f7a4fc2153bd
BLAKE2b-256 889d42f6839a7f0ca4bd10f6444c8bb966768957a0771fe39a93ee7eb4ec18dc

See more details on using hashes here.

File details

Details for the file bezier-0.11.0-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: bezier-0.11.0-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.6m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using 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

File hashes

Hashes for bezier-0.11.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 188db1e5265a2b499dc98b82928987d45f9ada38badf14678a8eafe3459e36a0
MD5 4f4a7c8387dbd51d30ff15b106cfc049
BLAKE2b-256 74e033975b1a3459685e7a7ee1cfdaa01b89f5c7414883b0b48e0c65d687a7fd

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page