MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / interpolate

Method interpolate

source/core/StarParametricFunction.hpp:258–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256
257template <typename IndexType, typename ValueType>
258ValueType ParametricFunction<IndexType, ValueType>::interpolate(IndexType index) const {
259 if (Base::empty())
260 return ValueType();
261
262 if (m_interpolationMode == InterpolationMode::HalfStep) {
263 return parametricInterpolate2(Base::indexes(), Base::values(), index, StepWeightOperator<IndexType>(), m_boundMode);
264
265 } else if (m_interpolationMode == InterpolationMode::Linear) {
266 return parametricInterpolate2(
267 Base::indexes(), Base::values(), index, LinearWeightOperator<IndexType>(), m_boundMode);
268
269 } else if (m_interpolationMode == InterpolationMode::Cubic) {
270 // ParametricFunction uses CubicWeights with linear extrapolation (not
271 // configurable atm)
272 return parametricInterpolate4(
273 Base::indexes(), Base::values(), index, Cubic4WeightOperator<IndexType>(true), m_boundMode);
274
275 } else {
276 throw MathException("Unsupported interpolation type in ParametricFunction::interpolate");
277 }
278}
279
280template <typename IndexType, typename ValueType>
281ValueType ParametricFunction<IndexType, ValueType>::operator()(IndexType index) const {

Callers 4

evaluateMethod · 0.45
searchMethod · 0.45
TESTFunction · 0.45
TESTFunction · 0.45

Calls 2

parametricInterpolate2Function · 0.85
parametricInterpolate4Function · 0.85

Tested by 2

TESTFunction · 0.36
TESTFunction · 0.36