range: add interpolation accessor
This commit is contained in:
parent
daa492ce07
commit
98312c2c37
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user