1#ifndef SpeedFrequencyLookup_h__
2#define SpeedFrequencyLookup_h__
22 const auto upper = std::upper_bound(axis.begin(), axis.end(), value);
23 std::size_t hi =
static_cast<std::size_t
>(upper - axis.begin());
24 hi = std::clamp<std::size_t>(hi, 1, axis.size() - 1);
25 const std::size_t lo = hi - 1;
26 return {lo, (value - axis[lo]) / (axis[hi] - axis[lo])};
35T
BlendSpeedFrequency(
const T& q00,
const T& q01,
const T& q10,
const T& q11,
double speedFraction,
double frequencyFraction)
37 return q00 * ((1.0 - speedFraction) * (1.0 - frequencyFraction)) + q01 * ((1.0 - speedFraction) * frequencyFraction) +
38 q10 * (speedFraction * (1.0 - frequencyFraction)) + q11 * (speedFraction * frequencyFraction);
Simple waypoint object.
Definition CableAttach.h:16
AxisBracket FindAxisBracket(const std::vector< double > &axis, double value)
Definition SpeedFrequencyLookup.h:20
T BlendSpeedFrequency(const T &q00, const T &q01, const T &q10, const T &q11, double speedFraction, double frequencyFraction)
Definition SpeedFrequencyLookup.h:35
Two neighbouring nodes of an ascending axis and where a value lies between them.
Definition SpeedFrequencyLookup.h:13
std::size_t lo
index of the lower node; lo + 1 is the upper node
Definition SpeedFrequencyLookup.h:14
double fraction
0 at the lower node, 1 at the upper node; outside [0, 1] when the value is off the axis
Definition SpeedFrequencyLookup.h:15