Skip to main content

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://raw.githubusercontent.com/dhermes/bezier/0.10.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://raw.githubusercontent.com/dhermes/bezier/0.10.0/docs/images/bernstein_basis.png

to define a curve as a linear combination:

https://raw.githubusercontent.com/dhermes/bezier/0.10.0/docs/images/bezier_defn.png

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

https://raw.githubusercontent.com/dhermes/bezier/0.10.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

The bezier Python package can be installed with pip:

$ python    -m pip install --upgrade bezier
$ python3.7 -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.5, 1.0],
...     [0.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.25,  0.5, 0.75, 1.0],
...     [0.0, 2.0 , -2.0, 2.0 , 0.0],
... ])
>>> curve2 = bezier.Curve.from_nodes(nodes2)
>>> intersections = curve1.intersect(curve2)
>>> intersections
array([[0.31101776, 0.68898224, 0. , 1. ],
       [0.31101776, 0.68898224, 0. , 1. ]])
>>> s_vals = np.asfortranarray(intersections[0, :])
>>> points = curve1.evaluate_multi(s_vals)
>>> points
array([[0.31101776, 0.68898224, 0. , 1. ],
       [0.42857143, 0.42857143, 0. , 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://raw.githubusercontent.com/dhermes/bezier/0.10.0/docs/images/curves1_and_13.png

For API-level documentation, check out the Bézier Python 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.

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.10.0.tar.gz (568.2 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.10.0-cp37-none-win_amd64.whl (723.4 kB view details)

Uploaded CPython 3.7Windows x86-64

bezier-0.10.0-cp37-none-win32.whl (681.8 kB view details)

Uploaded CPython 3.7Windows x86

bezier-0.10.0-cp37-cp37m-manylinux1_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.7m

bezier-0.10.0-cp37-cp37m-manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.7m

bezier-0.10.0-cp37-cp37m-macosx_10_6_intel.whl (2.0 MB view details)

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

bezier-0.10.0-cp36-none-win_amd64.whl (723.4 kB view details)

Uploaded CPython 3.6Windows x86-64

bezier-0.10.0-cp36-none-win32.whl (681.9 kB view details)

Uploaded CPython 3.6Windows x86

bezier-0.10.0-cp36-cp36m-manylinux1_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.6m

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

Uploaded CPython 3.6m

bezier-0.10.0-cp36-cp36m-macosx_10_6_intel.whl (2.0 MB view details)

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

File details

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

File metadata

  • Download URL: bezier-0.10.0.tar.gz
  • Upload date:
  • Size: 568.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.4

File hashes

Hashes for bezier-0.10.0.tar.gz
Algorithm Hash digest
SHA256 122750fa004fb00d6dae9602c36864ec32a8f315bf56988d774a1533650131a8
MD5 58ead3ca2db323caa1a680a6f2792e38
BLAKE2b-256 cd480dba0d6c9c76b3bcd34c84ec184a877388580056bde732146f982c2aaf07

See more details on using hashes here.

File details

Details for the file bezier-0.10.0-cp37-none-win_amd64.whl.

File metadata

  • Download URL: bezier-0.10.0-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 723.4 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.4

File hashes

Hashes for bezier-0.10.0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 4f50d58cb2f1af671de0a9004abf79dc8ccb710acc26bfe26b0132eec5c62ca3
MD5 c9a65983a4669b532872f487481d358f
BLAKE2b-256 21f0c9b33a0703ac9a63e8198cdeac7dc7287c2ade7722ce6d3b77075ba63756

See more details on using hashes here.

File details

Details for the file bezier-0.10.0-cp37-none-win32.whl.

File metadata

  • Download URL: bezier-0.10.0-cp37-none-win32.whl
  • Upload date:
  • Size: 681.8 kB
  • Tags: CPython 3.7, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.4

File hashes

Hashes for bezier-0.10.0-cp37-none-win32.whl
Algorithm Hash digest
SHA256 3dd9e04b2a43c2e6d4740e12fdb9e2208263cf84df78ab246567a78a29b076c6
MD5 0729de6a52e0c1c310ad529bd6f8a71d
BLAKE2b-256 224d120771c8d07ffa737f03b8768a324f845cb657e43097a7e56009c1dc4ee8

See more details on using hashes here.

File details

Details for the file bezier-0.10.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: bezier-0.10.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.4

File hashes

Hashes for bezier-0.10.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 19afada34e81fa2cde5ac8992743b53157c36413f97b5ceee75073be11de0eb1
MD5 f97b4b43913b8a5d73b2eed600ca89d4
BLAKE2b-256 01e933c83b00bae83dfd3d9ac5e5901e7e6fcd45e02747da758ad1017c8df356

See more details on using hashes here.

File details

Details for the file bezier-0.10.0-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: bezier-0.10.0-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.4

File hashes

Hashes for bezier-0.10.0-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 65d797c0fd7cf216aef94fb50e24c6e60507dc7eb794f2e539a3a4f94448a4c2
MD5 3671365d0604d2a0dab4f905a13ac989
BLAKE2b-256 377617a356409182c69838c36188111ce13de963e02eff65fab7c4fcb8709ec4

See more details on using hashes here.

File details

Details for the file bezier-0.10.0-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: bezier-0.10.0-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.7m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.33.0 CPython/3.7.3

File hashes

Hashes for bezier-0.10.0-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 5936ab42b558e119d07c2bae2e55acc190820427e9476294b4c6315960cc74b5
MD5 66c35abc5dbf6bb626ac65b8c9b4d1db
BLAKE2b-256 7be4686f17712339c98172a00baeed582cf30ecb979d39147ce00a6521066106

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bezier-0.10.0-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 723.4 kB
  • Tags: CPython 3.6, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.4

File hashes

Hashes for bezier-0.10.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 94f60ed278488dea0fb815a407f563c8d545d8b5a9c86d2cd324ec78e1bf6e90
MD5 bfbdba05d4cd10b6d70b2b277e28efd9
BLAKE2b-256 bc7c768f21c22be4c5bf7a7ac597ec01c8fa9cd93af0519533dfe5cdc79e47fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bezier-0.10.0-cp36-none-win32.whl
  • Upload date:
  • Size: 681.9 kB
  • Tags: CPython 3.6, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.4

File hashes

Hashes for bezier-0.10.0-cp36-none-win32.whl
Algorithm Hash digest
SHA256 846a628d2ac05677e27bc2bb9277fb3e000c25389632a6770b5402ca5379ba9d
MD5 61ca7dcc895652d7fd89e16835138127
BLAKE2b-256 3aa05b7d23604d925c745c77392efc5944b7a715c0ae07e336c80d0f10d72181

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bezier-0.10.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.4

File hashes

Hashes for bezier-0.10.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ad583b400d53c858071a6bba7c0a67a55a5819c3dffb2bf93eaed365c351b2a3
MD5 5e66d1fed1b666506d5dcd6768edb865
BLAKE2b-256 4accb14db3b165f5fa7fece7d09b1b5259cd0e6c2395e1a1faf2a96a05f3befb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bezier-0.10.0-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.4

File hashes

Hashes for bezier-0.10.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 32a264a097b4a77a52eb2a041ec330b2464dbc4ec9805afbf9cf697da324f9a0
MD5 459193ec3d620a72709e7f14b119515c
BLAKE2b-256 2db59aa82a29d75a62e65050ec443b61b70137d2bf30cd9a8c04988f85d6ba6c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bezier-0.10.0-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.6m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.33.0 CPython/3.7.3

File hashes

Hashes for bezier-0.10.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 658fc4d9049500f57a0651956d34b80b92a1a533b2a959836fab752fdb46f38d
MD5 c2bdf5284b411ba753c90345140ca2d9
BLAKE2b-256 f534960f4657d10db84f2741b678ad925f293f989f6cabdd7b4eccb5d489474f

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 Sentry Error logging StatusPage Status page