6 #ifndef UTILS_INTERVAL_H 7 #define UTILS_INTERVAL_H 27 Interval(
const float a,
const float b,
const float epsilon)
28 : min_(glm::min(a, b))
29 , max_(glm::max(a, b))
43 const float max_common_epsilon =
std_ext::Max(epsilon_, o.epsilon_);
58 return glm::clamp(val, min_, max_);
Holds float interval and performs operations on it.
Definition: Interval.h:17
Interval(const float a, const float b, const float epsilon)
Creates an interval <a,b> with custom numerical precision (epsilon).
Definition: Interval.h:27
bool operator!=(const Interval &o) const
Compares if two intervals are different.
Definition: Interval.h:50
float GetMax() const
Returns value of a maximal endpoint of the interval.
Definition: Interval.h:92
bool AreEqual(const T val1, const T val2, const T epsilon=std::numeric_limits< T >::epsilon())
Returns true if two values are equal within defined epsilon threshold.
Definition: ExtGLM.h:255
Interval()
Creates a default interval <0,1>.
Definition: Interval.h:21
Interval(const float left, const float right)
Creates an interval <a,b>.
Definition: Interval.h:35
T Max(const std::vector< T > &vector)
Finds a maximum value in a vector.
Definition: ExtSTD.h:509
bool IsEmpty() const
Check whether the range of interval is zero.
Definition: Interval.h:80
bool operator==(const Interval &o) const
Compares if two intervals are identical.
Definition: Interval.h:41
General namespace for utilities.
Definition: BulletConversions.h:9
float ValueToNorm(const float val) const
Returns normalized interval parameter from the real value.
Definition: Interval.h:68
float GetMin() const
Returns value of a minimal endpoint of the interval.
Definition: Interval.h:86
float GetClamped(const float val) const
Clamps a value to the interval endpoints.
Definition: Interval.h:56
float GetRange() const
Returns a distance between interval endpoints.
Definition: Interval.h:74
float NormToValue(const float t) const
Returns real value from the normalized interval parameter.
Definition: Interval.h:62
float GetEpsilon() const
Returns numerical precision of the interval.
Definition: Interval.h:98