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

to define a curve as a linear combination:

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

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

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

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.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://cdn.rawgit.com/dhermes/bezier/0.7.0/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.7.0.tar.gz (352.7 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.7.0-cp36-none-win_amd64.whl (696.7 kB view details)

Uploaded CPython 3.6Windows x86-64

bezier-0.7.0-cp36-none-win32.whl (661.0 kB view details)

Uploaded CPython 3.6Windows x86

bezier-0.7.0-cp36-cp36m-manylinux1_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.6m

bezier-0.7.0-cp36-cp36m-manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.6m

bezier-0.7.0-cp36-cp36m-macosx_10_6_intel.whl (2.8 MB view details)

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

bezier-0.7.0-cp35-none-win_amd64.whl (692.5 kB view details)

Uploaded CPython 3.5Windows x86-64

bezier-0.7.0-cp35-none-win32.whl (657.1 kB view details)

Uploaded CPython 3.5Windows x86

bezier-0.7.0-cp35-cp35m-manylinux1_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.5m

bezier-0.7.0-cp35-cp35m-manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.5m

bezier-0.7.0-cp35-cp35m-macosx_10_6_intel.whl (2.8 MB view details)

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

bezier-0.7.0-cp27-none-win_amd64.whl (697.7 kB view details)

Uploaded CPython 2.7Windows x86-64

bezier-0.7.0-cp27-none-win32.whl (663.5 kB view details)

Uploaded CPython 2.7Windows x86

bezier-0.7.0-cp27-cp27mu-manylinux1_x86_64.whl (1.5 MB view details)

Uploaded CPython 2.7mu

bezier-0.7.0-cp27-cp27mu-manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 2.7mu

bezier-0.7.0-cp27-cp27m-manylinux1_x86_64.whl (1.5 MB view details)

Uploaded CPython 2.7m

bezier-0.7.0-cp27-cp27m-manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 2.7m

bezier-0.7.0-cp27-cp27m-macosx_10_6_intel.whl (2.8 MB view details)

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

File details

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

File metadata

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

File hashes

