From f8054c1b8882b488d8c8aa28c81e94fd786e5d73 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Thu, 30 May 2024 10:30:15 +0200 Subject: [PATCH] Get rid of boost::math::constants::* in favor of std::numbers --- CHANGELOG.md | 1 + include/util/coordinate_calculation.hpp | 2 +- include/util/trigonometry_table.hpp | 2 +- src/util/coordinate_calculation.cpp | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a22841b00..e2e535cdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - NodeJS: - CHANGED: Use node-api instead of NAN. [#6452](https://github.com/Project-OSRM/osrm-backend/pull/6452) - Misc: + - CHANGED: Get rid of boost::math::constants::* and M_PI in favor of std::numbers. [#6916](https://github.com/Project-OSRM/osrm-backend/pull/6916) - CHANGED: Use std::variant instead of mapbox::util::variant. [#6903](https://github.com/Project-OSRM/osrm-backend/pull/6903) - CHANGED: Bump rapidjson to version f9d53419e912910fd8fa57d5705fa41425428c35 [#6906](https://github.com/Project-OSRM/osrm-backend/pull/6906) - CHANGED: Bump mapbox/variant to version 1.2.0 [#6898](https://github.com/Project-OSRM/osrm-backend/pull/6898) diff --git a/include/util/coordinate_calculation.hpp b/include/util/coordinate_calculation.hpp index a67d5f1c8..48a5753e2 100644 --- a/include/util/coordinate_calculation.hpp +++ b/include/util/coordinate_calculation.hpp @@ -25,7 +25,7 @@ const constexpr long double EARTH_RADIUS = 6372797.560856; inline double degToRad(const double degree) { return degree * (std::numbers::pi / 180.0); } -inline double radToDeg(const double radian) { return radian * (180.0 * (1. / std::numbers::pi)); } +inline double radToDeg(const double radian) { return radian * (180.0 * std::numbers::inv_pi); } } // namespace detail const constexpr static double METERS_PER_DEGREE_LAT = 110567.0; diff --git a/include/util/trigonometry_table.hpp b/include/util/trigonometry_table.hpp index 6f5057be6..cc272903b 100644 --- a/include/util/trigonometry_table.hpp +++ b/include/util/trigonometry_table.hpp @@ -359,7 +359,7 @@ constexpr unsigned short atan_table[4096] = { #ifdef _MSC_VER // TODO: remove as soon as boost allows C++14 features with Visual Studio const constexpr double SCALING_FACTOR = 4. / M_PI * 0xFFFF; #else -const constexpr double SCALING_FACTOR = 4. / std::numbers::pi * 0xFFFF; +const constexpr double SCALING_FACTOR = 4. * std::numbers::inv_pi * 0xFFFF; #endif inline double atan2_lookup(double y, double x) diff --git a/src/util/coordinate_calculation.cpp b/src/util/coordinate_calculation.cpp index 953873cb3..2e43d2abd 100644 --- a/src/util/coordinate_calculation.cpp +++ b/src/util/coordinate_calculation.cpp @@ -162,7 +162,7 @@ double computeAngle(const Coordinate first, const Coordinate second, const Coord const double v2y = web_mercator::latToY(toFloating(third.lat)) - web_mercator::latToY(toFloating(second.lat)); - double angle = (atan2_lookup(v2y, v2x) - atan2_lookup(v1y, v1x)) * 180. / std::numbers::pi; + double angle = (atan2_lookup(v2y, v2x) - atan2_lookup(v1y, v1x)) * 180. * std::numbers::inv_pi; while (angle < 0.) {