calcBSplineDerivatives function
dynamic
calcBSplineDerivatives(
- dynamic p,
- dynamic U,
- dynamic P,
- dynamic u,
- 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] = Vector4(0, 0, 0);
}
return ck;
}