Allow range::normalise to return non-unit values
This commit is contained in:
parent
9cc47a05bd
commit
71fcd082aa
@ -107,7 +107,6 @@ range<T>::expand (T val) {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
double
|
double
|
||||||
range<T>::normalise (T val) const {
|
range<T>::normalise (T val) const {
|
||||||
CHECK_SOFT (val >= min && val <= max);
|
|
||||||
return ((double)val - min) /
|
return ((double)val - min) /
|
||||||
((double)max - min);
|
((double)max - min);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,9 @@ namespace util {
|
|||||||
/// Expand the range to include this value if necessary
|
/// Expand the range to include this value if necessary
|
||||||
void expand (T val);
|
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;
|
double normalise (T val) const;
|
||||||
|
|
||||||
range& operator*= (T);
|
range& operator*= (T);
|
||||||
|
Loading…
Reference in New Issue
Block a user