calcBSplineDerivatives static method

List<Vector4> calcBSplineDerivatives(
  1. int p,
  2. List<double> U,
  3. List<Vector> P,
  4. dynamic u,
  5. int nd,
)

Implementation

static 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;
}