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

Method AverageKnotVector

src/LNLib/Algorithm/Interpolation.cpp:154–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154std::vector<double> LNLib::Interpolation::AverageKnotVector(int degree, const std::vector<double>& params)
155{
156 int n = static_cast<int>(params.size()) - 1;
157 int m = n + degree + 1;
158 std::vector<double> knotVector(m + 1, 0.0);
159
160 for (int i = m - degree; i <= m; ++i) {
161 knotVector[i] = 1.0;
162 }
163
164 if (n <= degree) {
165 return knotVector;
166 }
167
168 double windowSum = 0.0;
169 for (int i = 1; i <= degree; ++i) {
170 windowSum += params[i];
171 }
172 knotVector[degree + 1] = windowSum / static_cast<double>(degree);
173
174 for (int j = 2; j <= n - degree; ++j) {
175 windowSum -= params[j - 1];
176 windowSum += params[j + degree - 1];
177 knotVector[degree + j] = windowSum / static_cast<double>(degree);
178 }
179
180 return knotVector;
181}
182
183std::vector<double> LNLib::Interpolation::ComputeKnotVector(int degree, int controlPointsCount, const std::vector<double>& params)
184{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected