// https://github.com/thibauts/b-spline module.exports = function interpolate(t, degree, points, knots, weights, result, scaled) { var i,j,s,l; // function-scoped iteration variables var n = points.length; // points count var d = points[0].length; // point dimensionality if(degree < 1) throw new Error('degree must be at least 1 (linear)'); if(degree > (n-1)) throw new Error('degree must be less than or equal to point count - 1'); if(!weights) { // build weight vector of length [n] weights = []; for(i=0; i high) throw new Error('out of bounds'); // find s (the spline segment) for the [t] value provided for(s=domain[0]; s= knots[s] && t <= knots[s+1]) { break; } } // convert points to homogeneous coordinates var v = []; for(i=0; is-degree-1+l; i--) { alpha = (t - knots[i]) / (knots[i+degree+1-l] - knots[i]); // interpolate each component for(j=0; j