Big templatization. Fix for interpolation.

This commit is contained in:
Ian Gulliver
2017-08-10 15:24:23 -07:00
parent c9024d3d63
commit a2c9eeb66b
11 changed files with 247 additions and 234 deletions

View File

@@ -4,3 +4,12 @@ template <typename T>
constexpr T AbsDiff(T a, T b) {
return (a > b) ? (a - b) : (b - a);
}
template <typename T>
constexpr T Interpolate(T val0, T val1, T mul, T div) {
if (val1 > val0) {
return val0 + ((mul * (val1 - val0)) / div);
} else {
return val1 - (((div - mul) * (val0 - val1)) / div);
}
}