Skip to content

Instantly share code, notes, and snippets.

View subnivean's full-sized avatar

Mark Krautheim subnivean

  • Orwell, Vermont, USA
View GitHub Profile
@subnivean
subnivean / bsplinesurf.py
Created November 30, 2015 12:06
Python module that uses scipy.interpolate.RectBivariateSpline to implement 2D parametric surfaces in 3D space.
"""Implements a b-spline surface as a 3-tuple of
scipy.interpolate.RectBivariateSpline instances, one
each for x, y and z.
"""
import math
import numpy as np
from scipy.interpolate import RectBivariateSpline
class BSplineSurf(object):
@subnivean
subnivean / zigzag.py
Created December 11, 2012 03:21
python: How to Zig-Zag a Toolpath Array
"""Demonstration of how to 'zig-zag' an m x n x 3
python array (m = passes, n = points per pass).
Includes some array creation/mod tricks
>>> import numpy as np
>>> a = np.random.randn(4,3,3)
>>> a
array([[[-0.74865489, 0.533361 , 0.51997179],
[-0.72109915, -0.74988902, -2.61720425],
[-0.72792437, 2.43027423, 0.84132144]],
@subnivean
subnivean / parasurf.py
Last active April 5, 2018 23:42
python: Parametric 2D Surface Class
import numpy as np
from scipy.interpolate import RectBivariateSpline, bisplev
class ParaSurf(object):
def __init__(self, u, v, xyz, bbox=[-0.25, 1.25, -0.5, 1.5], ku=3, kv=3):
"""Parametric (u,v) surface approximation over a rectangular mesh.
Parameters
----------