Create C2-continuous, non-rational cubic Bézier splines. In other words, this will approximate or interpolate a sequence of points into a sequence of non-rational cubic Bézier curves.
Project description
Non-rational Bezier curves and splines (composite Bezier curves)
This package exists mostly to create C2-continuous, non-rational cubic Bezier splines. In other words, this will approximate or interpolate a sequence of points into a sequence of non-rational cubic Bezier curves.
Should be relatively fast, but this isn't suited for heavy math. This is for taking some points you have and making a nice-looking curve out of them. Specifically, a cubic Bezier spline, which is made from the type of curves used in SVG, fonts, and other vector-base programs. I am only interested in feature requests that directly apply to that purpose. This is not an exercise in completism.
this package will
- Evaluate, differentiate, elevate, and split non-rational Bezier curves of any degree
- Construct non-rational cubic Bezier splines (open and closed, approximating and interpolating)
- Evaluate and differentiate non-rational Bezier splines of any degree
this package will not**
- Work with rational Bezier splines, b-splines, NURBS, or any other generalization of Bezier curves
- Decrease curve degree
- Approximate curve intersections
- Approximate the length of a curve
- "Stroke" (move left or right) a curve
** much of the "will not" features can be found here: https://github.com/dhermes/bezier
Public classes / functions
# a c2-continuous cubic Bezier spline near the control points
new_open_approximating_spline([(x0, y0), (x1, y1), ...])
# a c2-continuous cubic Bezier spline near the control points
new_closed_approximating_spline([(x0, y0), (x1, y1), ...])
# a c2-continuous cubic Bezier spline through the control points
new_open_interpolating_spline([(x0, y0), (x1, y1), ...])
# a c2-continuous cubic Bezier spline through the control points
new_closed_interpolating_spline([(x0, y0), (x1, y1), ...])
Any of these will return a BezierSpline object. This object has a some of the usual methods (e.g., elevate, derivative, split) to help find path normals or do some light modeling, but you may be most interested in.
# plot the spline at a given point, where time is 0 to
# (number of input points + 1)
spline(time: float)
# an svg data string
# (the d="" attribute of an SVG path object)
spline.svg_data
Examples
Some of these use double and triple repeated points to create "knots". This isn't a special function, just a feature of Bezier math. The idea is clearer with a picture.
Most of the math can be found in:
- A Primer on Bezier Curves
https://pomax.github.io/bezierinfo/ - UCLS-Math-149-Mathematics-of-Computer-Graphics-lecture-notes
https://www.stkent.com/assets/pdfs/UCLA-Math-149-Mathematics-of-Computer-Graphics-lecture-notes.pdf
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
Built Distribution
Hashes for cubic_bezier_spline-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb68211d1630aec046072b037fe3a90295ed3f422e243e3f56e4496564b1a7db |
|
MD5 | f1fa329d689a46666a9fb42140d393c7 |
|
BLAKE2b-256 | 2606c59a01dbd2e9bd36eade2899aede432307cbcc27e3ae51533a7059bde195 |
Hashes for cubic_bezier_spline-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38cc1a4c3b107c4b1030f40ccc7e092c47e9fdef500d942a84df79a5496dbb85 |
|
MD5 | 3744d9854fbb88a475eecb9df5ac8f48 |
|
BLAKE2b-256 | 6bcdb1e081cc2e6924f919251740cc4c81b7694a1003e9798af7536b4d216930 |