Spline modelling library for Python
Project description
SpliPy
This repository contains the SpliPy packages. SpliPy is a pure python library for the creation, evaluation and manipulation of B-spline and NURBS geometries. It supports n-variate splines of any dimension, but emphasis is made on the use of curves, surfaces and volumes. The library is designed primarily for analysis use, and therefore allows fine-grained control over many aspects which is not possible to achieve with conventional CAD tools.
Features
SpliPy allows for the generation of parametric curves, surfaces and volumes in the form of non-uniform rational B-splines (NURBS). It supports traditional curve- and surface-fitting methods such as (but not limited to)
Curve fitting
- Bezier curves
- Hermite Interpolation
- Cubic Curve Interpolation
- B-spline Interpolation
- Least Square Fit
Surface operations
- Sweep
- Revolve
- Loft
- Edge_Curves (interior from four edges)
- Extrude
- Structured Point Cloud Interpolation
- Least Square Fit
Revolve
Sweep
Loft
Volume operations
- Revolve
- Extrude
- Loft
- Structured Point Cloud Interpolation
- Least Square Fit
In addition to these basic building blocks, it also supports a number of primitive shapes such as (but not limited to)
Primitive shapes
- Cube
- Circle
- Disc
- Cylinder
- Torus
- Teapot
Examples
Derivatives of spline curves
from splipy import *
import numpy as np
n = 250 # number of evaluation points
c = curve_factory.circle() # create the NURBS circle (r=1)
t = np.linspace(c.start(0), c.end(0), n) # parametric evaluation points
x = c(t) # physical (x,y)-coordinates, size (n,2)
v = c.derivative(t, 1) # velocity at all points
a = c.derivative(t, 2) # acceleration at all points
Curve fitting
Lissajous curves are a family of parametric curves of the type
x = A sin(at+d)
y = B sin(bt)
More info: https://en.wikipedia.org/wiki/Lissajous_curve. Stripping the animation parts of the code, one can generate these curves in the following way
from splipy import *
import numpy as np
from fractions import gcd
def lissajous(a, b, d):
# request a,b integers, so we have closed, periodic curves
n = np.gcd(a,b)
N = (a/n) * (b/n) # number of periods before looping
# compute a set of interpolation points
numb_pts = max(3*N, 100) # using 3N interpolation points is decent enough
t = np.linspace(0,2*np.pi/n, numb_pts)
x = np.array([np.sin(a*t + d), np.sin(b*t)])
# do a cubic curve interpolation with periodic boundary conditions
my_curve = curve_factory.cubic_curve(x.T, curve_factory.Boundary.PERIODIC)
Animation of the lissajous curve with a=3, b=4 and d=pi/2
Surface Sweep
This produces the trefoil knot shown above
from splipy import *
from numpy import pi,cos,sin,transpose,array,sqrt
# define a parametric representation of the trefoil knot (to be sampled)
def trefoil(u):
x = [41*cos(u) - 18*sin( u) - 83*cos(2*u) - 83*sin(2*u) - 11*cos(3*u) + 27*sin(3*u),
36*cos(u) + 27*sin( u) - 113*cos(2*u) + 30*sin(2*u) + 11*cos(3*u) - 27*sin(3*u),
45*sin(u) - 30*cos(2*u) + 113*sin(2*u) - 11*cos(3*u) + 27*sin(3*u)]
return transpose(array(x))
knot_curve = curve_factory.fit(trefoil, 0, 2*pi) # adaptive curve fit of trefoil knot
square_curve = 15 * curve_factory.n_gon(4) # square cross-section
my_surface = surface_factory.sweep(crv, square) # sweep out the surface
Working with the controlpoints
>>> from splipy import *
>>> my_curve = curve_factory.circle(r=3)
>>> print(my_curve[0])
[3. 0. 1.]
>>> print(my_curve[1])
[2.12132034 2.12132034 0.70710678]
>>> for controlpoint in my_curve:
... print(controlpoint)
[3. 0. 1.]
[2.12132034 2.12132034 0.70710678]
[0. 3. 1.]
[-2.12132034 2.12132034 0.70710678]
[-3. 0. 1.]
[-2.12132034 -2.12132034 0.70710678]
[ 0. -3. 1.]
[ 2.12132034 -2.12132034 0.70710678]
Creating STL files
STL files are used extensively for 3D representation and is one of the only supported formats for 3D printing.
from splipy.io import STL
from splipy import surface_factory
# create a NURBS torus
my_torus = surface_factory.torus(minor_r=1, major_r=4)
# STL files are tessellated linear triangles. View with i.e. meshlab
with STL('torus.stl') as my_file:
my_file.write(my_torus, n=(50, 150)) # specify resolution of 50x150 evaluation pts
Torus tessellation as viewed in Meshlab
Citations
If you use Splipy in your work, please consider citing K. A. Johannessen and E. Fonn 2020 J. Phys.: Conf. Ser. 1669 012032.
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 Distributions
File details
Details for the file Splipy-1.8.2.tar.gz
.
File metadata
- Download URL: Splipy-1.8.2.tar.gz
- Upload date:
- Size: 264.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 201ee38bd5f0d0dc57c0d6efe350ccd493521dd3b730348295b61306e9ee4ac6 |
|
MD5 | 0d7b24937e4e38673a2a7a5762acb209 |
|
BLAKE2b-256 | abbeadc10954fe010ff66dd805bb11ea13485717ad6a6a618b486636f9442e40 |
File details
Details for the file Splipy-1.8.2-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 195.6 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2e46d845ce1f479d915346bce0a6aaaafa42287d10a6531d4612e2c4f75653b |
|
MD5 | 1280aa7156d4777bf8f8315205dd9bbc |
|
BLAKE2b-256 | 6ed6f0effd9ea6e34ea1b9d5c16bb2e75fd39a8d88ad316c38dd0869a3e7d12a |
File details
Details for the file Splipy-1.8.2-cp312-cp312-win32.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp312-cp312-win32.whl
- Upload date:
- Size: 183.3 kB
- Tags: CPython 3.12, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fc45af9e9ea7a058752c665f186b892c33acef3d6f36a85d59872f8b109ef1b |
|
MD5 | 9b6bc1cbca42e111e044e132c8b814bc |
|
BLAKE2b-256 | b17a1ed4724cc29f1691d0425478f3b102af26830f2590a94e2a5b9c8154866b |
File details
Details for the file Splipy-1.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 611.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da6fbfdad47a0db77f5acbfca519db14948ec53d0270dad3adafc720ddb8d8cf |
|
MD5 | 3b4955e0407b7b1e94a7041d6f10505d |
|
BLAKE2b-256 | d8aba452b0bb8b5b0c690162a37fa63bbf800cd2a1be44d4a78f9d5c8d44c3f4 |
File details
Details for the file Splipy-1.8.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 592.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a444865ac3cc7e470595db736630ea3cff4837e71755a715153e43ec483a49cc |
|
MD5 | a1b6d1efdb40607e6da1aa83bbe79dbf |
|
BLAKE2b-256 | a115ca6a5ebf3671a80dfedbb536345e706dbdd93f3b9f46e3806fdcebd32190 |
File details
Details for the file Splipy-1.8.2-cp312-cp312-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 205.5 kB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34b93829f3ae41179c9c108bad718a4f3e3b3f0c73251c1c5d1a6ef37336ffba |
|
MD5 | ae8ea09b3ba8288466b393641f0f0c4c |
|
BLAKE2b-256 | 9b1f1a381ffaef89efd9b02aca9f8334bc6a9007448b91bef3a13ecc6c740216 |
File details
Details for the file Splipy-1.8.2-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 195.1 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b897b354ebc5426f06691a93be2de002515feb7369b32d3a23d2134704be59d |
|
MD5 | 72a9c5ec5a2ef80ab9412c2f99e87d4c |
|
BLAKE2b-256 | 265830b0b1539bc36c25bdb493b2394ef560921a73f9ee45207b776a10e69c8f |
File details
Details for the file Splipy-1.8.2-cp311-cp311-win32.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp311-cp311-win32.whl
- Upload date:
- Size: 182.8 kB
- Tags: CPython 3.11, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a432f8b4f800fb140f578e42356bb8a033f1827f90bbafda22bdd9577e104f9d |
|
MD5 | dcd6cf12ca1f5c6b1f63fd2f6f80e2c6 |
|
BLAKE2b-256 | 0f544f9878a76bd4ba3d156157152795517ed390791dec96ef57ee8ccfec5154 |
File details
Details for the file Splipy-1.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 621.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a6d0bafdfe085cc7f2aed15f5afde6241d327fff25eb4e26adb13f8cc3b2082 |
|
MD5 | 442f0e5020b6207002559ac4f8b903f3 |
|
BLAKE2b-256 | 4932a4c54fb41243203012447da63a3f8081579fe66f20434ec023e1662206b4 |
File details
Details for the file Splipy-1.8.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 600.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5d092d23a8e1f9b3a8e4cece1c6fc87ffaf8eb09389a1f61d41702bdd9d196c |
|
MD5 | 6a84dfbb9c435d746a3c7370f5cade58 |
|
BLAKE2b-256 | 2f1752826c75fa2e5ca04f9a0e4ee8fc397c0c11fcbca7aa0811e55eadf02efe |
File details
Details for the file Splipy-1.8.2-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 204.2 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 109dc9fce6591ee8bf31906786480ee3b88a20c8abf758261dce55d11226fc8d |
|
MD5 | 6b48633d9692f3829b32e2ccbd33d972 |
|
BLAKE2b-256 | 831603462cdefad8af905e5dd08f97d29365f308c114a81e97575de8ab3769d0 |
File details
Details for the file Splipy-1.8.2-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 195.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48d485b9f4c9a8b229aea345e9dde5a768cdca4844ddde8808405eda8629febd |
|
MD5 | fa48b4d50bc92f42cd4c0058b7e18b2a |
|
BLAKE2b-256 | 4bda82ef723ca7faa9b3dcfa33d44e95fb480ddd92d1664f199063134b338adf |
File details
Details for the file Splipy-1.8.2-cp310-cp310-win32.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp310-cp310-win32.whl
- Upload date:
- Size: 183.0 kB
- Tags: CPython 3.10, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb6ed49d7070da2679ec78c03823c30635f067015b8cbba19cc3890dbf65804c |
|
MD5 | b4b97772b1d45800108bce8bbe877b46 |
|
BLAKE2b-256 | e168154c3fd4ca72da67d1a37523af4963189acdcf12ed61a7d749fd7dcfd48b |
File details
Details for the file Splipy-1.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 584.4 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a751eac96bedc1432426f5d5fa3b3647c968c16cbd62234661c6f3d533b09973 |
|
MD5 | d13024a3b3d1efda9aca49b23635ba33 |
|
BLAKE2b-256 | 6def83f9a74e3eb0f2b198c2e2ede32ca436461f6e4fbdf1e2d6af6cd119d6db |
File details
Details for the file Splipy-1.8.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 564.8 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64ad578561b268b37f3f0327f835971c9017943b20a426dab16f32f7208a3770 |
|
MD5 | 993323d7636de9b8afe8b0de105e73ee |
|
BLAKE2b-256 | 21975de346e4c64cca2fea26300e3ab8b04d1c6dd6b93756276262d00797d3d7 |
File details
Details for the file Splipy-1.8.2-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 204.4 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c495479ed37b9d85f3743e26125c4a5e91518363ff001c40fe0fc52771ee9b7d |
|
MD5 | f892d976801c0129ea7bfa6212a0aac5 |
|
BLAKE2b-256 | 804a428726937737ee816b208e1221869dfca7db92792791b44da13014825c9b |
File details
Details for the file Splipy-1.8.2-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 195.5 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e23eed336889bc6688b97c8d231108e52889f59ce0084bba37379ce665b29421 |
|
MD5 | d59fade3c18aff5b0bdf48a2ec94957f |
|
BLAKE2b-256 | e4f891089e56890b4141ad80b48144bb944f619fe4edc27169f5abb5e5bd3769 |
File details
Details for the file Splipy-1.8.2-cp39-cp39-win32.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp39-cp39-win32.whl
- Upload date:
- Size: 183.7 kB
- Tags: CPython 3.9, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bbfa0b31a8f2e227670fb099003d3c15fae144efaa3089c2d737268d07a1c8f |
|
MD5 | 221fd9d28837b3d01dbaeb3ad66afcc9 |
|
BLAKE2b-256 | e8631c04f41163efef69a905c663ad08c988ab9357d463bd05d7cbc67ebb49cc |
File details
Details for the file Splipy-1.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 586.3 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9177b0fd5316bd1f1358e4d3065ce63b9e790dd917b768ad0e16ec5d3497382 |
|
MD5 | 2849be3c2d5e8cb300278256879248c6 |
|
BLAKE2b-256 | 194a894bf0a619d6ba30f9af09b84e45658c73e3cf0dcf334e1d8648b0cb3d3a |
File details
Details for the file Splipy-1.8.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 567.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b7cd9550a9bafe7943b1d322f955c07fe857bbe627e7dc50576607704f67b56 |
|
MD5 | 7d9fcf5bde7c986e20fb9b19eaa78cfb |
|
BLAKE2b-256 | 0132b9c71491e2a0275b1414048fcea257ec14782ae5e71db6e8160381aea8a0 |
File details
Details for the file Splipy-1.8.2-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: Splipy-1.8.2-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 205.0 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60ec81b85a6f16fc229f0a5be5b09f313dc9cc60168ced23448141f945af900e |
|
MD5 | bdc39510fadd817b84afbf98f0046ecb |
|
BLAKE2b-256 | 01959004a7737e8ff7e438dfd3a39d81bfd28df356657ec390f208bcd8b21660 |