calcBasisFunctions function

dynamic calcBasisFunctions(
  1. dynamic span,
  2. dynamic u,
  3. dynamic p,
  4. dynamic U,
)

Implementation

calcBasisFunctions( span, u, p, U ) {

	var N = [];
	var left = [];
	var right = [];
	N[ 0 ] = 1.0;

	for ( var j = 1; j <= p; ++ j ) {

		left[ j ] = u - U[ span + 1 - j ];
		right[ j ] = U[ span + j ] - u;

		var saved = 0.0;

		for ( var r = 0; r < j; ++ r ) {

			var rv = right[ r + 1 ];
			var lv = left[ j - r ];
			var temp = N[ r ] / ( rv + lv );
			N[ r ] = saved + rv * temp;
			saved = lv * temp;

		}

		N[ j ] = saved;

	}

	return N;

}