Allow range::normalise to return non-unit values

This commit is contained in:
Danny Robson 2014-02-18 16:00:48 +11:00
parent 9cc47a05bd
commit 71fcd082aa
2 changed files with 3 additions and 2 deletions

View File

@ -107,7 +107,6 @@ range<T>::expand (T val) {
template <typename T>
double
range<T>::normalise (T val) const {
CHECK_SOFT (val >= min && val <= max);
return ((double)val - min) /
((double)max - min);
}

View File

@ -49,7 +49,9 @@ namespace util {
/// Expand the range to include this value if necessary
void expand (T val);
/// Normalise a number to [0, 1] within the range. Does not check bounds.
/// Normalise a number to [0, 1] within the range. Does not check
/// bounds, it is the caller's responsibility to clamp the result if
/// needed.
double normalise (T val) const;
range& operator*= (T);