Get rid of boost::math::constants::* and M_PI in favor of std::numbers (#6916)
This commit is contained in:
committed by
GitHub
parent
a9b1bd88d3
commit
fb9d1cefcc
@@ -6,6 +6,7 @@
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
|
||||
#include <boost/optional/optional_io.hpp>
|
||||
#include <numbers>
|
||||
|
||||
namespace osrm::extractor::intersection
|
||||
{
|
||||
@@ -79,11 +80,11 @@ namespace
|
||||
{
|
||||
double findAngleBisector(double alpha, double beta)
|
||||
{
|
||||
alpha *= M_PI / 180.;
|
||||
beta *= M_PI / 180.;
|
||||
alpha *= std::numbers::pi / 180.;
|
||||
beta *= std::numbers::pi / 180.;
|
||||
const auto average =
|
||||
180. * std::atan2(std::sin(alpha) + std::sin(beta), std::cos(alpha) + std::cos(beta)) /
|
||||
M_PI;
|
||||
180. * std::atan2(std::sin(alpha) + std::sin(beta), std::cos(alpha) + std::cos(beta)) *
|
||||
std::numbers::inv_pi;
|
||||
return std::fmod(average + 360., 360.);
|
||||
}
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ bool MergableRoadDetector::IsCircularShape(const NodeID intersection_node,
|
||||
// ---- ----
|
||||
// \ /
|
||||
// -------
|
||||
const auto constexpr CIRCULAR_POLYGON_ISOPERIMETRIC_LOWER_BOUND = 0.85 / (4 * M_PI);
|
||||
const auto constexpr CIRCULAR_POLYGON_ISOPERIMETRIC_LOWER_BOUND = 0.85 / (4 * std::numbers::pi);
|
||||
if (connect_again && coordinates_to_the_left.front() == coordinates_to_the_left.back())
|
||||
{ // if the left and right roads connect again and are closed polygons ...
|
||||
const auto area = util::coordinate_calculation::computeArea(coordinates_to_the_left);
|
||||
@@ -359,7 +359,7 @@ bool MergableRoadDetector::IsCircularShape(const NodeID intersection_node,
|
||||
const auto area_to_squared_perimeter_ratio = std::abs(area) / (perimeter * perimeter);
|
||||
|
||||
// then don't merge roads if A/L² is greater than the lower bound
|
||||
BOOST_ASSERT(area_to_squared_perimeter_ratio <= 1. / (4 * M_PI));
|
||||
BOOST_ASSERT(area_to_squared_perimeter_ratio <= 1. / (4 * std::numbers::pi));
|
||||
if (area_to_squared_perimeter_ratio >= CIRCULAR_POLYGON_ISOPERIMETRIC_LOWER_BOUND)
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user