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 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.5.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.5.0/docs/images/bernstein_basis.png

to define a curve as a linear combination:

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

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

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

$ pip              install --upgrade bezier
$ python    -m pip install --upgrade bezier --user
$ python2.7 -m pip install --upgrade bezier --user
$ python3.6 -m pip install --upgrade bezier --user

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.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(
...     intersections[:, 0], intersections[:, 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.5.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.

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

Uploaded Source

Built Distributions

bezier-0.5.0-cp36-none-win_amd64.whl (643.7 kB view details)

Uploaded CPython 3.6Windows x86-64

bezier-0.5.0-cp36-none-win32.whl (654.7 kB view details)

Uploaded CPython 3.6Windows x86

bezier-0.5.0-cp36-cp36m-manylinux1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.6m

bezier-0.5.0-cp36-cp36m-manylinux1_i686.whl (1.6 MB view details)

Uploaded CPython 3.6m

bezier-0.5.0-cp36-cp36m-macosx_10_6_intel.whl (2.5 MB view details)

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

bezier-0.5.0-cp35-none-win_amd64.whl (640.7 kB view details)

Uploaded CPython 3.5Windows x86-64

bezier-0.5.0-cp35-none-win32.whl (652.6 kB view details)

Uploaded CPython 3.5Windows x86

bezier-0.5.0-cp35-cp35m-manylinux1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.5m

bezier-0.5.0-cp35-cp35m-manylinux1_i686.whl (1.6 MB view details)

Uploaded CPython 3.5m

bezier-0.5.0-cp35-cp35m-macosx_10_6_intel.whl (2.5 MB view details)

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

bezier-0.5.0-cp27-none-win_amd64.whl (648.9 kB view details)

Uploaded CPython 2.7Windows x86-64

bezier-0.5.0-cp27-none-win32.whl (665.2 kB view details)

Uploaded CPython 2.7Windows x86

bezier-0.5.0-cp27-cp27mu-manylinux1_x86_64.whl (1.7 MB view details)

Uploaded CPython 2.7mu

bezier-0.5.0-cp27-cp27mu-manylinux1_i686.whl (1.6 MB view details)

Uploaded CPython 2.7mu

bezier-0.5.0-cp27-cp27m-manylinux1_x86_64.whl (1.7 MB view details)

Uploaded CPython 2.7m

bezier-0.5.0-cp27-cp27m-manylinux1_i686.whl (1.6 MB view details)

Uploaded CPython 2.7m

bezier-0.5.0-cp27-cp27m-macosx_10_6_intel.whl (2.5 MB view details)

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

File details

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

File metadata

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

File hashes

Hashes for bezier-0.5.0.tar.gz
Algorithm Hash digest
SHA256 81346179e52815b8381a6e9f32a5d10205fe949256c4dc849611d2798556ba47
MD5 05f13801f36e65ac20d50cb6516f84f0
BLAKE2b-256 a917bcdcb73355d736a33bfdd3c18a9ddd31a9d51b9764534b0eb10ee7ea5133

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 b5244261f3e2ee7469e8e6bd9dfebb3ea3762797983f9f0766eee406c1d9bf6d
MD5 b989fa859af18737b1d836c067d12caa
BLAKE2b-256 858d277792f3dfdc2971ba4a3aa4737c993021faa516333413fb5b98c4101a62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp36-none-win32.whl
Algorithm Hash digest
SHA256 6e8e92e83bc89803f5c89cd7ea844ea79b4e2314432b1e3305ceaf6ab0555c10
MD5 310d27c27eaa5657a9b4aef29c254c59
BLAKE2b-256 f05c16556b10c1f975d84618ce049331eb0635a14bdd4e5ddc60386ce7084be2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 733b55880ab941345d3162e71cdef8aebbb45791b2bc0a1e53b127ee22aa77c7
MD5 f57608911419be26149126d0c1764e74
BLAKE2b-256 d0d9d65b1cdab37b3e12a41ef63de84115b51f2d8a4aee664c3ee1faedee3801

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 b9799e6861acddc879636f839a21186ae5f6cf4428cafad015b39c4f3cbe2267
MD5 89e4bfa54071853bc41a58f79ab22e39
BLAKE2b-256 468c76866a29450c9ba825136813a9a6bd4bd22759459e4bd5ae193fe0a30f0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 ddb4d034ad086e72d9ae5174258bf150aa13a497bd76df042d5a8da9826ee83d
MD5 6340faf90b59a0763dbf82a38e454d8c
BLAKE2b-256 05b47ca7519711518d13edd034c7d3527a299d781ab1dbab41abc5e8e5bf5172

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 a9de293ecf5055aded1aa4e1cc9969f417acd9658c13d313cbef1d8a030ca6c4
MD5 d86b4f78e324f99abdac54e86e1819cf
BLAKE2b-256 129b6f56dcdda7285a308a83d5eb089f19824409dc92e37c84a362bcb6bf748d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp35-none-win32.whl
Algorithm Hash digest
SHA256 ae6f115272823db3994a9ada4ba44c9b12021ccc7c2629f48e17f1620e980744
MD5 a775c2739236a3a99cce9fba63d310e0
BLAKE2b-256 1700a8163799ee042cdb17130e8b0f2e55f2f493e2135d6da04d319ff57ce1ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3227c1c870c5a2b21974205f58a166b6355a90fd852ee9e3c8bc3e738c10b489
MD5 acfd3bfcc3f3d7f5cfae47956d833797
BLAKE2b-256 a169f9471e4e17939b80605678fa8f8342f0251c31c91ee440bc5dc74a0dcb06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 5b649e371fb9ad4e6373f6ea29daa188b79e773a29bfb5ea625ab77e2cec39ec
MD5 0c0847b37ce2c016c8fd333aa6866d07
BLAKE2b-256 8f4004f08db440b301cfbd65253abab556f651cf1a9f4a3c1385d2f05cf5671a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 0ba4d1da278f25761a6e76c601a96f883293b4cc5fee947b7cbd349e78ab74fa
MD5 4917ca906fa23be55fdca9af801f60c9
BLAKE2b-256 70796f25c695c6984e9314b33f9d67430a889a98b4ab49a30fbf199382bf387b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 8733403f6c5c9e74b2ad7cd7d638c232315cd925bda19d4a1b7da69ef54b8b1f
MD5 b62035314ba43dc4e0fccea545784ae9
BLAKE2b-256 e14e3c14421642751c1ac8d50a792cf53359c2e48ebbbec7b14a6978a1eb29d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp27-none-win32.whl
Algorithm Hash digest
SHA256 8a53cab25d9dd172a1a5b82dcb22d1b94834419c68f96e5da6f9932d01e94d05
MD5 28a9b416cc32af8e0a0b764d1422e20f
BLAKE2b-256 307d9b3d15e943c36d104a88d583fa12378182254c13c8fed4ef1a2d9ef33666

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5ccf9a979dd7c12b4c72cb7fb51b1322e00bc4342a2b4aa65f67f62426544bb3
MD5 63cff8a74ed2f63815138d79063181c8
BLAKE2b-256 5f59c66d13e347fd77b62375c5fb9687a444a147b2d1de2d5afea292cbfe1255

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 458770fac41e6ea942377bf7a629039a5f3cb8d72b04ead681779e1a80a2fad0
MD5 ca1d8c4a646b79b9844db8a2b0af5206
BLAKE2b-256 d7f3b65cc36aa589cead65c1d74ef24f56e931ea55a5cea24b46a07ea04b911b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2073ba703bc70cc667f9e339e47ea43c6435bc4ff99804f7523fc9f02d29704c
MD5 d38be35016d2b3b97aa5ebabdbde3761
BLAKE2b-256 5556ca7d21e3001ed921d151937282bbebcfbc52eaf510dbd1a9f263c72d32ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d43a169ef0fd7f4c086c3c16af564f369898e1545579ac1db3fb3831b042fe6d
MD5 8a350bcc5fb46d0ddb1a917a035a40ec
BLAKE2b-256 939d94a67f31ab0ba2dd6e579ab9112e4a39d80e3dd9c602eeb00fe0c27ba0fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.5.0-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 4fc871726ea84de232d567cd31b96d6ce0b2a8fe8dc578c4367d30f61cace7e3
MD5 36a3464474248d5d727a4561be2d437b
BLAKE2b-256 d7f0991573b365bfafebd4084c756f9c1dfba1f2bede5ed8abb026673c066296

See more details on using hashes here.

Supported by

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