diff --git a/Util/ComputeAngle.h b/Util/ComputeAngle.h index ade0374b6..f6a3bb51f 100644 --- a/Util/ComputeAngle.h +++ b/Util/ComputeAngle.h @@ -721,12 +721,11 @@ constexpr unsigned short atan_table[4096] = { }; // max value is pi/4 -constexpr double SCALING_FACTOR = 4 / M_PI * 0xFFFF; +constexpr double SCALING_FACTOR = 4. / M_PI * 0xFFFF; inline double atan2_lookup(double y, double x) { - if (((x > 0.) && (x < std::numeric_limits::epsilon())) || - ((x < 0.) && (x > -std::numeric_limits::epsilon()))) + if (std::abs(x) < std::numeric_limits::epsilon()) { if (y >= 0.) { @@ -803,7 +802,9 @@ inline static double GetAngleBetweenThreeFixedPointCoordinates(const CoordinateT double angle = (atan2_lookup(v2y, v2x) - atan2_lookup(v1y, v1x)) * 180 / M_PI; while (angle < 0) + { angle += 360; + } return angle; }