wrmath/include/wrnav/util/math.h

40 lines
479 B
C
Raw Normal View History

2019-08-03 02:03:44 +00:00
#ifndef __WRNAV_UTIL_MATH_H
#define __WRNAV_UTIL_MATH_H
namespace wr {
namespace util {
const double Epsilon_double = 0.0001;
const float Epsilon_float = 0.0001;
void
DefaultEpsilon(double &epsilon)
{
epsilon = Epsilon_double;
}
void
DefaultEpsilon(float &epsilon)
{
epsilon = Epsilon_float;
}
template <typename T>
T
WithinTolerance(T a, T b, T epsilon)
{
return std::abs(a - b) < epsilon;
}
} // namespace util
} // namespace wr
#endif // __WRNAV_UTIL_MATH_H