[Sketcher] [planegcs] Calculate value at general b-spline
This commit is contained in:
committed by
Chris Hennes
parent
d68ac06b01
commit
076232a67a
@@ -746,6 +746,20 @@ double BSpline::getLinCombFactor(double x, size_t k, size_t i, size_t p)
|
||||
return d[p];
|
||||
}
|
||||
|
||||
double BSpline::splineValue(double x, size_t k, size_t p, VEC_D& d, const VEC_D& flatknots)
|
||||
{
|
||||
for (size_t r = 1; r < p + 1; ++r) {
|
||||
for (size_t j = p; j > r - 1; --j) {
|
||||
double alpha =
|
||||
(x - flatknots[j + k - p]) /
|
||||
(flatknots[j + 1 + k - r] - flatknots[j + k - p]);
|
||||
d[j] = (1.0 - alpha) * d[j-1] + alpha * d[j];
|
||||
}
|
||||
}
|
||||
|
||||
return d[p];
|
||||
}
|
||||
|
||||
void BSpline::setupFlattenedKnots()
|
||||
{
|
||||
flattenedknots.clear();
|
||||
|
||||
@@ -308,6 +308,13 @@ namespace GCS
|
||||
inline double getLinCombFactor(double x, size_t k, size_t i)
|
||||
{ return getLinCombFactor(x, k, i, degree); }
|
||||
void setupFlattenedKnots();
|
||||
/// finds spline(x) for the given parameter and knot/pole vector
|
||||
/// x is the point at which combination is needed
|
||||
/// k is the range in `flattenedknots` that contains x
|
||||
/// p is the degree
|
||||
/// d is the vector of (relevant) poles (this will be changed)
|
||||
/// flatknots is the vector of knots
|
||||
static double splineValue(double x, size_t k, size_t p, VEC_D& d, const VEC_D& flatknots);
|
||||
};
|
||||
|
||||
} //namespace GCS
|
||||
|
||||
Reference in New Issue
Block a user