Multi-dimensional parameterized spline curves (snappiness parameter gives uniform cubic B-splines, four-point subdivision splines, uniform quintic B-splines, and everything in-between)
Project description
jspline
Multi-dimensional parameterized spline curves (snappiness parameter gives uniform cubic B-splines, four-point subdivision splines, uniform quintic B-splines, and everything in-between)
Description
J-Splines are awesome: they're a class of spline curves that take a shape parameter, s. Setting s=1 yields uniform cubic B-spline curves, s=0 gives four-point subdivision curves, s=0.5 are uniform quintic B-splines - and more. "s" basically governs the "snappiness" of the curve.
jspline
, lets you choose any combination of J-Spline parameters for any number of input arrays, with a range of different starting and ending schemes (eg: open or closed loops). Use it for 2D drawing, 3D graphics, or any other kind of interpolation you might need.
- See also my CPAN perl module that does the same: https://metacpan.org/pod/Math::JSpline
Synopsis
from jspline import jspline
interpolated_results=jspline.make(subdivision_level, a, b, end_type, [xarray, ...])
where
subdivision_level determines how many points to interpolate (1 doubles $#x in the above example).
when a = b, this is the "s" paramater from the description (and the math paper below)
end_type is how you want to deal with the start and end points:
3=join them up (loop). 2=tangent clamp, 1=end clamp, 0=simple join (refer "see also" below)
[xarray] any number of array references come next, ex [xarray,yarray,zarray]
Example
from jspline import jspline
js=jspline.make(1,0,0, 0 ,[[1, 2, 4, 5]]) # returns 1,2,3,4,5
# or
x=[ 50 ,250, 250, 50 ]
y=[ 50, 50, 250, 250 ]
js=jspline.make(1,0,0, 0 ,[x,y]) # Draws one of the the below
See Also http://faculty.cs.tamu.edu/schaefer/research/js.pdf for details.
Installation
Normal installation
pip install jspline
Development installation
git clone https://github.com/gitcnd/jspline.git
cd jspline
pip install --editable .
Author note
Be sure to check out Airfoil Tools, a Fusion 360 plugin, for which this module was written.
Change log
[1.0.0] - 2020-05-02
- Cloned a quality github python module, and changed it to jspline :-)
- Followed instructions here: https://medium.com/@thucnc/how-to-publish-your-own-python-package-to-pypi-4318868210f9
[1.0.1] - 2020-05-02
- Added synopsis, examples, and references to the Doc
[1.0.2] - 2020-05-02
- Improved doc.
[1.0.3] - 2020-05-04
- Correct endpoint clamping to create closed output shapes when input shape was closed
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
Built Distribution
File details
Details for the file jspline-1.0.3.tar.gz
.
File metadata
- Download URL: jspline-1.0.3.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c464d35d707ec7998768f84b0260db6ab0b606f614dba37ff108d7a14aeafd2e |
|
MD5 | c03bb8c0382470356a7cf6ad87f0c4ad |
|
BLAKE2b-256 | e515078e998265bf0a53a108e5d7e7eebca5b762a132cbf26ba6b0a5de65b873 |
File details
Details for the file jspline-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: jspline-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.23.4 CPython/3.6.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fe76ffd03c23cf2283d4688988000918fc7aaf4381945319813c26dd3672739 |
|
MD5 | fdfb27bfa374f73d8c18e53833ef5b1d |
|
BLAKE2b-256 | e05254da8e4c0b5873ee3c7278b04b92749576dc2ec0a90732151242570b828c |