52 template<
typename Value,
typename InterpolationFunction = LinearInterpolation<Value>>
129 if(currTime >=
values_.back().first) {
return values_.back().second; }
130 else if(currTime <=
values_.front().first) {
return values_.front().second; }
140 auto updateIndex = [
this, currTime]()
152 auto nextIt = std::lower_bound(std::begin(
values_), std::end(
values_), currTime,
153 [](
const TimedValue & lhs,
const double & rhs) {
return lhs.first < rhs; });
void error_and_throw(Args &&... args)
Definition: logging.h:47
Interpolate values in a timed sequence.
Definition: SequenceInterpolator.h:54
bool hasValues() const noexcept
Definition: SequenceInterpolator.h:106
size_t prevIndex_
Cache the previous index to optimize lookup when used sequentially.
Definition: SequenceInterpolator.h:169
SequenceInterpolator() noexcept
Creates an empty interpolator.
Definition: SequenceInterpolator.h:63
std::vector< TimedValue > TimedValueVector
Definition: SequenceInterpolator.h:56
size_t nextIndex_
Cache the next index.
Definition: SequenceInterpolator.h:170
Value compute(double currTime)
Definition: SequenceInterpolator.h:124
double intervalDuration_
Cache the duration of the current interval.
Definition: SequenceInterpolator.h:171
InterpolationFunction interpolator_
Functor for computing the interpolated values.
Definition: SequenceInterpolator.h:167
SequenceInterpolator(const TimedValueVector &values)
Creates an interpolator with values.
Definition: SequenceInterpolator.h:72
void values(const TimedValueVector &values)
Set interpolator values.
Definition: SequenceInterpolator.h:82
typename std::pair< double, Value > TimedValue
Definition: SequenceInterpolator.h:55
void clear()
Definition: SequenceInterpolator.h:109
const TimedValueVector & values() const noexcept
Definition: SequenceInterpolator.h:100
TimedValueVector values_
Interpolation values.
Definition: SequenceInterpolator.h:168