15template <
typename T>
inline bool withinRange(T n, T lo, T hi) {
19 return n > lo && n < hi;
33inline T map(T n, T start1, T stop1, T start2, T stop2,
34 bool withinBounds =
true) {
35 const T newval = (n - start1) / (stop1 - start1) * (stop2 - start2) + start2;
40 return std::clamp(newval, start2, stop2);
42 return std::clamp(newval, stop2, start2);