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

to define a curve as a linear combination:

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

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

https://cdn.rawgit.com/dhermes/bezier/0.6.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.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.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.6.0.tar.gz (777.8 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.6.0-cp36-none-win_amd64.whl (922.7 kB view details)

Uploaded CPython 3.6Windows x86-64

bezier-0.6.0-cp36-none-win32.whl (881.6 kB view details)

Uploaded CPython 3.6Windows x86

bezier-0.6.0-cp36-cp36m-manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.6m

bezier-0.6.0-cp36-cp36m-manylinux1_i686.whl (2.5 MB view details)

Uploaded CPython 3.6m

bezier-0.6.0-cp36-cp36m-macosx_10_6_intel.whl (3.7 MB view details)

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

bezier-0.6.0-cp35-none-win_amd64.whl (917.2 kB view details)

Uploaded CPython 3.5Windows x86-64

bezier-0.6.0-cp35-none-win32.whl (878.2 kB view details)

Uploaded CPython 3.5Windows x86

bezier-0.6.0-cp35-cp35m-manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.5m

bezier-0.6.0-cp35-cp35m-manylinux1_i686.whl (2.5 MB view details)

Uploaded CPython 3.5m

bezier-0.6.0-cp35-cp35m-macosx_10_6_intel.whl (3.7 MB view details)

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

bezier-0.6.0-cp27-none-win_amd64.whl (936.3 kB view details)

Uploaded CPython 2.7Windows x86-64

bezier-0.6.0-cp27-none-win32.whl (900.4 kB view details)

Uploaded CPython 2.7Windows x86

bezier-0.6.0-cp27-cp27mu-manylinux1_x86_64.whl (2.7 MB view details)

Uploaded CPython 2.7mu

bezier-0.6.0-cp27-cp27mu-manylinux1_i686.whl (2.4 MB view details)

Uploaded CPython 2.7mu

bezier-0.6.0-cp27-cp27m-manylinux1_x86_64.whl (2.7 MB view details)

Uploaded CPython 2.7m

bezier-0.6.0-cp27-cp27m-manylinux1_i686.whl (2.4 MB view details)

Uploaded CPython 2.7m

bezier-0.6.0-cp27-cp27m-macosx_10_6_intel.whl (3.8 MB view details)

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

File details

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

File metadata

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

File hashes

