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

to define a curve as a linear combination:

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

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

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

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

Uploaded Source

Built Distributions

bezier-0.6.4-cp36-none-win_amd64.whl (653.6 kB view details)

Uploaded CPython 3.6 Windows x86-64

bezier-0.6.4-cp36-none-win32.whl (647.2 kB view details)

Uploaded CPython 3.6 Windows x86

bezier-0.6.4-cp36-cp36m-manylinux1_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.6m

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

Uploaded CPython 3.6m

bezier-0.6.4-cp36-cp36m-macosx_10_6_intel.whl (2.7 MB view details)

Uploaded CPython 3.6m macOS 10.6+ intel

bezier-0.6.4-cp35-none-win_amd64.whl (649.6 kB view details)

Uploaded CPython 3.5 Windows x86-64

bezier-0.6.4-cp35-none-win32.whl (644.2 kB view details)

Uploaded CPython 3.5 Windows x86

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

Uploaded CPython 3.5m

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

Uploaded CPython 3.5m

bezier-0.6.4-cp35-cp35m-macosx_10_6_intel.whl (2.7 MB view details)

Uploaded CPython 3.5m macOS 10.6+ intel

bezier-0.6.4-cp27-none-win_amd64.whl (656.3 kB view details)

Uploaded CPython 2.7 Windows x86-64

bezier-0.6.4-cp27-none-win32.whl (650.0 kB view details)

Uploaded CPython 2.7 Windows x86

bezier-0.6.4-cp27-cp27mu-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 2.7mu

bezier-0.6.4-cp27-cp27mu-manylinux1_i686.whl (1.2 MB view details)

Uploaded CPython 2.7mu

bezier-0.6.4-cp27-cp27m-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 2.7m

bezier-0.6.4-cp27-cp27m-manylinux1_i686.whl (1.2 MB view details)

Uploaded CPython 2.7m

bezier-0.6.4-cp27-cp27m-macosx_10_6_intel.whl (2.7 MB view details)

Uploaded CPython 2.7m macOS 10.6+ intel

File details

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

File metadata

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

File hashes

