diff options
author | Maxim Pimenov <m@maps.me> | 2018-09-14 21:08:09 +0300 |
---|---|---|
committer | Vlad Mihaylenko <vxmihaylenko@gmail.com> | 2018-09-18 14:46:56 +0300 |
commit | 412387c84eefba2ec4c267ee2748bf78f03ce327 (patch) | |
tree | 8d79b6b480fb91a5458a21aec10ac689de54db9f /geometry | |
parent | bef147b46fb8fd5160fc8e3b13f3548906ae5ef7 (diff) |
[base] Replaced the namespace my with base.
Diffstat (limited to 'geometry')
-rw-r--r-- | geometry/angles.cpp | 2 | ||||
-rw-r--r-- | geometry/distance_on_sphere.cpp | 8 | ||||
-rw-r--r-- | geometry/geometry_tests/angle_test.cpp | 24 | ||||
-rw-r--r-- | geometry/geometry_tests/screen_test.cpp | 8 | ||||
-rw-r--r-- | geometry/geometry_tests/vector_test.cpp | 14 | ||||
-rw-r--r-- | geometry/latlon.cpp | 2 | ||||
-rw-r--r-- | geometry/latlon.hpp | 2 | ||||
-rw-r--r-- | geometry/mercator.cpp | 4 | ||||
-rw-r--r-- | geometry/mercator.hpp | 18 | ||||
-rw-r--r-- | geometry/point2d.hpp | 12 | ||||
-rw-r--r-- | geometry/polygon.hpp | 8 | ||||
-rw-r--r-- | geometry/rect2d.hpp | 4 | ||||
-rw-r--r-- | geometry/region2d.hpp | 6 | ||||
-rw-r--r-- | geometry/screenbase.cpp | 4 |
14 files changed, 59 insertions, 57 deletions
diff --git a/geometry/angles.cpp b/geometry/angles.cpp index c911abf0b3..02cc633c25 100644 --- a/geometry/angles.cpp +++ b/geometry/angles.cpp @@ -9,7 +9,7 @@ double AngleIn2PI(double ang) if (ang < 0.0) ang += period; - if (my::AlmostEqualULPs(period, ang)) + if (base::AlmostEqualULPs(period, ang)) return 0.0; return ang; diff --git a/geometry/distance_on_sphere.cpp b/geometry/distance_on_sphere.cpp index 5900059769..52040c692f 100644 --- a/geometry/distance_on_sphere.cpp +++ b/geometry/distance_on_sphere.cpp @@ -20,10 +20,10 @@ namespace ms { double DistanceOnSphere(double lat1Deg, double lon1Deg, double lat2Deg, double lon2Deg) { - double const lat1 = my::DegToRad(lat1Deg); - double const lat2 = my::DegToRad(lat2Deg); + double const lat1 = base::DegToRad(lat1Deg); + double const lat2 = base::DegToRad(lat2Deg); double const dlat = sin((lat2 - lat1) * 0.5); - double const dlon = sin((my::DegToRad(lon2Deg) - my::DegToRad(lon1Deg)) * 0.5); + double const dlon = sin((base::DegToRad(lon2Deg) - base::DegToRad(lon1Deg)) * 0.5); double const y = dlat * dlat + dlon * dlon * cos(lat1) * cos(lat2); return 2.0 * atan2(sqrt(y), sqrt(max(0.0, 1.0 - y))); } @@ -31,7 +31,7 @@ double DistanceOnSphere(double lat1Deg, double lon1Deg, double lat2Deg, double l double AreaOnSphere(ms::LatLon const & ll1, ms::LatLon const & ll2, ms::LatLon const & ll3) { // Todo: proper area on sphere (not needed for now) - double const avgLat = my::DegToRad((ll1.lat + ll2.lat + ll3.lat) / 3); + double const avgLat = base::DegToRad((ll1.lat + ll2.lat + ll3.lat) / 3); return cos(avgLat) * 0.5 * fabs((ll2.lon - ll1.lon) * (ll3.lat - ll1.lat) - (ll3.lon - ll1.lon) * (ll2.lat - ll1.lat)); diff --git a/geometry/geometry_tests/angle_test.cpp b/geometry/geometry_tests/angle_test.cpp index 22dc6a8e4f..deadadb6e2 100644 --- a/geometry/geometry_tests/angle_test.cpp +++ b/geometry/geometry_tests/angle_test.cpp @@ -75,18 +75,18 @@ UNIT_TEST(ShortestDistance) UNIT_TEST(TwoVectorsAngle) { double const eps = 1e-10; - TEST(my::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point<double>(0, 0) /* p */, - m2::Point<double>(0, 1) /* p1 */, - m2::Point<double>(1, 0)) /* p2 */, 3 * math::pi2, eps), ()); - TEST(my::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point<double>(1, 1) /* p */, - m2::Point<double>(2, 2) /* p1 */, - m2::Point<double>(1, 2)) /* p2 */, math::pi4, eps), ()); - TEST(my::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point<double>(0, 0) /* p */, - m2::Point<double>(1, 0) /* p1 */, - m2::Point<double>(0, -1)) /* p2 */, 3 * math::pi2, eps), ()); - TEST(my::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point<double>(0, 0) /* p */, - m2::Point<double>(1, 0) /* p1 */, - m2::Point<double>(-1, 0)) /* p2 */, math::pi, eps), ()); + TEST(base::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point<double>(0, 0) /* p */, + m2::Point<double>(0, 1) /* p1 */, + m2::Point<double>(1, 0)) /* p2 */, 3 * math::pi2, eps), ()); + TEST(base::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point<double>(1, 1) /* p */, + m2::Point<double>(2, 2) /* p1 */, + m2::Point<double>(1, 2)) /* p2 */, math::pi4, eps), ()); + TEST(base::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point<double>(0, 0) /* p */, + m2::Point<double>(1, 0) /* p1 */, + m2::Point<double>(0, -1)) /* p2 */, 3 * math::pi2, eps), ()); + TEST(base::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point<double>(0, 0) /* p */, + m2::Point<double>(1, 0) /* p1 */, + m2::Point<double>(-1, 0)) /* p2 */, math::pi, eps), ()); } UNIT_TEST(Azimuth) diff --git a/geometry/geometry_tests/screen_test.cpp b/geometry/geometry_tests/screen_test.cpp index 7e6fdfb721..dd8d4ff324 100644 --- a/geometry/geometry_tests/screen_test.cpp +++ b/geometry/geometry_tests/screen_test.cpp @@ -22,10 +22,10 @@ namespace b2 = screen.GtoP(b2); // check that we are in boundaries. - TEST(my::between_s(0, width, my::rounds(b1.x)), ()); - TEST(my::between_s(0, width, my::rounds(b2.x)), ()); - TEST(my::between_s(0, height, my::rounds(b1.y)), ()); - TEST(my::between_s(0, height, my::rounds(b2.y)), ()); + TEST(base::between_s(0, width, base::rounds(b1.x)), ()); + TEST(base::between_s(0, width, base::rounds(b2.x)), ()); + TEST(base::between_s(0, height, base::rounds(b1.y)), ()); + TEST(base::between_s(0, height, base::rounds(b2.y)), ()); } } diff --git a/geometry/geometry_tests/vector_test.cpp b/geometry/geometry_tests/vector_test.cpp index 0b8ea7ee7c..6cd493acaf 100644 --- a/geometry/geometry_tests/vector_test.cpp +++ b/geometry/geometry_tests/vector_test.cpp @@ -2,17 +2,19 @@ #include "geometry/avg_vector.hpp" - namespace { -template <class T, size_t N> bool EqualArrays(T (&a1)[N], T (&a2)[N]) +template <class T, size_t N> +bool EqualArrays(T (&a1)[N], T (&a2)[N]) +{ + for (size_t i = 0; i < N; ++i) { - for (size_t i = 0; i < N; ++i) - if (!my::AlmostEqualULPs(a1[i], a2[i])) - return false; - return true; + if (!base::AlmostEqualULPs(a1[i], a2[i])) + return false; } + return true; } +} // namespace UNIT_TEST(AvgVector_Smoke) { diff --git a/geometry/latlon.cpp b/geometry/latlon.cpp index fa0521a2c3..9df06e46a5 100644 --- a/geometry/latlon.cpp +++ b/geometry/latlon.cpp @@ -24,6 +24,6 @@ bool LatLon::operator==(ms::LatLon const & p) const { return lat == p.lat && lon bool LatLon::EqualDxDy(LatLon const & p, double eps) const { - return (my::AlmostEqualAbs(lat, p.lat, eps) && my::AlmostEqualAbs(lon, p.lon, eps)); + return (base::AlmostEqualAbs(lat, p.lat, eps) && base::AlmostEqualAbs(lon, p.lon, eps)); } } // namespace ms diff --git a/geometry/latlon.hpp b/geometry/latlon.hpp index ceff8cbe31..95476645b4 100644 --- a/geometry/latlon.hpp +++ b/geometry/latlon.hpp @@ -29,7 +29,7 @@ public: struct Hash { - size_t operator()(ms::LatLon const & p) const { return my::Hash(p.lat, p.lon); } + size_t operator()(ms::LatLon const & p) const { return base::Hash(p.lat, p.lon); } }; }; diff --git a/geometry/mercator.cpp b/geometry/mercator.cpp index 9f46e5585a..0977316e1c 100644 --- a/geometry/mercator.cpp +++ b/geometry/mercator.cpp @@ -18,7 +18,7 @@ m2::RectD MercatorBounds::MetresToXY(double lon, double lat, double lonMetresR, double const minLat = max(-90.0, lat - latDegreeOffset); double const maxLat = min(90.0, lat + latDegreeOffset); - double const cosL = max(cos(my::DegToRad(max(fabs(minLat), fabs(maxLat)))), 0.00001); + double const cosL = max(cos(base::DegToRad(max(fabs(minLat), fabs(maxLat)))), 0.00001); ASSERT_GREATER(cosL, 0.0, ()); double const lonDegreeOffset = lonMetresR * degreeInMetres / cosL; @@ -36,7 +36,7 @@ m2::PointD MercatorBounds::GetSmPoint(m2::PointD const & pt, double lonMetresR, double const latDegreeOffset = latMetresR * degreeInMetres; double const newLat = min(90.0, max(-90.0, lat + latDegreeOffset)); - double const cosL = max(cos(my::DegToRad(newLat)), 0.00001); + double const cosL = max(cos(base::DegToRad(newLat)), 0.00001); ASSERT_GREATER(cosL, 0.0, ()); double const lonDegreeOffset = lonMetresR * degreeInMetres / cosL; diff --git a/geometry/mercator.hpp b/geometry/mercator.hpp index eea5d1cfee..0da726428b 100644 --- a/geometry/mercator.hpp +++ b/geometry/mercator.hpp @@ -15,21 +15,21 @@ struct MercatorBounds static m2::RectD FullRect() { return m2::RectD(minX, minY, maxX, maxY); } - static bool ValidLon(double d) { return my::between_s(-180.0, 180.0, d); } - static bool ValidLat(double d) { return my::between_s(-90.0, 90.0, d); } + static bool ValidLon(double d) { return base::between_s(-180.0, 180.0, d); } + static bool ValidLat(double d) { return base::between_s(-90.0, 90.0, d); } - static bool ValidX(double d) { return my::between_s(minX, maxX, d); } - static bool ValidY(double d) { return my::between_s(minY, maxY, d); } + static bool ValidX(double d) { return base::between_s(minX, maxX, d); } + static bool ValidY(double d) { return base::between_s(minY, maxY, d); } - static double ClampX(double d) { return my::clamp(d, minX, maxX); } - static double ClampY(double d) { return my::clamp(d, minY, maxY); } + static double ClampX(double d) { return base::clamp(d, minX, maxX); } + static double ClampY(double d) { return base::clamp(d, minY, maxY); } - static double YToLat(double y) { return my::RadToDeg(2.0 * atan(tanh(0.5 * my::DegToRad(y)))); } + static double YToLat(double y) { return base::RadToDeg(2.0 * atan(tanh(0.5 * base::DegToRad(y)))); } static double LatToY(double lat) { - double const sinx = sin(my::DegToRad(my::clamp(lat, -86.0, 86.0))); - double const res = my::RadToDeg(0.5 * log((1.0 + sinx) / (1.0 - sinx))); + double const sinx = sin(base::DegToRad(base::clamp(lat, -86.0, 86.0))); + double const res = base::RadToDeg(0.5 * log((1.0 + sinx) / (1.0 - sinx))); return ClampY(res); } diff --git a/geometry/point2d.hpp b/geometry/point2d.hpp index b43ea8af7a..9d0fc638e1 100644 --- a/geometry/point2d.hpp +++ b/geometry/point2d.hpp @@ -159,7 +159,7 @@ public: struct Hash { - size_t operator()(m2::Point<T> const & p) const { return my::Hash(p.x, p.y); } + size_t operator()(m2::Point<T> const & p) const { return base::Hash(p.x, p.y); } }; }; @@ -235,13 +235,13 @@ std::string DebugPrint(m2::Point<T> const & p) template <typename T> bool AlmostEqualAbs(m2::Point<T> const & a, m2::Point<T> const & b, double const eps) { - return my::AlmostEqualAbs(a.x, b.x, eps) && my::AlmostEqualAbs(a.y, b.y, eps); + return base::AlmostEqualAbs(a.x, b.x, eps) && base::AlmostEqualAbs(a.y, b.y, eps); } template <typename T> bool AlmostEqualULPs(m2::Point<T> const & a, m2::Point<T> const & b, unsigned int maxULPs = 256) { - return my::AlmostEqualULPs(a.x, b.x, maxULPs) && my::AlmostEqualULPs(a.y, b.y, maxULPs); + return base::AlmostEqualULPs(a.x, b.x, maxULPs) && base::AlmostEqualULPs(a.y, b.y, maxULPs); } /// Calculate three points of a triangle (p1, p2 and p3) which give an arrow that @@ -269,7 +269,7 @@ template <typename T> Point<T> PointAtSegment(Point<T> const & p1, Point<T> const & p2, T shiftFromP1) { Point<T> p12 = p2 - p1; - shiftFromP1 = my::clamp(shiftFromP1, static_cast<T>(0.0), static_cast<T>(p12.Length())); + shiftFromP1 = base::clamp(shiftFromP1, static_cast<T>(0.0), static_cast<T>(p12.Length())); return p1 + p12.Normalize() * shiftFromP1; } @@ -298,7 +298,7 @@ bool operator<(Point<T> const & l, Point<T> const & r) } } // namespace m2 -namespace my +namespace base { template <typename T> bool AlmostEqualULPs(m2::Point<T> const & p1, m2::Point<T> const & p2, unsigned int maxULPs = 256) @@ -311,4 +311,4 @@ bool AlmostEqualAbs(m2::Point<T> const & p1, m2::Point<T> const & p2, double con { return m2::AlmostEqualAbs(p1, p2, eps); } -} // namespace my +} // namespace base diff --git a/geometry/polygon.hpp b/geometry/polygon.hpp index b4d91722c5..8b67bc070a 100644 --- a/geometry/polygon.hpp +++ b/geometry/polygon.hpp @@ -16,17 +16,17 @@ bool FindSingleStripForIndex(size_t i, size_t n, IsVisibleF isVisible) { // Searching for a strip only in a single direction, because the opposite direction // is traversed from the last vertex of the possible strip. - size_t a = my::PrevModN(i, n); - size_t b = my::NextModN(i, n); + size_t a = base::PrevModN(i, n); + size_t b = base::NextModN(i, n); for (size_t j = 2; j < n; ++j) { ASSERT_NOT_EQUAL ( a, b, () ); if (!isVisible(a, b)) return false; if (j & 1) - a = my::PrevModN(a, n); + a = base::PrevModN(a, n); else - b = my::NextModN(b, n); + b = base::NextModN(b, n); } ASSERT_EQUAL ( a, b, () ); diff --git a/geometry/rect2d.hpp b/geometry/rect2d.hpp index e0a26a37a3..1e87a7c6c4 100644 --- a/geometry/rect2d.hpp +++ b/geometry/rect2d.hpp @@ -195,8 +195,8 @@ public: void SetSizesToIncludePoint(Point<T> const & pt) { Point<T> const c = Center(); - T const dx = my::Abs(pt.x - c.x); - T const dy = my::Abs(pt.y - c.y); + T const dx = base::Abs(pt.x - c.x); + T const dy = base::Abs(pt.y - c.y); m_minX = c.x - dx; m_minY = c.y - dy; diff --git a/geometry/region2d.hpp b/geometry/region2d.hpp index cd3c856b06..fa60739806 100644 --- a/geometry/region2d.hpp +++ b/geometry/region2d.hpp @@ -25,8 +25,8 @@ struct DefEqualFloat { static_assert(std::is_floating_point<typename Point::value_type>::value, ""); - return my::AlmostEqualAbs(p1.x, p2.x, static_cast<typename Point::value_type>(kPrecision)) && - my::AlmostEqualAbs(p1.y, p2.y, static_cast<typename Point::value_type>(kPrecision)); + return base::AlmostEqualAbs(p1.x, p2.x, static_cast<typename Point::value_type>(kPrecision)) && + base::AlmostEqualAbs(p1.y, p2.y, static_cast<typename Point::value_type>(kPrecision)); } template <typename Coord> @@ -34,7 +34,7 @@ struct DefEqualFloat { static_assert(std::is_floating_point<Coord>::value, ""); - return my::AlmostEqualAbs(val, 0.0, kPrecision * kPrecision); + return base::AlmostEqualAbs(val, 0.0, kPrecision * kPrecision); } // Determines if value of a val lays between a p1 and a p2 values with some precision. bool IsAlmostBetween(double val, double p1, double p2) const diff --git a/geometry/screenbase.cpp b/geometry/screenbase.cpp index 62e2260521..1721b3148f 100644 --- a/geometry/screenbase.cpp +++ b/geometry/screenbase.cpp @@ -210,9 +210,9 @@ void ScreenBase::SetAngle(double angle) UpdateDependentParameters(); } -int ScreenBase::GetWidth() const { return my::rounds(m_PixelRect.SizeX()); } +int ScreenBase::GetWidth() const { return base::rounds(m_PixelRect.SizeX()); } -int ScreenBase::GetHeight() const { return my::rounds(m_PixelRect.SizeY()); } +int ScreenBase::GetHeight() const { return base::rounds(m_PixelRect.SizeY()); } ScreenBase::MatrixT const ScreenBase::CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2, |