Get rid of boost::math::constants::* in favor of std::numbers
This commit is contained in:
parent
f8054c1b88
commit
23455166cf
@ -6,6 +6,7 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <numbers>
|
||||||
|
|
||||||
namespace mapbox
|
namespace mapbox
|
||||||
{
|
{
|
||||||
@ -37,7 +38,7 @@ class CheapRuler
|
|||||||
static constexpr double FE = 1.0 / 298.257223563; // flattening
|
static constexpr double FE = 1.0 / 298.257223563; // flattening
|
||||||
|
|
||||||
static constexpr double E2 = FE * (2 - FE);
|
static constexpr double E2 = FE * (2 - FE);
|
||||||
static constexpr double RAD = M_PI / 180.0;
|
static constexpr double RAD = std::numbers::pi / 180.0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CheapRuler(double latitude)
|
explicit CheapRuler(double latitude)
|
||||||
|
@ -356,11 +356,7 @@ constexpr unsigned short atan_table[4096] = {
|
|||||||
0xffe0, 0xffea, 0xfff4, 0xffff};
|
0xffe0, 0xffea, 0xfff4, 0xffff};
|
||||||
|
|
||||||
// max value is pi/4
|
// max value is pi/4
|
||||||
#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::inv_pi * 0xFFFF;
|
const constexpr double SCALING_FACTOR = 4. * std::numbers::inv_pi * 0xFFFF;
|
||||||
#endif
|
|
||||||
|
|
||||||
inline double atan2_lookup(double y, double x)
|
inline double atan2_lookup(double y, double x)
|
||||||
{
|
{
|
||||||
|
@ -103,8 +103,8 @@ inline void pixelToDegree(const double shift, double &x, double &y)
|
|||||||
const double b = shift / 2.0;
|
const double b = shift / 2.0;
|
||||||
x = (x - b) / shift * 360.0;
|
x = (x - b) / shift * 360.0;
|
||||||
// FIXME needs to be simplified
|
// FIXME needs to be simplified
|
||||||
const double g = (y - b) / -(shift / (2 * M_PI)) / detail::DEGREE_TO_RAD;
|
const double g = (y - b) / -(shift * 0.5 * std::numbers::inv_pi) / detail::DEGREE_TO_RAD;
|
||||||
static_assert(detail::DEGREE_TO_RAD / (2 * M_PI) - 1 / 360. < 0.0001, "");
|
static_assert(detail::DEGREE_TO_RAD * 0.5 * std::numbers::inv_pi - 1 / 360. < 0.0001, "");
|
||||||
y = static_cast<double>(yToLat(g));
|
y = static_cast<double>(yToLat(g));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "util/coordinate_calculation.hpp"
|
#include "util/coordinate_calculation.hpp"
|
||||||
|
|
||||||
#include <boost/optional/optional_io.hpp>
|
#include <boost/optional/optional_io.hpp>
|
||||||
|
#include <numbers>
|
||||||
|
|
||||||
namespace osrm::extractor::intersection
|
namespace osrm::extractor::intersection
|
||||||
{
|
{
|
||||||
@ -79,11 +80,11 @@ namespace
|
|||||||
{
|
{
|
||||||
double findAngleBisector(double alpha, double beta)
|
double findAngleBisector(double alpha, double beta)
|
||||||
{
|
{
|
||||||
alpha *= M_PI / 180.;
|
alpha *= std::numbers::pi / 180.;
|
||||||
beta *= M_PI / 180.;
|
beta *= std::numbers::pi / 180.;
|
||||||
const auto average =
|
const auto average =
|
||||||
180. * std::atan2(std::sin(alpha) + std::sin(beta), std::cos(alpha) + std::cos(beta)) /
|
180. * std::atan2(std::sin(alpha) + std::sin(beta), std::cos(alpha) + std::cos(beta)) *
|
||||||
M_PI;
|
std::numbers::inv_pi;
|
||||||
return std::fmod(average + 360., 360.);
|
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 (connect_again && coordinates_to_the_left.front() == coordinates_to_the_left.back())
|
||||||
{ // if the left and right roads connect again and are closed polygons ...
|
{ // if the left and right roads connect again and are closed polygons ...
|
||||||
const auto area = util::coordinate_calculation::computeArea(coordinates_to_the_left);
|
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);
|
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
|
// 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)
|
if (area_to_squared_perimeter_ratio >= CIRCULAR_POLYGON_ISOPERIMETRIC_LOWER_BOUND)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
|
|||||||
return RoundaboutType::RoundaboutIntersection;
|
return RoundaboutType::RoundaboutIntersection;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double radius = roundabout_length / (2 * M_PI);
|
const double radius = roundabout_length * 0.5 * std::numbers::inv_pi;
|
||||||
|
|
||||||
// Looks like a rotary: large roundabout with dedicated name
|
// Looks like a rotary: large roundabout with dedicated name
|
||||||
// do we have a dedicated name for the rotary, if not its a roundabout
|
// do we have a dedicated name for the rotary, if not its a roundabout
|
||||||
|
Loading…
Reference in New Issue
Block a user