calcBSplineDerivatives function

dynamic calcBSplineDerivatives(
  1. dynamic p,
  2. dynamic U,
  3. dynamic P,
  4. dynamic u,
  5. dynamic nd,
)

Implementation

calcBSplineDerivatives( p, U, P, u, nd ) {

	var du = nd < p ? nd : p;
	var CK = [];
	var span = findSpan( p, u, U );
	var nders = calcBasisFunctionDerivatives( span, u, p, du, U );
	var Pw = [];

	for ( var i = 0; i < P.length; ++ i ) {

		var point = P[ i ].clone();
		var w = point.w;

		point.x *= w;
		point.y *= w;
		point.z *= w;

		Pw[ i ] = point;

	}

	for ( var k = 0; k <= du; ++ k ) {

		var point = Pw[ span - p ].clone().multiplyScalar( nders[ k ][ 0 ] );

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

			point.add( Pw[ span - p + j ].clone().multiplyScalar( nders[ k ][ j ] ) );

		}

		CK[ k ] = point;

	}

	for ( var k = du + 1; k <= nd + 1; ++ k ) {

		CK[ k ] = new Vector4( 0, 0, 0 );

	}

	return CK;

}