Hashes for bezier-0.6.0.tar.gz
Algorithm Hash digest
SHA256 dbe61bb9e99839040e40d1e65054a0ceca436012099a3daef01abd370b3c4e3f
MD5 ed0418b6fe11afacb4db74a1958add73
BLAKE2b-256 8d5c5b61412cf552d4d843c61ce2dc3e7cd35da9c609f6856798fc792b626d2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 d98489e5b4322f2e821626e047f968174945fa976eb4ea16640c9cc9c405968a
MD5 7eb0d05d5b49a6e0c9c3ad88fe9d24d5
BLAKE2b-256 a7eca64760bdd6d0a7ded7182ea3a079d19a7a0ba837caec6ca37733ae2720d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp36-none-win32.whl
Algorithm Hash digest
SHA256 219c88f7c46f3680522e0c8ee6259e614f3e1a614e53aa559229bd5e715ec92a
MD5 816a5b8952ee617884529061d54adc23
BLAKE2b-256 f471b6a98cc895aebf2bdb2ef57e592573cb994ae6d11dbc3fb62c0d6ef71355

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a8697a4c80a36d4c61000069842068bc969c97732166e5606b60463e591faf41
MD5 af97f075b70551ffd301a3b75d389332
BLAKE2b-256 a444b26932e8b7c557def923d4f14a8a9c636076f6b2aac1cb0cb54d7a33c7ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 90aa01f601bfe1212d8d74743aa791e6d966508b93db8278546235c41e43e01f
MD5 0e370d68231b5cf2c494e33d72ff724f
BLAKE2b-256 dde9105a0faa4940117130bc7b23c7753f3a10a548a8b9f7b660eb089cd2996b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 a1319c323178121a2961eb6a6fe7021ae0b1118a00ebf60b938714e4ca5aa360
MD5 1fc36ab5063b3463bbcd4ca30629c9e5
BLAKE2b-256 f7c9d821fdc85f37aa17fee633c1e7004f6f6e1e60155aef6acdfd5b785e891e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 5fdece151b3c7ee0c691364440d86ea28561ad6115208f32db53b89e639bc46e
MD5 e7c0379bda2fb8bead979a4d3be9bc1d
BLAKE2b-256 25fd75bcf18343ea2141f457c404115e671eb8559f5538f4b23a8f5c6d55ac68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp35-none-win32.whl
Algorithm Hash digest
SHA256 8418bb84d7e90763e75f9498901953a67d7e34e36c6d67a0c3ca260b5de1fc88
MD5 2b5ee7acdd5a8cc263c24e25464c43a4
BLAKE2b-256 1c20bd210c02d535c7fa91af3215b2e07dbfe599231acf1a315f233843f67e9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bd17c451ba36a7e121eafe87a522a4a70291d2a5250b43ebf4a8dd754bfb866a
MD5 8cf93c5a53d9020b59388e4bf60bde0b
BLAKE2b-256 6504e8bd1cf1cc19019db3e39ec61f4d4a3bdef7cf69523ba0edb790b3384658

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ce26e7ce6fdef99c6e2a7335d009f20a6a576975fa40c5154130aa55a424cb16
MD5 5019cf4b84e390f692ead0649b037d86
BLAKE2b-256 bbcb5e3647cf0a80caa5d513ed5403327e1b85d0ee243cc884fea8c7f6291241

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 97ff27269337b00fe10156ae929c6db2e6ad2424b232a4ba798f70804a81141f
MD5 5d1cfab53420b06bb3a741fa5ac45377
BLAKE2b-256 453d816a6396cc5ff6024061e9af7246a5c186f02a4677120a4c91d563b789d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 eb0a7483cca14e8fa62a9ac12864031bb3335ffb64204f5d5ae89e7b04c23646
MD5 6cbb48fecd13280950c383304912be32
BLAKE2b-256 8818006e239563e9fb48eaf97b031b60d1ac0ff01a4616353f591118410d9189

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp27-none-win32.whl
Algorithm Hash digest
SHA256 7fd9a0ca41034a80f9090e06bc536f6cfb3d9f35e3adcfdd5ce5512aaa431778
MD5 6429a1440d7b0483588d138de16b1153
BLAKE2b-256 028817d92b3bdf1a2907e6fd315b0cd0c8dcd444f84bf9e112541d180a4532e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b513a8e595ccfac6ae90ba21abb626820b80e64ce330a511ba188659571d0e9d
MD5 e1c8946b0d33a6c681ef60b9e9e5bbb6
BLAKE2b-256 bc5c4db7a68bcce83e45f5603ec25593a3a5b01587a2a21493b2a4e08fa59721

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ce5686c88b5209db68895e36cb0d4f93d2e6942e857c3ed5089137711aea2b8a
MD5 35705123523004bdb5208a1c0d273953
BLAKE2b-256 4c33fe331413dcfbdbb14d4ff20b082a77e33109f40d5c42b6b36f1d6c8cc0c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 58f978b2992a232dbf4aa377609fbffa2231a15c32f07de3f574c996b055a564
MD5 96bb5980b5aaa31aae6634aaf02b4695
BLAKE2b-256 c340ec110d09aca1fd6f074a3767860d524ba9c8d62f7883e237e6ec1c0a8aec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 87cf21904fd5ed7abd63ce7166ab319d6377ec199ac2d7617765c8f4fac1c885
MD5 4bbb151c962b0b743c4a04c1f4410ca5
BLAKE2b-256 089cce6a646af639630ea9cdcda05b672f444ef32347bc1ffa396cc0602ce4b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bezier-0.6.0-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 0bc40ce66eab0bc3130a2615902ee1059fa1b8230a8ffda62b133216f66e2f87
MD5 aa1663942d2d7bb30e3ec34b19bcdd54
BLAKE2b-256 b47b8f6793a43947b1b83c2a79f53f75db47b445d199dfeb939149ba38f56121

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