calcBSplinePoint function

dynamic calcBSplinePoint(
  1. dynamic p,
  2. dynamic U,
  3. dynamic P,
  4. dynamic u,
)

Implementation

calcBSplinePoint(p, U, P, u) {
  var span = findSpan(p, u, U);
  var n = calcBasisFunctions(span, u, p, U);
  var c = Vector4(0, 0, 0, 0);

  for (var j = 0; j <= p; ++j) {
    var point = P[span - p + j];
    var nj = n[j];
    var wNj = point.w * nj;
    c.x += point.x * wNj;
    c.y += point.y * wNj;
    c.z += point.z * wNj;
    c.w += point.w * nj;
  }

  return c;
}