calcBSplineDerivatives function
Implementation
List<Vector4> calcBSplineDerivatives(int p,List<double> U, List<Vector> P, u, int nd ) {
final du = nd < p ? nd : p;
final List<Vector4> ck = [];
int span = findSpan( p, u, U );
final nders = calcBasisFunctionDerivatives( span, u, p, du, U );
final List<Vector4> pw = [];
for ( int i = 0; i < P.length; ++ i ) {
final point = P[ i ].clone() as Vector4;
final w = point.w;
point.x *= w;
point.y *= w;
point.z *= w;
pw[i] = point;
}
for ( int k = 0; k <= du; ++ k ) {
final Vector4 point = pw[ span - p ].clone().scale( nders[ k ][ 0 ] );
for ( int j = 1; j <= p; ++ j ) {
point.add( pw[ span - p + j ].clone().scale( nders[ k ][ j ] ) );
}
ck[ k ] = point;
}
for ( int k = du + 1; k <= nd + 1; ++ k ) {
ck[ k ] = Vector4( 0, 0, 0 );
}
return ck;
}