Helper for Bézier Curves, Triangles, and Higher Order Objects
Project description
Helper for Bézier Curves, Triangles, and Higher Order Objects
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)
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(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()
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
Release history Release notifications | RSS feed
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.2.1.tar.gz
(85.4 kB
view hashes)
Built Distribution
bezier-0.2.1-py2.py3-none-any.whl
(107.5 kB
view hashes)
Close
Hashes for bezier-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e009297b7deb3f34179fba036e4639518684d631adb5d598bee84c90f5cb0490 |
|
MD5 | a66020fd4184f50684973367fd942cbd |
|
BLAKE2b-256 | 63e872d0a3b3b439f99936328f0b2c3ff1834c273ef330f76aac4183a1526e2b |