Hashes for bezier-0.7.0.tar.gz
Algorithm Hash digest
SHA256 101b0d07612361c45a426eeae190329931d3b59d062af0f7a41240b29e2af344
MD5 d4ff2e02385363c887c672e986800326
BLAKE2b-256 aa7d67e813bbf578e23ed6d0d6b8ef1a4f4b996d6f3c405c0300a7d93e388a80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 68bb319e42e570ca2bcc0ebb1da33b619fd3cfbaf51839f4dd4fd358f0d253c1
MD5 bc2a5fcbb3185d53ec7e2e7c06162065
BLAKE2b-256 9a85d7d71ccbc51113db6a2f15a4c7f21e5b4b4eb214b105adba40c59eec60c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp36-none-win32.whl
Algorithm Hash digest
SHA256 257acfdb767ef7bba70b829abe07db19bd777e80ee7a37adc3473d4a1f5598ef
MD5 593c82945c8f0cda92370a2da7b25b66
BLAKE2b-256 f7435b611a894f4b101241ac017f3935b6e7071cf515a4f69220b0ed211c8a76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0b19a81abda1128c88708d0ececf61ac99c21975de7d2f45d13757afecb65b72
MD5 b9a47e764ba2be001ac422d265bd5140
BLAKE2b-256 e10d9e9564b2b238235fd95c338ffae12bb28946717acc8ec8bf67120267b75f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 8be3e50ade8a691257d8a98190b4fb2cd48ccda4e03b4c4ae768f3cd86ee8dc6
MD5 c0f80589306c31f46ad3029259ffc132
BLAKE2b-256 f8c4785910a52407e98dc31a770cdaf7bc88eebfed08be958cea09299cf39262

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 4cf069ee9ca38d208821adf8c23a1e2929b35d3bf2335a60076333ad190d1403
MD5 8b60c366e84591d9d6d3e7fab54ee471
BLAKE2b-256 93a746800013e8b1549a250aec5335184a710438ed4cc98cc13c7aab6c0b7765

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 fa413ad9c6df3881d4c9376160c1197cdb255971a46c34e1ce6c22c0b8a84e37
MD5 5748a62f53913e4a5014c8c9b97610b2
BLAKE2b-256 f34dac9cede81c02a0008e493bae2db13d7a1ceafc700ab43b57b6aedc2c0e28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp35-none-win32.whl
Algorithm Hash digest
SHA256 34bc546b26a1b572a977969599b5c43aa89c3eb9575fdff4f3b44bdb3a4bcbe6
MD5 b9190a4a9651407f2623f16042ffcdd7
BLAKE2b-256 3a8cdad1f2e9fa85a6abe27a87b7286de8673a1f0eac50bd4ed776c08cf5c0de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 431061d94f3699a919580bb443b65cfe45610fc1e665c5157a969bf3269717c6
MD5 9c8d137a8c1153f8e0d59adc682ff562
BLAKE2b-256 5dfbe7696c5b011eb38969d8019b6af99d2aec5d5e364eee00ec9b313f1bb229

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 19cd7a541378fe8f7656c5c0a641da7e81091cb805ce9dad556f91bf995b969d
MD5 672ce97d0f5910e2c75353967a3bf00b
BLAKE2b-256 786279db4ed0787387fdca034f4b8394d2c8c6b03da01a4747abdc7d8c93bd53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 0103ce03e041916aefd39ae0f802847559bdff6201e6519da7950f5dfc58e0c4
MD5 5e6db919204ef480e4f02fecd800ab62
BLAKE2b-256 34666da4fb19b21996991ee8220eb80b68637657cb7e1c6862841ead42b2bc32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 ab75da930eb5aa2465bb3ef23e5fcb83b4ef57f21b732311013dac641911c333
MD5 1f91d77219cc969e1d36bc21fa3fc0f2
BLAKE2b-256 bc791e83094390ae0da0fa701309e47823cb552b09faeec2bc5bf5890661e902

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp27-none-win32.whl
Algorithm Hash digest
SHA256 79b9ca1b01b5f6443da7b27d166414ec778ba22a59fce81d01944e994d2cfdea
MD5 2f310ec8bcc81e7e0779766a2f824034
BLAKE2b-256 e094a8b14c773c2973de54b85b6e3a9dac97aff960c00619372350aeab331b54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a0aefe24b30cb7029e7bdc71fdafaeba4effd08e29fd3eabd161f25ea865b781
MD5 65dcf5c6450bddbfeba6bd005173bf5e
BLAKE2b-256 e618f4c712adda3d4c5fe1034637541cf4d562733fa457a13f25aebc7bacd34c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 38012799ae10f7847909a8114f49d1f3f55c090bc676d192f835ee469aa6f614
MD5 a6976962b2ee0e412155f52ca926c800
BLAKE2b-256 e4460e6f7ba710df2b076301ee5e4bf0265664034dd8672f724c29adf81dc1d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b3610c9f7e2cd6ef2940d0f3def27fbea6ee442183d679022b83f2714c63aff7
MD5 e4bff6f7cfa90bdfff1ea97dcfebec7d
BLAKE2b-256 e87b7df344d21fd0ffbf3ccb343d9c69850a94239b3053d85202eae597d394e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 a8fc3833be7a9a0cf23b0a0ad3032a924b3f1b39c093e88266d05964c6da1a1b
MD5 9b517f3993cb03bafef28b867e978494
BLAKE2b-256 5a3d1ed70f8541c3e2b52714384f75963ba875e90ab15733381d5817eafb207d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.7.0-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 f12a99b722fce1cafb1aacf28e6cc0756eb345bc80f410297a44a4d3421a8520
MD5 53252344c0b020cabe9784cbe70ee31f
BLAKE2b-256 208081eeee4064f19940b543fc8f7a20f44d0221d7d049ae629905f765ef0406

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