Replace M_PI with std::numbers:pi (#2713)

This commit is contained in:
Bart Louwers
2024-08-13 01:26:49 +02:00
committed by GitHub
parent b42fa344b3
commit d19ab42d0a
22 changed files with 126 additions and 64 deletions

View File

@@ -9,11 +9,15 @@
#include <mbgl/util/projection.hpp>
#include <mbgl/util/tile_coordinate.hpp>
#include <numbers>
using namespace std::numbers;
namespace mbgl {
namespace {
LatLng latLngFromMercator(Point<double> mercatorCoordinate, LatLng::WrapMode wrapMode = LatLng::WrapMode::Unwrapped) {
return {util::rad2deg(2 * std::atan(std::exp(M_PI - mercatorCoordinate.y * util::M2PI)) - M_PI_2),
return {util::rad2deg(2 * std::atan(std::exp(pi - mercatorCoordinate.y * 2 * pi)) - (pi / 2)),
mercatorCoordinate.x * 360.0 - 180.0,
wrapMode};
}
@@ -384,11 +388,11 @@ void TransformState::setNorthOrientation(const NorthOrientation val) {
double TransformState::getNorthOrientationAngle() const {
double angleOrientation = 0;
if (orientation == NorthOrientation::Rightwards) {
angleOrientation += M_PI / 2.0f;
angleOrientation += pi / 2;
} else if (orientation == NorthOrientation::Downwards) {
angleOrientation += M_PI;
angleOrientation += pi;
} else if (orientation == NorthOrientation::Leftwards) {
angleOrientation -= M_PI / 2.0f;
angleOrientation -= pi / 2;
}
return angleOrientation;
}
@@ -442,7 +446,7 @@ void TransformState::setEdgeInsets(const EdgeInsets& val) {
// MARK: - Position
LatLng TransformState::getLatLng(LatLng::WrapMode wrapMode) const {
return {util::rad2deg(2 * std::atan(std::exp(y / Cc)) - 0.5 * M_PI), -x / Bc, wrapMode};
return {util::rad2deg(2 * std::atan(std::exp(y / Cc)) - 0.5 * pi), -x / Bc, wrapMode};
}
double TransformState::pixel_x() const {