Skip to main content

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://cdn.rawgit.com/dhermes/bezier/0.6.1/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://cdn.rawgit.com/dhermes/bezier/0.6.1/docs/images/bernstein_basis.png

to define a curve as a linear combination:

https://cdn.rawgit.com/dhermes/bezier/0.6.1/docs/images/bezier_defn.png

This comes from the fact that the weights sum to one:

https://cdn.rawgit.com/dhermes/bezier/0.6.1/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

bezier can be installed with pip:

$ python    -m pip install --upgrade bezier
$ python2.7 -m pip install --upgrade bezier
$ python3.6 -m pip install --upgrade 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.0],
...     [0.5, 1.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.0],
...     [0.25,  2.0],
...     [0.5 , -2.0],
...     [0.75,  2.0],
...     [1.0 ,  0.0],
... ])
>>> curve2 = bezier.Curve.from_nodes(nodes2)
>>> intersections = curve1.intersect(curve2)
>>> intersections
array([[0.31101776, 0.31101776],
       [0.68898224, 0.68898224],
       [0.        , 0.        ],
       [1.        , 1.        ]])
>>> s_vals = intersections[:, 0]
>>> points = curve1.evaluate_multi(s_vals)
>>> points
array([[0.31101776, 0.42857143],
       [0.68898224, 0.42857143],
       [0.        , 0.        ],
       [1.        , 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://cdn.rawgit.com/dhermes/bezier/0.6.1/docs/images/curves1_and_13.png

For API-level documentation, check out the Bézier 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.

License

bezier is made available under the Apache 2.0 License. For more details, see the LICENSE.

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

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bezier-0.6.1-cp36-none-win_amd64.whl (923.6 kB view details)

Uploaded CPython 3.6Windows x86-64

bezier-0.6.1-cp36-none-win32.whl (882.6 kB view details)

Uploaded CPython 3.6Windows x86

bezier-0.6.1-cp36-cp36m-manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.6m

bezier-0.6.1-cp36-cp36m-manylinux1_i686.whl (2.5 MB view details)

Uploaded CPython 3.6m

bezier-0.6.1-cp36-cp36m-macosx_10_6_intel.whl (3.7 MB view details)

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

bezier-0.6.1-cp35-none-win_amd64.whl (918.0 kB view details)

Uploaded CPython 3.5Windows x86-64

bezier-0.6.1-cp35-none-win32.whl (879.1 kB view details)

Uploaded CPython 3.5Windows x86

bezier-0.6.1-cp35-cp35m-manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.5m

bezier-0.6.1-cp35-cp35m-manylinux1_i686.whl (2.5 MB view details)

Uploaded CPython 3.5m

bezier-0.6.1-cp35-cp35m-macosx_10_6_intel.whl (3.7 MB view details)

Uploaded CPython 3.5mmacOS 10.6+ Intel (x86-64, i386)

bezier-0.6.1-cp27-none-win_amd64.whl (937.1 kB view details)

Uploaded CPython 2.7Windows x86-64

bezier-0.6.1-cp27-none-win32.whl (901.4 kB view details)

Uploaded CPython 2.7Windows x86

bezier-0.6.1-cp27-cp27mu-manylinux1_x86_64.whl (2.7 MB view details)

Uploaded CPython 2.7mu

bezier-0.6.1-cp27-cp27mu-manylinux1_i686.whl (2.4 MB view details)

Uploaded CPython 2.7mu

bezier-0.6.1-cp27-cp27m-manylinux1_x86_64.whl (2.7 MB view details)

Uploaded CPython 2.7m

bezier-0.6.1-cp27-cp27m-manylinux1_i686.whl (2.4 MB view details)

Uploaded CPython 2.7m

bezier-0.6.1-cp27-cp27m-macosx_10_6_intel.whl (3.8 MB view details)

Uploaded CPython 2.7mmacOS 10.6+ Intel (x86-64, i386)

File details

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

File metadata

  • Download URL: bezier-0.6.1.tar.gz
  • Upload date:
  • Size: 778.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bezier-0.6.1.tar.gz
Algorithm Hash digest
SHA256 e8027c35b3fe4f16c4d42b74f201022ad6077cbf64c6131becc256345ba176c2
MD5 874bd37d5f2e306319999a174f717f80
BLAKE2b-256 3ea6601be6a14af6153198f3c296db48ff35d9daf6a95191ff051620b5bdb23d

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp36-none-win_amd64.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 80c889cf985701db8a089808f4e3a4d50f0e0ffd78071fe798eaa93fc347825c
MD5 0ffe6cf035e7cc3e5b651e3e2aac1b9b
BLAKE2b-256 504aeaf600cc63d2fd68b8b56b37fb0b232cdcaebd55d41f14eadfc571a5722d

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp36-none-win32.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp36-none-win32.whl
Algorithm Hash digest
SHA256 14374888308bcec5275d447b2c492047a89258a9144f385901a81fbc60b16bdb
MD5 dbb1b35c7e8796fe0ff0f5d953d6502c
BLAKE2b-256 16e5e0926e28bb693f2cfb422e77bbd8e74d148f78e20d991ec48743c9b7faa0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c4b871bf6eddbcd765b1c8a1e43b5087d7917b376f52d2a2274a75d88774c288
MD5 424703683556917999002a1883d00b10
BLAKE2b-256 5a3bdf5e8962f0bc68865ce71c9bbf7e691599582d3549b16e2a38c270291df8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.1-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 1055f4317ed1167797754a6ec7347d1306a0b71a9ab6d75a442c131df7cefed7
MD5 2cfe90f68563feece210d58cbd451b64
BLAKE2b-256 ce327901a30c3a0af400d30b1664102958538bd9d99dc142f00d629b4f62a260

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.1-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 2175dd9a0dd8c62092e92712c1420ebb7099e8b6b1dcf4e90e4bf5e13480dd12
MD5 2aaa2c651efced1d1ea2d4143a89c237
BLAKE2b-256 4c41e2827c73ffc4972f899453bb1472e72fa55f6e44d63b3bd32d077002fbe7

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp35-none-win_amd64.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 199db3105e29703cbb17a9c298608ce7db7cf3d3cc393c68f9b40d4d65d393b5
MD5 4466b3e928c79397eca238826fdca972
BLAKE2b-256 413d2bff4a4a80d9c81b31be7fb600a2fc5d6bfbd509cf7d37b2bc244a668f75

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp35-none-win32.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp35-none-win32.whl
Algorithm Hash digest
SHA256 3a69b8e26c0aa9f20b1a5473d4234d3ececb2891bcc436cf62cb0ef4ff40a1c9
MD5 625b73fd19445efc20d1add5d1991407
BLAKE2b-256 db598a5f454a26f58cab6461ba305a41753967136c5f0dfde835bdbe3ce0584b

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bd178d19282cb4798a5ff1bbce3deb1bf140e72ba77f185a7a891a2a0e57e04e
MD5 630bc0e83c705765a6edb19b962201ea
BLAKE2b-256 cbc483e87b9e17eff8f476bd79e43345bfaa49cdad43f464ee5fb29f32845ff5

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 bfb578c8bfd35d8d01a4b35006c230abdbddbd90a608a328382a9fabff260171
MD5 92aaa20a5947d7c775f560fc9d6d2fb9
BLAKE2b-256 4114626c98709a1d60d2be536bf09823988cba612940e5acb7419ffa3e521d6a

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 30e1ff7c0c6d23282f7c1537c707156f696599e8bef6b3cae8e45a4f2fc5fe37
MD5 d39bf3fe7c7670949be6304b8e594ea8
BLAKE2b-256 f6e0a93d74270a28711faf56b4586c038c4a9ba0dd78aee8a6decef32b4ec9d9

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp27-none-win_amd64.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 fd8285b84f0ebda5c81280bf80ddb859ea468157761242f776552812000c520c
MD5 925c45d2c89e31f351c543d9a242ed7e
BLAKE2b-256 8573fd25b25e1b3bb449945b5e4ee6aa1357b6c084aad05ba772695b894e4563

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp27-none-win32.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp27-none-win32.whl
Algorithm Hash digest
SHA256 d6d7a53686a937fad62bc2813f263bea48337f6e30b1466a38794c43428869ae
MD5 5d6a914e72eb28bbe116eb7e25f26134
BLAKE2b-256 0e3034fc6d14953a06623a28b10caf7e4ba430683f8ebf91800de11f8e5d2d3c

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 16959e7babbe9a90e7114dd1c88803409e875be02f41a7939d4e4533f6a10b09
MD5 5a9d57ff4ec2f75d45557b3481c60fa9
BLAKE2b-256 016f2ec931b412fcebfb755f8c98f7d35684fc2d305b15d5bdb02ad2f1553357

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp27-cp27mu-manylinux1_i686.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 9b24f37a7cb7dfa5279010b20dd47848bb1f43bfddaa3affd77a4ff42325923c
MD5 7599fd5b47541f2dfd587381744eae65
BLAKE2b-256 60ab1462a8ebd0cdf4e179a003673f5b8035372766b292104392497a93ddd779

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b30ec3dcac93219aa6aa413bf853d9bb2d9e28a3e82c44f2c2615d9304977bec
MD5 74337d347ccb9ac8577c3d91dbf88c23
BLAKE2b-256 26dc5bc9024d3c5977761f368e893b9bba7ce415d134b45f46fd28efd14febb6

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp27-cp27m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d7919885666e1cd4d5306bb243cbbe69b3743f4845423b397dccf8a845c73557
MD5 e8c1e8eb4f3ea1d8619a9e6c27632c61
BLAKE2b-256 94b092ec38639a2974fa5ac897dffcfd26d0925c53c2655155606aafb07c563f

See more details on using hashes here.

File details

Details for the file bezier-0.6.1-cp27-cp27m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for bezier-0.6.1-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 263cb2fa80571faa0f5ee5ddb1f8e0f4e2c1790f53d01994787e2a27f74a001b
MD5 d6f2f991a51230f3ae8cc2517e5c1205
BLAKE2b-256 635a1c5ccfc8afb4ff68d96c79ef42bd43f9bd88f82ef697846c4b680e08d623

See more details on using hashes here.

Supported by

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