Skip to main content

Spline modelling library for Python

Project description

Splipy Logo 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 Revolve

Sweep Sweep

Loft 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

Missing circle animation

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)

Missing Lissajous curve animation

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 Torus

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Splipy-1.7.4.tar.gz (230.0 kB view details)

Uploaded Source

Built Distributions

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

Splipy-1.7.4-cp311-cp311-win_amd64.whl (182.8 kB view details)

Uploaded CPython 3.11Windows x86-64

Splipy-1.7.4-cp311-cp311-win32.whl (172.4 kB view details)

Uploaded CPython 3.11Windows x86

Splipy-1.7.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (550.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

Splipy-1.7.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (533.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

Splipy-1.7.4-cp311-cp311-macosx_10_9_x86_64.whl (191.4 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

Splipy-1.7.4-cp310-cp310-win_amd64.whl (183.5 kB view details)

Uploaded CPython 3.10Windows x86-64

Splipy-1.7.4-cp310-cp310-win32.whl (173.2 kB view details)

Uploaded CPython 3.10Windows x86

Splipy-1.7.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (529.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

Splipy-1.7.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (515.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

Splipy-1.7.4-cp310-cp310-macosx_10_9_x86_64.whl (192.3 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

Splipy-1.7.4-cp39-cp39-win_amd64.whl (184.6 kB view details)

Uploaded CPython 3.9Windows x86-64

Splipy-1.7.4-cp39-cp39-win32.whl (174.1 kB view details)

Uploaded CPython 3.9Windows x86

Splipy-1.7.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (532.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

Splipy-1.7.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (521.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

Splipy-1.7.4-cp39-cp39-macosx_10_9_x86_64.whl (192.7 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

Splipy-1.7.4-cp38-cp38-win_amd64.whl (184.3 kB view details)

Uploaded CPython 3.8Windows x86-64

Splipy-1.7.4-cp38-cp38-win32.whl (174.0 kB view details)

Uploaded CPython 3.8Windows x86

Splipy-1.7.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (533.8 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

Splipy-1.7.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (522.4 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

Splipy-1.7.4-cp38-cp38-macosx_10_9_x86_64.whl (190.7 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

Details for the file Splipy-1.7.4.tar.gz.

File metadata

  • Download URL: Splipy-1.7.4.tar.gz
  • Upload date:
  • Size: 230.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for Splipy-1.7.4.tar.gz
Algorithm Hash digest
SHA256 d1d2b4dceee68cdb4107fa2b3b268ab2711b90149eabf82a4eb510d9c562af12
MD5 9fae30da889e507c1396c09ee249f94d
BLAKE2b-256 05febfc7035dabcc7fd124d36aaa0100aab5e86f0d89073f7e9898e8b535df39

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: Splipy-1.7.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 182.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for Splipy-1.7.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1caac2f820635e11732210a1530a9e71c259801cd93a2638fafb477e9b5373dc
MD5 e977f1dc04969c0e26537b49a393cc90
BLAKE2b-256 f8f32df4e351f3878b9a0a661542895dc1f496818f05768d346c41ff3788cef1

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp311-cp311-win32.whl.

File metadata

  • Download URL: Splipy-1.7.4-cp311-cp311-win32.whl
  • Upload date:
  • Size: 172.4 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for Splipy-1.7.4-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 56c512d2fedeaab3b0fb38cb5591fa0a755cda19ec7647b75360d885347046e9
MD5 5e3a33f286bcab5bc1c8f33e8234bb7b
BLAKE2b-256 c572dded84ff2a7c5b8f64e1f44520847134d984c62e0e16e8753795ee159cf7

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 01179fe93bfb468ad7a9acaaeb7b1651bc0b70eb68f99a9b866f2993b631df1b
MD5 8945052c63ea1ce9dbb7e83875be28c6
BLAKE2b-256 07640795115464be47da978fe5fefc0dba7df40bb7b4a4506258e97e34ca85a4

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 836611630fa73df02fb87b3a19e599e4962743b392c71f28da4c28718ea186c6
MD5 8ffd29aa58efdc97ba28e0aaba7bf7a0
BLAKE2b-256 2000c96eaf096df3c3e4413cb08e7fb4e16da2acde58d5ddcf385314fc14fe3e

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bfeaf992bddd82bc0371ef606bdc35b4914f6f7e3033f6f5dbe6cd33b35044af
MD5 32ec77a0e135db159e9bcb98c3a0fc96
BLAKE2b-256 974a868c78803ccca8f0c4367d751f401f65299b618854ce9f533801f369ed8c

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: Splipy-1.7.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 183.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for Splipy-1.7.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a808038a3f1a8cc8a8a033f668056e16de87329224024be45cca448ad71c6394
MD5 d3ebe98d202c3b7e5411bf3910c3c791
BLAKE2b-256 52f329652f95ab1d6e180661a653d0eeb53ac5d5f7fc61c16cd2d081bcae539d

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp310-cp310-win32.whl.

File metadata

  • Download URL: Splipy-1.7.4-cp310-cp310-win32.whl
  • Upload date:
  • Size: 173.2 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for Splipy-1.7.4-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 67f744de1bf7a5a3ff09668cf8447e631872044288e64e9f60a268ae2abc93e3
MD5 973707c8ecd8061dcf04caf79a44cf59
BLAKE2b-256 9bce32e9c6974860e3b59bf085a94eb6e4864eb287586e4084a84f0bda421856

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7cbfe269cb4a04fe321ebebf1164ddd62ed8c772e1d52039c8457a9f8ee51802
MD5 229085011da86433d0a877616f41f542
BLAKE2b-256 2d6f670b3f2313a72bc5c33c937ce398c99b62c772c6d17f8883d4ccae156385

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 bcb3f7bcd0463627170abe5c350cb429809c3271583916159e039781ed88868b
MD5 42f2aba5df75bff6f6ad14b1352d957b
BLAKE2b-256 0cd53085e02626ae3ec082b0526001721ac4945c975a1a9ce56871ea5ee68d8a

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f2adab3d7ce84240a432419000e5997de2026aa659d65e42231ebcf20712e28f
MD5 8ad8e37403bf281c5bd53c884e873770
BLAKE2b-256 a7c2fff1313d4bf49fe136f1caccafc256c0524dca854aa97b9c3892059b89e1

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: Splipy-1.7.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 184.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for Splipy-1.7.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e662de99c4a8fdcd67af0db2e43238e9e2556418bcc6e2accfe9a2b29d99ca08
MD5 169d9dbb6a5a3fe4e34aa6da8e29b565
BLAKE2b-256 a1c5dd379bd6a8d089ef1a879af3b288d5f016297b42e06b740865251625e9e5

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp39-cp39-win32.whl.

File metadata

  • Download URL: Splipy-1.7.4-cp39-cp39-win32.whl
  • Upload date:
  • Size: 174.1 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for Splipy-1.7.4-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 51129b108ad44e4678165b13bc007241e771ff7da4b96ea9758b47b271ff8611
MD5 63bb7392d685bf21a1278a4820c5f1fd
BLAKE2b-256 acf78399e148b978d52f4ed8925ddf97bac29709f7195ac3f1e3a5e29205cfd4

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 22bc23c99b372b8a4b45d8831f49c458b46da3aeb108fe409020bddaa50ad215
MD5 505050ebf6903d8cc7bb03509c84a3ad
BLAKE2b-256 18d1b3d642a98fc45aa9391c5f1bac466fbbe4bc1b90760fddfee76294f332d8

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7e4ecb01e5a3f7e767b0219bce37fba383cfe30f30188167876f836a566e214a
MD5 e4589b6637086f9881e15b23b14ae60d
BLAKE2b-256 a5ea01cf92330462cba03d6e3f5dc2034e42d3152cb93b0cb57572d70745e162

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f1188d791dc28b2173573e39b400db0e3d75663c8663abb4ec9edd79eefb8ee9
MD5 42d2dde4a6f90b69ab44a39dc66ea35e
BLAKE2b-256 ba37771fbc8358dc7c59fee62fca7889d8a443df3d374e992523f1349003accb

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: Splipy-1.7.4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 184.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for Splipy-1.7.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 f371cc120a4adbde1e7da7b27d466f189c960062bdb4896b4011b952847962aa
MD5 e5d6e00267f838d68a39ea498455fb02
BLAKE2b-256 fc5dca64fab22c6444bc738d26a643e3fe171b00ffd8fb6746451f42261bd535

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp38-cp38-win32.whl.

File metadata

  • Download URL: Splipy-1.7.4-cp38-cp38-win32.whl
  • Upload date:
  • Size: 174.0 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for Splipy-1.7.4-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 802c8163b26e130a4f89cda7a0b28301a93279826e8ea2852b7e999fbf56f86f
MD5 283eae123633fedd3a641aa0bbbedc9d
BLAKE2b-256 a9c1839303463572490c3e4659f2a112095dce5c3ea5d8c52bee5e26c06cefc8

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b03c95e0bab0e334b69a06ee3560127c61a67fc143e78516a2c3daf5f768366f
MD5 a9c104916b9845fc6d68ad61aa815c94
BLAKE2b-256 47ee68efac297f83fad2f22ad11665e5b13e3649e3652f7ddad4fe5e1dcf7fab

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 74538305d467c20434203e51a5b277776da844b526ec4424880fb593b3ae17a5
MD5 34517ebb10667cde4a9dbd63087dc384
BLAKE2b-256 ab7152148fa7984db35f125975190f9fe2dc07d1125e64cec9d464d13fb59539

See more details on using hashes here.

File details

Details for the file Splipy-1.7.4-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for Splipy-1.7.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7d51e488c19865dccb98c9d511827fb3c073b52366de58eedc97549f00635e5e
MD5 5a816b4d9dd563398bd5deadf00fcb86
BLAKE2b-256 abe14d3cf13bf8914ddd509bfd2247abbfed43d32c20518ee0dcea079074bb47

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