Add range expansion method
This commit is contained in:
parent
40c40507f9
commit
be0426ff24
@ -77,6 +77,14 @@ range<T>::clamp (T val) const
|
|||||||
{ return std::max (min, std::min (val, max)); }
|
{ 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>
|
template <typename T>
|
||||||
double
|
double
|
||||||
range<T>::normalise (T val) const {
|
range<T>::normalise (T val) const {
|
||||||
|
@ -46,6 +46,9 @@ namespace util {
|
|||||||
/// Return the closest number that falls within the range.
|
/// Return the closest number that falls within the range.
|
||||||
T clamp (T val) const;
|
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.
|
/// Normalise a number to [0, 1] within the range. Does not check bounds.
|
||||||
double normalise (T val) const;
|
double normalise (T val) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user