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

This library provides:

Dive in and take a look!

https://cdn.rawgit.com/dhermes/bezier/0.4.0/docs/images/test_surfaces6Q_and_7Q.png

Why Bézier?

A Bézier curves (and surface, etc.) is a parametric curve that uses the Bernstein basis:

https://cdn.rawgit.com/dhermes/bezier/0.4.0/docs/images/bernstein_basis.png

to define a curve as a linear combination:

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

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

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

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
>>>
>>> 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.4.0/docs/images/test_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.4.0.tar.gz (84.0 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.4.0-cp36-cp36m-manylinux1_x86_64.whl (476.4 kB view details)

Uploaded CPython 3.6m

bezier-0.4.0-cp36-cp36m-manylinux1_i686.whl (433.3 kB view details)

Uploaded CPython 3.6m

bezier-0.4.0-cp36-cp36m-macosx_10_11_x86_64.whl (173.6 kB view details)

Uploaded CPython 3.6mmacOS 10.11+ x86-64

bezier-0.4.0-cp35-cp35m-manylinux1_x86_64.whl (476.7 kB view details)

Uploaded CPython 3.5m

bezier-0.4.0-cp35-cp35m-manylinux1_i686.whl (434.5 kB view details)

Uploaded CPython 3.5m

bezier-0.4.0-cp35-cp35m-macosx_10_11_x86_64.whl (173.9 kB view details)

Uploaded CPython 3.5mmacOS 10.11+ x86-64

bezier-0.4.0-cp27-cp27mu-manylinux1_x86_64.whl (476.4 kB view details)

Uploaded CPython 2.7mu

bezier-0.4.0-cp27-cp27mu-manylinux1_i686.whl (432.9 kB view details)

Uploaded CPython 2.7mu

bezier-0.4.0-cp27-cp27m-win_amd64.whl (191.6 kB view details)

Uploaded CPython 2.7mWindows x86-64

bezier-0.4.0-cp27-cp27m-manylinux1_x86_64.whl (476.4 kB view details)

Uploaded CPython 2.7m

bezier-0.4.0-cp27-cp27m-manylinux1_i686.whl (432.9 kB view details)

Uploaded CPython 2.7m

bezier-0.4.0-cp27-cp27m-macosx_10_11_x86_64.whl (171.4 kB view details)

Uploaded CPython 2.7mmacOS 10.11+ x86-64

File details

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

File metadata

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

File hashes

Hashes for bezier-0.4.0.tar.gz
Algorithm Hash digest
SHA256 fbdf79c9a7e5302b5efd97f5ef1c41b55b152d5c21665b3c9b6c4b093c928abd
MD5 b6aa33017392ec3be4a2715ac63a635e
BLAKE2b-256 6a7d66a0c4f69fa60cf556db16fba958c1895616fbc3a4aea88aa405853003f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.4.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 be5cb77d53cd0e14560809fcb1ca3ff77d061f08fc27f5885a747a371c689a99
MD5 47e757d4e6067e01986d7d55bb5e8966
BLAKE2b-256 84b956b85fb911f1024afbbd9dce2a03ea4eb17f100d91e045d53eff6516b30b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.4.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 7ab58e9b7a3157cba74114f9dc10813cf60afabbbe7f388fd7ae871498fab084
MD5 3e08d42dcbc7972e1fb5a37236f13f6c
BLAKE2b-256 b01681e1d641a46bc48ae56d8337b3d71c76d658de8ef827d4395d7fe9712469

See more details on using hashes here.

File details

Details for the file bezier-0.4.0-cp36-cp36m-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for bezier-0.4.0-cp36-cp36m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 2d5752d662730eeb1104f3c5030503f5699590b10bbc6841b15a74ea90bce14b
MD5 21f42e7d2659ebe3e159fa9497b19856
BLAKE2b-256 400114d669298b9b72e8452e718c844ee8a28daabf6267e02b95c77ddda43c01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.4.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 61524c59a37a94a440cb8973341d4dd0a80c5db4dc71dafc56daef9aed8c6552
MD5 eab8db6db3efcfb73e3e47327ff2b52c
BLAKE2b-256 11799eb6f67b46e142fd348d9e7fabfeecd609cb6b275813e3247702f85aad79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.4.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 539cf4a486a0a593e8f277968b1c25d684ce371b4c2bc9281873fe467d78c782
MD5 5cafb5eaba3584a2aff30534f205fe4b
BLAKE2b-256 4b8f2df63b9ce0bfa7c29c20770a34473c156cbb0d48ed373cd282c20ffa4d94

See more details on using hashes here.

File details

Details for the file bezier-0.4.0-cp35-cp35m-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for bezier-0.4.0-cp35-cp35m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 f2ad3d0b32298827e5518fbb9f2e3f2b383e98fb465608e28eece0405c51e605
MD5 66ea7c5fa3bba54fff9e54010c8113a6
BLAKE2b-256 ada886a03aeae6ac69015bccc4017671300837c7a690ac6f5e3ec37903882afb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.4.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 747a7014d6cfe1513a546f126b58b4d7ee8aaf239ce25d8e8a70ea24957b2fa9
MD5 e181a989efdf5f9658e6cfe7bf963ffb
BLAKE2b-256 cb7e7fc8e312d90971aa42f883f4732d99b7b03c253acdec4f06ee9eb2c7806e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.4.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 c0eb95a62e7d13c4aa2e6411cb6cdccc3a6bce5319dae0c4097dc27f5f849c9e
MD5 2e9aae836254dc7f2033752344c7e078
BLAKE2b-256 dfa5a630cd2a9dfd7bd8b442c403addb8c46a6e58995b04f1913ccf4fc915592

See more details on using hashes here.

File details

Details for the file bezier-0.4.0-cp27-cp27m-win_amd64.whl.

File metadata

File hashes

Hashes for bezier-0.4.0-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 f20df08b27d1a51b3bbeb9e6b70463cee9129f7524cea8c7b83d1a520c07c24a
MD5 ae72e0bdd45479dfa006e751e7fac938
BLAKE2b-256 09b5b70f5331e2a091704d0df863e863ff18b57a0bc2e267dd39ac2d9566463f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.4.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cfe985a56ed5b29c838db8b3b97ceeb46067e803bbcc9980460d79696d9d189e
MD5 fe1fe7404e7878783d29a912a2ab3baf
BLAKE2b-256 eaf2a3923b5b019b300fd1a8df0155be104689e569092cbffbbe5648ea2df7ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.4.0-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 1e2ab645b9eebdd8445136eebf9216d7e9d389e1615d90a0b4557de78bb43710
MD5 e32015114338626d504fd1f3d7467f2b
BLAKE2b-256 0d11b1134cf7048cbe2895ebeac43ab063b0453ff9963a11943834795d4ca006

See more details on using hashes here.

File details

Details for the file bezier-0.4.0-cp27-cp27m-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for bezier-0.4.0-cp27-cp27m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 3eb6b4b7c0b70324f5bbfe8ff7ddb2239bd2989a91cd505b958f85abaf2fdda7
MD5 1770f1abf63048c747e4ae468111cbd1
BLAKE2b-256 e9269b7b5100d554020a7462498815535313d586a66618e5b6036f451da2381e

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