MCPcopy Create free account
hub / github.com/BIMCoderLiang/LNLib / BasisFunctionsFirstOrderDerivative

Method BasisFunctionsFirstOrderDerivative

src/LNLib/Algorithm/Polynomials.cpp:300–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300void LNLib::Polynomials::BasisFunctionsFirstOrderDerivative(int spanIndex, int degree, const std::vector<double>& knotVector, double paramT, double derivatives[2][Constants::NURBSMaxDegree + 1])
301{
302 VALIDATE_ARGUMENT(spanIndex >= 0, "spanIndex", "SpanIndex must be greater than or equal zero.");
303 VALIDATE_ARGUMENT(degree >= 0 && degree <= Constants::NURBSMaxDegree, "degree", "Degree must be greater than or equal zero and not exceed the maximun degree.");
304 VALIDATE_ARGUMENT(1 <= degree, "derivative", "Derivative must not be greater than degree.");
305 VALIDATE_ARGUMENT(knotVector.size() > 0, "knotVector", "KnotVector size must be greater than zero.");
306 VALIDATE_ARGUMENT(ValidationUtils::IsValidKnotVector(knotVector), "knotVector", "KnotVector must be a nondecreasing sequence of real numbers.");
307 VALIDATE_ARGUMENT_RANGE(paramT, knotVector[0], knotVector[knotVector.size() - 1]);
308
309 double ndu[Constants::NURBSMaxDegree + 1][Constants::NURBSMaxDegree + 1];
310
311 ndu[0][0] = 1.0;
312
313 double left[Constants::NURBSMaxDegree + 1];
314 double right[Constants::NURBSMaxDegree + 1];
315
316 double saved = 0.0;
317 double temp = 0.0;
318
319 for (int j = 1; j <= degree; j++)
320 {
321 left[j] = paramT - knotVector[spanIndex + 1 - j];
322 right[j] = knotVector[spanIndex + j] - paramT;
323
324 saved = 0.0;
325 for (int r = 0; r < j; r++)
326 {
327 ndu[j][r] = right[r + 1] + left[j - r];
328 temp = ndu[r][j - 1] / ndu[j][r];
329
330 ndu[r][j] = saved + right[r + 1] * temp;
331 saved = left[j - r] * temp;
332 }
333 ndu[j][j] = saved;
334 }
335
336 for (int j = 0; j <= degree; j++)
337 {
338 derivatives[0][j] = ndu[j][degree];
339 }
340
341 double a[2][Constants::NURBSMaxDegree + 1];
342 for (int r = 0; r <= degree; r++)
343 {
344 int s1 = 0;
345 int s2 = 1;
346 a[0][0] = 1.0;
347
348 const int k = 1;
349 {
350 double d = 0.0;
351 int rk = r - k;
352 int pk = degree - k;
353
354 if (r >= k)
355 {
356 a[s2][0] = a[s1][0] / ndu[pk + 1][rk];
357 d = a[s2][0] * ndu[rk][pk];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected