17 template <
class T,
class V>
28 template <
class T,
class V>
33 template <
class T,
class V>
45 template <
class T,
int size,
class V = T>
65 constexpr V
Map(
const T inVal)
const {
68 }
else if (inVal <=
m_mapArray.front().inVal) {
72 auto beforePoint{std::prev(afterPoint)};
73 const auto lerpPct = (inVal - beforePoint->inVal) / (afterPoint->inVal - beforePoint->inVal);
74 return beforePoint->outVal + lerpPct * (afterPoint->outVal - beforePoint->outVal);
Performs linear interpolation of a value based on a set of input->output mapping points.
Definition interpolation.h:46
constexpr V Map(const T inVal) const
Generate interpolated output based on input.
Definition interpolation.h:65
InterpolationMap()=delete
constexpr V operator()(const T inVal) const
Generate interpolated output based on input.
Definition interpolation.h:83
std::array< InterpMapPoint< T, V >, size > m_mapArray
Definition interpolation.h:86
constexpr InterpolationMap(std::array< InterpMapPoint< T, V >, size > initArray)
Constructs new interpolation map.
Definition interpolation.h:54
Definition swap_controllers_command.h:12
constexpr bool operator<(const InterpMapPoint< T, V > &a, const T &b)
Definition interpolation.h:29
Point that helps generate an interpolation map.
Definition interpolation.h:18
constexpr InterpMapPoint(T in, V out)
Definition interpolation.h:22
constexpr bool operator<(const InterpMapPoint< T, V > &other)
Definition interpolation.h:24
T inVal
Definition interpolation.h:19
V outVal
Definition interpolation.h:20
constexpr bool operator==(const InterpMapPoint< T, V > &other)
Definition interpolation.h:25