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

Install

$ pip install --upgrade bezier

Getting Started

For example, to create a curve:

>>> nodes1 = np.array([
...     [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.array([
...     [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.311...,  0.428...],
       [ 0.688...,  0.428...],
       [ 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)
>>> 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/bbd1ee88c3b379348c71b0942115f36c62b728d9/docs/images/test_curves1_and_13.png

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

Apache 2.0 - See the LICENSE for more information.

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bezier-0.3.0-py2.py3-none-any.whl (116.5 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for bezier-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1c08393e16b1b135c3bf5bef83d62bba0017737cd9570ab10befcbf4d9706549
MD5 c5c510172b6a6035aa4a4271703b259e
BLAKE2b-256 7d652f5b038c145d0f1f8c97faeb39dd0724b99b2c4f7930dc9428bc34ba9bcb

See more details on using hashes here.

File details

Details for the file bezier-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for bezier-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dc271e5360aaece56c7dd9e956fe92a92eb47327b27add151b16dd53a2313fbf
MD5 06f2faecc0afbf7b4dcabe2ddc4099fd
BLAKE2b-256 8bf2321a5913ea92e65dc8adc6ad9564ffff4699ebd1278a5379550f601912d3

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