| 162 | } |
| 163 | |
| 164 | void LNLib::Polynomials::BasisFunctions(int spanIndex, int degree, const std::vector<double>& knotVector, double paramT, double* basisFunctions) |
| 165 | { |
| 166 | VALIDATE_ARGUMENT(spanIndex >= 0, "spanIndex", "SpanIndex must be greater than or equal zero."); |
| 167 | VALIDATE_ARGUMENT(degree >= 0 && degree <= Constants::NURBSMaxDegree, "degree", "Degree must be greater than or equal zero and not exceed the maximun degree."); |
| 168 | VALIDATE_ARGUMENT(knotVector.size() > 0, "knotVector", "KnotVector size must be greater than zero."); |
| 169 | VALIDATE_ARGUMENT(ValidationUtils::IsValidKnotVector(knotVector), "knotVector", "KnotVector must be a nondecreasing sequence of real numbers."); |
| 170 | VALIDATE_ARGUMENT_RANGE(paramT, knotVector[0], knotVector[knotVector.size() - 1]); |
| 171 | |
| 172 | basisFunctions[0] = 1.0; |
| 173 | |
| 174 | double left[Constants::NURBSMaxDegree + 1]; |
| 175 | double right[Constants::NURBSMaxDegree + 1]; |
| 176 | |
| 177 | for (int j = 1; j <= degree; j++) |
| 178 | { |
| 179 | left[j] = paramT - knotVector[spanIndex + 1 - j]; |
| 180 | right[j] = knotVector[spanIndex + j] - paramT; |
| 181 | |
| 182 | double saved = 0.0; |
| 183 | |
| 184 | for (int r = 0; r < j; r++) |
| 185 | { |
| 186 | double temp = basisFunctions[r] / (right[r + 1] + left[j - r]); |
| 187 | basisFunctions[r] = saved + right[r + 1] * temp; |
| 188 | saved = left[j - r] * temp; |
| 189 | } |
| 190 | basisFunctions[j] = saved; |
| 191 | } |
| 192 | |
| 193 | } |
| 194 | |
| 195 | std::vector<std::vector<double>> LNLib::Polynomials::BasisFunctionsDerivatives(int spanIndex, int degree, |
| 196 | int derivative, const std::vector<double>& knotVector, double paramT) |
nothing calls this directly
no outgoing calls
no test coverage detected