diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/math.hpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/base/math.hpp b/base/math.hpp index 92ac40ab06..eb20ca4295 100644 --- a/base/math.hpp +++ b/base/math.hpp @@ -73,6 +73,13 @@ inline bool AlmostEqualRel(TFloat x, TFloat y, TFloat eps) return fabs(x - y) < eps * max(fabs(x), fabs(y)); } +// Returns true if x and y are equal up to the absolute or relative difference eps. +template <typename TFloat> +inline bool AlmostEqualAbsOrRel(TFloat x, TFloat y, TFloat eps) +{ + return AlmostEqualAbs(x, y, eps) || AlmostEqualRel(x, y, eps); +} + template <typename TFloat> inline TFloat DegToRad(TFloat deg) { return deg * TFloat(math::pi) / TFloat(180); |