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

to define a curve as a linear combination:

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

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

https://cdn.rawgit.com/dhermes/bezier/0.6.3/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.3/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.3.tar.gz (348.2 kB view details)

Uploaded Source

Built Distributions

bezier-0.6.3-cp36-none-win_amd64.whl (653.9 kB view details)

Uploaded CPython 3.6Windows x86-64

bezier-0.6.3-cp36-none-win32.whl (647.5 kB view details)

Uploaded CPython 3.6Windows x86

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

Uploaded CPython 3.6m

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

Uploaded CPython 3.6m

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

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

bezier-0.6.3-cp35-none-win_amd64.whl (649.9 kB view details)

Uploaded CPython 3.5Windows x86-64

bezier-0.6.3-cp35-none-win32.whl (644.5 kB view details)

Uploaded CPython 3.5Windows x86

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

Uploaded CPython 3.5m

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

Uploaded CPython 3.5m

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

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

bezier-0.6.3-cp27-none-win_amd64.whl (656.7 kB view details)

Uploaded CPython 2.7Windows x86-64

bezier-0.6.3-cp27-none-win32.whl (650.5 kB view details)

Uploaded CPython 2.7Windows x86

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

Uploaded CPython 2.7mu

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

Uploaded CPython 2.7mu

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

Uploaded CPython 2.7m

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

Uploaded CPython 2.7m

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

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

File details

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

File metadata

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

File hashes

Hashes for bezier-0.6.3.tar.gz
Algorithm Hash digest
SHA256 cf19a2f74be13b5a4752daa3bf72d9228320235235de9f9941f5b8b67e37c571
MD5 e059ef747cd4369ccc28e6e6b3304fac
BLAKE2b-256 ad0f0dfa66dcfe72772de6d87a83d8860ee4840455ba9b4ea505de93dd884cc9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 fc2f01de185b26ac02c27aaca9f714390d90e72a3965eca6fd05c48918c8c3a7
MD5 f10e92c39952ee16dcf7404943ab7718
BLAKE2b-256 cfe3194d76c4817939a139cd5fb918c764d1ab21d1338696ebad703e5e43c0c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp36-none-win32.whl
Algorithm Hash digest
SHA256 b9e27a0743ef1a7768e293eee4c14c0d70969054e2c07dad9175c6459653ad6c
MD5 0eb7769d3bbfa4cb0f49980a82cfa536
BLAKE2b-256 385ed7066b1c770809b0555996cd380b73e4ebf90aac2ce91f3554bee79a6602

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4921ffba4ba2eee702c44a34081a4875156c05912fffa11e4c60c6135eeb2637
MD5 0d1ba288c21ff8622d81d500dd1d9381
BLAKE2b-256 555ef3ee69f212163b2cf6234ead24b0d200e883358e7a6bb3948faa5de138d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 00f628d588d6006bbc665128fdf30a23d0272b8ded19ec3b15f6c16863724079
MD5 d7f9dfac023c77fa935688e56b56021a
BLAKE2b-256 a215253139a7b943b219514bd70b360966487c3e7e5cd2d9f071a6e960956ac7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 6e339bdd67a71521caa612d728afce703be6266936497c6ce07dd451b1a4fa16
MD5 e95120374a355cb3c4e7e3970beb4298
BLAKE2b-256 3417a08dc3b7c400fc7c1d7b12b03eebc6ae0b06f9982544547452236684fae9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 7dab1787087f45628c53fd4e0227d3f6c205c65b5246b8b5acec9ec9623025e5
MD5 9414b32d05a0549999e36e06b8dd0cee
BLAKE2b-256 b5fbfa354dcd9c62c567546f8f330b02b638a1152b4558dd6b71055e47dfe0cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp35-none-win32.whl
Algorithm Hash digest
SHA256 8c2e18e93e17651910d472f6794f1bdee46d0e3135b5c8049b0ab069a490682c
MD5 2ef475968d91f46b2b03331e0713a843
BLAKE2b-256 625c5eb418fec5afce17717349a6426a22d66e47d56d0f9647bd6335c1314541

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d94161de74185bad7de4d6d573bd92c5a8ec0173d126a590c190b4dd3480418d
MD5 d92a6ce989b9626019a360e1cc1eb640
BLAKE2b-256 d2da12505e5ff7756a7cb528593de30f6fdeed29a063b519bb0cb2950bcf6580

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 10c27789ef496fba94db13ea2669b41ada98ebbdd4a5056e4502ef9cd0a1432e
MD5 c9307dd1f229da5ccf96f9cf031ad9c4
BLAKE2b-256 8957517748eaebd46917dbc6bf34cf8bbfc168bff6c02ef07db5e7dd803c8467

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 f4132b3d31032f970d042ccaa900a6b0b4324b9c0f86e2f26b7b912a22e709a9
MD5 4034a2719e228ac5f93d30a7c334fbcf
BLAKE2b-256 87dd7222b9cfcf9bc56f17b8ba3ab4ca024c3e325796e8f7a1fffcf274f11adf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 725e8b6e0c50db73ffa846250e451b711cb031cdd0265209ecc91dd48003f058
MD5 154a066bf9e904745c99d206a8150df3
BLAKE2b-256 c6825cefc983f4cd21a2a707a5a6cce028b1685d37eb57e6311754df3f3cc1e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp27-none-win32.whl
Algorithm Hash digest
SHA256 17778668653cf7a616848bccefa4863a75ac54a2ed28de728b11cfce681cb67e
MD5 e8c11458739699709ecc8f902a0b4b0c
BLAKE2b-256 dfb0ead88e340fd992a473727d54d24709d29ee9b1ff0b5c9d286f2042429634

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9110f7856122bccc0ec7b32f1e45add8534ef87a99f3dcb7a28acb7ef80f47f6
MD5 80bdfcb91a03e52359476ed1f59db61d
BLAKE2b-256 04c992b1af82cd81767272500f05e222914ea869e9b3a7ea0f6fa78e7dd70582

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 a79a629fb7d818b94f80aae348e28099928d8d1250d01d23f7403d40ef185128
MD5 edcc02d1576b2769abd4f3f35f74323c
BLAKE2b-256 9171b6f756119fe1bcbedcba628601dabddb6efa3eda7667aaf8f40b9fd7f234

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ea802ad28f351ed6af728bc44705ff1e1e8bf659b28a251341fc6b2ad9a1e1ce
MD5 0980ec24d6c005e5074655c953bca6ed
BLAKE2b-256 dd130a66a1741260414fc37e0c34bf502604d4bfb20c4de6da056e32e20654b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 997f127c2c4238e6fb7507230a77e510f3c1ad6dede35e11341dad8eaac31bb2
MD5 9b72f4402de5fa76392a792e85d6ffb0
BLAKE2b-256 bde58949f637fa4b33d7aeb574f04abd23072060797b00f38b1237c9c5e53640

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.3-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 72eb8b292d5b1170eea87aa074125584d75e13c37b068142b814ff56d8333844
MD5 800659ed839d8f4e26cab7f99f9afbc9
BLAKE2b-256 252df7e820f3a84d3cba7d30cb4561d8dead8fc30ed8de29988765886fdd5b7a

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