ADL for AlmostEqual* and use math:: instead of base:: (#9634)

* ADL for AlmostEqual* and use math:: instead of base::

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk
2025-07-07 20:49:00 +02:00
committed by Konstantin Pastbin
parent 82133c5743
commit 30718e106e
175 changed files with 542 additions and 559 deletions

View File

@@ -39,10 +39,10 @@ double const kAnglesInBucket = 360.0 / kNumBuckets;
uint32_t Bearing(m2::PointD const & a, m2::PointD const & b)
{
auto const angle = location::AngleToBearing(base::RadToDeg(ang::AngleTo(a, b)));
auto const angle = location::AngleToBearing(math::RadToDeg(ang::AngleTo(a, b)));
CHECK_LESS_OR_EQUAL(angle, 360, ("Angle should be less than or equal to 360."));
CHECK_GREATER_OR_EQUAL(angle, 0, ("Angle should be greater than or equal to 0"));
return base::Clamp(angle / kAnglesInBucket, 0.0, 255.0);
return math::Clamp(angle / kAnglesInBucket, 0.0, 255.0);
}
} // namespace
@@ -61,7 +61,7 @@ void Router::Vertex::Score::AddBearingPenalty(int expected, int actual)
ASSERT_GREATER_OR_EQUAL(actual, 0, ());
int const diff = abs(expected - actual);
double angle = base::DegToRad(std::min(diff, kNumBuckets - diff) * kAnglesInBucket);
double angle = math::DegToRad(std::min(diff, kNumBuckets - diff) * kAnglesInBucket);
m_penalty += kBearingErrorCoeff * angle * kBearingDist;
}
@@ -568,8 +568,8 @@ double Router::GetCoverage(m2::PointD const & u, m2::PointD const & v, It b, It
double const sp = DotProduct(uv, s - u) / sqlen;
double const tp = DotProduct(uv, t - u) / sqlen;
double const start = base::Clamp(std::min(sp, tp), 0.0, 1.0);
double const finish = base::Clamp(std::max(sp, tp), 0.0, 1.0);
double const start = math::Clamp(std::min(sp, tp), 0.0, 1.0);
double const finish = math::Clamp(std::max(sp, tp), 0.0, 1.0);
covs.emplace_back(start, finish);
}
@@ -627,7 +627,7 @@ double Router::GetMatchingScore(m2::PointD const & u, m2::PointD const & v, It b
cov += mercator::DistanceOnEarth(s, t);
}
return len == 0 ? 0 : base::Clamp(cov / len, 0.0, 1.0);
return len == 0 ? 0 : math::Clamp(cov / len, 0.0, 1.0);
}
template <typename It, typename Fn>