def resample_spline(points, smooth=.001, count=None, degree=3):
    """
    Resample a path in space, smoothing along a b-spline.

    Parameters
    -----------
    points: (n, dimension) float, points in space
    smooth: float, smoothing amount
    count:  number of samples in output
    degree: int, degree of spline polynomial

    Returns
    ---------
    resampled: (count, dimension) float, points in space
    """
    from scipy.interpolate import splprep, splev
    if count is None:
        count = len(points)
    points = np.asanyarray(points)
    closed = np.linalg.norm(points[0] - points[-1]) < tol.merge

    tpl = splprep(points.T, s=smooth, k=degree)[0]
    i = np.linspace(0.0, 1.0, count)
    resampled = np.column_stack(splev(i, tpl))

    if closed:
        shared = resampled[[0, -1]].mean(axis=0)
        resampled[0] = shared
        resampled[-1] = shared

    return resampled
Resample a path in space, smoothing along a b-spline.

    Parameters
    -----------
    points: (n, dimension) float, points in space
    smooth: float, smoothing amount
    count:  number of samples in output
    degree: int, degree of spline polynomial

    Returns
    ---------
    resampled: (count, dimension) float, points in space