19template <
typename Tin,
typename Tout>
33template <
typename Tin,
typename Tout,
typename Tm
id, u
int8_t size>
45 constexpr Tout
interp(Tin input)
const
48 if (input <= table[0].in)
51 if (input >= table[size - 1].in)
52 return table[size - 1].out;
54 for (uint8_t i = 1; i < size; ++i)
56 if (input < table[i].in)
61 Tmid deltaIn = p1.
in - p0.
in;
62 Tmid deltaOut = p1.
out - p0.
out;
63 return p0.
out + ((Tmid)(input - p0.
in) * deltaOut) / deltaIn;
67 return table[size - 1].out;
85 return table[size - 1].in - table[0].in;
Class template for performing linear interpolation using a lookup table.
constexpr Tout interp(Tin input) const
Performs linear interpolation for the given input value, using the table.
constexpr LinearInterp(const TablePoint< Tin, Tout >(&table_)[size])
constexpr Tin range() const
Returns the input range of the interpolation table (last input - first input)
constexpr Tin start() const
Returns the starting input value of the interpolation table.
Structure representing a point in the interpolation table.