Add range expansion method

This commit is contained in:
Danny Robson 2012-05-22 14:12:06 +10:00
parent 40c40507f9
commit be0426ff24
2 changed files with 11 additions and 0 deletions

View File

@ -77,6 +77,14 @@ range<T>::clamp (T val) const
{ return std::max (min, std::min (val, max)); }
template <typename T>
T
range<T>::expand (T val) {
min = std::min (min, val);
max = std::max (max, val);
}
template <typename T>
double
range<T>::normalise (T val) const {

View File

@ -46,6 +46,9 @@ namespace util {
/// Return the closest number that falls within the range.
T clamp (T val) const;
/// Expand the range to include this value if necessary
T expand (T val);
/// Normalise a number to [0, 1] within the range. Does not check bounds.
double normalise (T val) const;