Hashes for bezier-0.6.4.tar.gz
Algorithm Hash digest
SHA256 e765de7693a387ae80e62897f41e6353c937dca403ce70f1d72079de3a81d728
MD5 e961efbd69051068f1bdd7f58433f825
BLAKE2b-256 a357ea5af8d16a519bfa9fc84b290a523e3e9d35366e38131a98f6b8f4a4ea60

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 9a45e12e906edf57f616d47c00f0a5fda2820f1ac797282b7c7a6c380dab043c
MD5 6c77d41039c59d64f909ac1aeac931eb
BLAKE2b-256 293a5c1d50d39596411111308accece84c5ffdc7bd6b1f62cfe8af3a5b19d80a

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp36-none-win32.whl
Algorithm Hash digest
SHA256 48208b306aa8eaf7483d15be2913274cb3428b51a3d205776883dbd2a3103529
MD5 d1e7b7e4deae29e26d9a7a3170b435e7
BLAKE2b-256 37a62ee5cef68e3cb550409b2af9352aa4f39fe772fda84b1eefb7211ad4d9ae

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4fabeba98271b99533f5ffbe95ecb8f6a0bb34fa1774d3b35307a5c675242b75
MD5 55bdb5028f9989596e3f57d75ef28ef5
BLAKE2b-256 9161b9cd7de42c08e038ca5f298ae5cc0032eccb77275b72c604bab7f394190f

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 9f93195b7511e7d3a6c7dae0b622441d8a0ac72f92e2eba2512dbef0ddcb3608
MD5 482f34535bb20ce31c9cd88a8d41defa
BLAKE2b-256 6d092b3230cd4c7095b8ccaf2079f28bc19a9a7b8dacd7ea9ca4465355f8aa56

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 f2a90c81377222f4a713c58c99105b0c89276a1148cfd31eabc2be0bec7799b3
MD5 35c72be79ce836ccd492c092ea40f9d5
BLAKE2b-256 ea033c77cc813159608889f562849d406e85d27e54aae553d841f4b97e4226e3

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 d9690e2121aa70e8ac34dba697ee721c08d4890331a75bf10c93e3bdfe50f348
MD5 7925f2bd5df5b5e73799ee9baf4a33de
BLAKE2b-256 1e51c6dc973f312a798759edf48d24a5ed2e68916a62e7070bf954760fdda4a3

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp35-none-win32.whl
Algorithm Hash digest
SHA256 140c80898a504e13e53dc3ecba8eba7c5489afef0097cc85e29bc25e71bc7beb
MD5 2e2d72d23d02cf91dffb4c33af3dad85
BLAKE2b-256 8bf2a704c61c1314b933f35d6cbb6af371369a061f0bfc9cc7bf41c51f38860b

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ad96549e5cf38dfbb48ee37bddc562ade06b78bd59b53d3862d2f0e8d4f51c43
MD5 cbdbae1ec2fcd812f2def8aa178c458e
BLAKE2b-256 cb313495ad44149198ce7cf45d0a6f3035a8ed3249700fd814481ca71c3d3ef9

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 30761bb57f7b259edd41679d0503b8c98adde619a468931dc36a92d674e46d50
MD5 278d2752d9734970053c9dbf17ace729
BLAKE2b-256 31f4e7b41634e26d71871a74b170a423a44aaf52cd54ebb7679a4881fec49b3a

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 326fee2a07ae077df9a40942690fdc5bc5647ef9606844a7331fb485bb0c2f41
MD5 c7768c3dd3fb408d4dcd37605d132a00
BLAKE2b-256 3eede3aa7b9ad6fcbc50249ae4cb299f3ebc06c8597cee5bb2b67bb0611193d6

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 433096cbeefcf468c7c5db7e1043b889eb6466840d7ce743f5cca14241644032
MD5 73ea8bf91715c5d85855cf6ba86458d3
BLAKE2b-256 f35975e1010ecbde7ecc3cd8058aca782b5e02defb1f115971f3a11d276e1ba9

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp27-none-win32.whl
Algorithm Hash digest
SHA256 613e9d2fea5ea94c45e25c719ff69efaaadc655c78f5e0f88f14d19d9f88d438
MD5 5ec4607158ff25f819383ba86f6daf06
BLAKE2b-256 f72685cacee9514d1da2b871dbbdd67d76ae5bf6e5b01da4f4cd91ef00853336

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e58da5580d8bcfa0d2caa4e19d907a028dd6c893ffe0e903302f973ba7caa1ba
MD5 a168f85882504239a65bd8ad6f97b5ac
BLAKE2b-256 231312e8b74f38fc5d309fd2f23e4804dc71b2bb8f9ee740aff7f7a789dfee05

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 46e7dff396bd99065c045a5f685345b387dd6b25388c43523ba312959afab9b7
MD5 cf97aec75f3e6af015af55cf2ca173b7
BLAKE2b-256 0ebc9c737ab525864311dd8acd2217926f88af37ca65fc7846360a10ff7d95bd

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 541e5ed94ca977949bedad74bf62b112790afe653e2babe98681ca362f149744
MD5 3fc0178968d0524935bbbd0196290421
BLAKE2b-256 3311a2d17442f7a1c1c326e56c713133904ad53a1d9acfea93e74908f839cb21

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 e614f120dde8c14193ef785b7ad6692778d073d34b3444c79c002b8595bec50d
MD5 f59f13878834b39dd5904fba8a477281
BLAKE2b-256 90c589a3a99a3c01d6d32689b893ce9fb505287a24490050a2842161ed4cc13a

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for bezier-0.6.4-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 052da851f1c9f9b7fc2b7c6832eceac2d37bb10d5f775aa60b28ae927910042b
MD5 28dae0cd778cdfca14ab617165062108
BLAKE2b-256 23c4e3c65cd00808b26baf1942be4c8b85877ac4a849a01ff8957ff3c8be9bb0

See more details on using hashes here.

Provenance

Supported by

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