range: add interpolation accessor

This commit is contained in:
Danny Robson 2015-03-11 16:27:37 +11:00
parent daa492ce07
commit 98312c2c37
2 changed files with 12 additions and 0 deletions

View File

@ -66,6 +66,15 @@ util::range<T>::contains (const range <T> &r) const
}
//-----------------------------------------------------------------------------
template <typename T>
T
util::range<T>::at (float t) const
{
return static_cast<T> (min + (max - min) * t);
}
//-----------------------------------------------------------------------------
template <typename T>
T

View File

@ -45,6 +45,9 @@ namespace util {
/// Check whether a range falls partially within (inclusive) this range
//bool includes (const range <T> &r) const;
/// interpolate between min-max using the unit position
T at (float) const;
/// Return the closest number that falls within the range.
T clamp (T val) const;