diff --git a/range.cpp b/range.cpp index 4155a323..da6a8962 100644 --- a/range.cpp +++ b/range.cpp @@ -66,6 +66,15 @@ util::range::contains (const range &r) const } +//----------------------------------------------------------------------------- +template +T +util::range::at (float t) const +{ + return static_cast (min + (max - min) * t); +} + + //----------------------------------------------------------------------------- template T diff --git a/range.hpp b/range.hpp index ee056e67..21ad4cad 100644 --- a/range.hpp +++ b/range.hpp @@ -45,6 +45,9 @@ namespace util { /// Check whether a range falls partially within (inclusive) this range //bool includes (const range &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;