Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortatiana-kondakova <tatiana.kondakova@gmail.com>2018-02-27 12:34:45 +0300
committerIlya Zverev <ilya@zverev.info>2018-03-07 14:23:20 +0300
commit96558e0bdcc327bedfbbaf2f3784cd11cb79a8ee (patch)
treea82f5d55e1c73e248e274d212c4034c8604b6cbe /geometry
parenta3b711966bb0aa1fc3c9042e3d79802fae68a363 (diff)
Getting rid of my::sq, math::sqr
Diffstat (limited to 'geometry')
-rw-r--r--geometry/avg_vector.hpp24
-rw-r--r--geometry/covering_utils.hpp10
-rw-r--r--geometry/distance.hpp9
-rw-r--r--geometry/point2d.hpp5
-rw-r--r--geometry/triangle2d.cpp10
5 files changed, 29 insertions, 29 deletions
diff --git a/geometry/avg_vector.hpp b/geometry/avg_vector.hpp
index 84ad9dc494..2841f47509 100644
--- a/geometry/avg_vector.hpp
+++ b/geometry/avg_vector.hpp
@@ -3,18 +3,18 @@
#include "base/math.hpp"
#include "base/assert.hpp"
-#include "std/deque.hpp"
-#include "std/array.hpp"
-#include "std/cstring.hpp"
-#include "std/limits.hpp"
-#include "std/type_traits.hpp"
-
+#include <array>
+#include <cmath>
+#include <cstring>
+#include <deque>
+#include <limits>
+#include <type_traits>
namespace math
{
template <class T, size_t Dim> class AvgVector
{
- typedef deque<array<T, Dim> > ContT;
+ typedef std::deque<std::array<T, Dim>> ContT;
typedef typename ContT::value_type ValueT;
ContT m_vectors;
@@ -24,7 +24,7 @@ namespace math
{
T res = 0;
for (size_t i = 0; i < Dim; ++i)
- res += my::sq(a1[i] - a2[i]);
+ res += std::pow(a1[i] - a2[i], 2);
return sqrt(res);
}
@@ -37,7 +37,7 @@ namespace math
void CalcAverage(T * res) const
{
- T minD = numeric_limits<T>::max();
+ T minD = std::numeric_limits<T>::max();
size_t I = 0, J = 1;
size_t const count = m_vectors.size();
@@ -60,7 +60,7 @@ namespace math
public:
AvgVector(size_t count = 1) : m_count(count)
{
- static_assert(is_floating_point<T>::value, "");
+ static_assert(std::is_floating_point<T>::value, "");
}
void SetCount(size_t count) { m_count = count; }
@@ -73,7 +73,7 @@ namespace math
m_vectors.pop_front();
m_vectors.push_back(ValueT());
- memcpy(m_vectors.back().data(), arr, Dim*sizeof(T));
+ std::memcpy(m_vectors.back().data(), arr, Dim * sizeof(T));
if (m_vectors.size() > 1)
CalcAverage(arr);
@@ -91,7 +91,7 @@ namespace math
// smoothedHeadingRad and new heading value is bigger than smoothingThreshold.
template <class T, size_t Dim> class LowPassVector
{
- typedef array<T, Dim> ArrayT;
+ typedef std::array<T, Dim> ArrayT;
ArrayT m_val;
T m_factor;
diff --git a/geometry/covering_utils.hpp b/geometry/covering_utils.hpp
index a2dbfb8df2..9ca35d7969 100644
--- a/geometry/covering_utils.hpp
+++ b/geometry/covering_utils.hpp
@@ -9,7 +9,7 @@
#include "base/logging.hpp"
#include "base/math.hpp"
-#include "std/algorithm.hpp"
+#include <cmath>
namespace covering
{
@@ -29,7 +29,7 @@ inline CellObjectIntersection IntersectCellWithLine(CellIdT const cell,
m2::PointD const & a,
m2::PointD const & b)
{
- pair<uint32_t, uint32_t> const xy = cell.XY();
+ std::pair<uint32_t, uint32_t> const xy = cell.XY();
uint32_t const r = cell.Radius();
m2::PointD const cellCorners[4] =
{
@@ -68,7 +68,7 @@ CellObjectIntersection IntersectCellWithTriangle(
ASSERT_EQUAL(i3, i1, (cell, a, b, c));
if (i1 == OBJECT_INSIDE_CELL || i2 == OBJECT_INSIDE_CELL || i3 == OBJECT_INSIDE_CELL)
return OBJECT_INSIDE_CELL;
- pair<uint32_t, uint32_t> const xy = cell.XY();
+ std::pair<uint32_t, uint32_t> const xy = cell.XY();
if (m2::IsPointStrictlyInsideTriangle(m2::PointD(xy.first, xy.second), a, b, c))
return CELL_INSIDE_OBJECT;
return CELL_OBJECT_NO_INTERSECTION;
@@ -84,7 +84,7 @@ void CoverObject(IntersectF const & intersect, uint64_t cellPenaltyArea, CellIdC
return;
}
- uint64_t const cellArea = my::sq(uint64_t(1 << (cellDepth - 1 - cell.Level())));
+ uint64_t const cellArea = std::pow(uint64_t(1 << (cellDepth - 1 - cell.Level())), 2);
CellObjectIntersection const intersection = intersect(cell);
if (intersection == CELL_OBJECT_NO_INTERSECTION)
@@ -101,7 +101,7 @@ void CoverObject(IntersectF const & intersect, uint64_t cellPenaltyArea, CellIdC
uint64_t subdivArea = 0;
for (size_t i = 0; i < subdiv.size(); ++i)
- subdivArea += my::sq(uint64_t(1 << (cellDepth - 1 - subdiv[i].Level())));
+ subdivArea += std::pow(uint64_t(1 << (cellDepth - 1 - subdiv[i].Level())), 2);
ASSERT(!subdiv.empty(), (cellPenaltyArea, out, cell));
diff --git a/geometry/distance.hpp b/geometry/distance.hpp
index cfa8ed9d0e..35ef7cca09 100644
--- a/geometry/distance.hpp
+++ b/geometry/distance.hpp
@@ -3,8 +3,8 @@
#include "base/math.hpp"
-#include "std/limits.hpp"
-
+#include <cmath>
+#include <limits>
namespace m2
{
@@ -15,7 +15,8 @@ namespace impl
template <typename PointT> class CalculatedSection
{
private:
- static_assert(numeric_limits<typename PointT::value_type>::is_signed, "We do not support unsigned points!!!");
+ static_assert(std::numeric_limits<typename PointT::value_type>::is_signed,
+ "We do not support unsigned points!!!");
public:
void SetBounds(PointT const & p0, PointT const & p1)
@@ -82,7 +83,7 @@ public:
}
// Closest point is interior to segment.
- return my::sq(this->Distance(YmP0));
+ return std::pow(this->Distance(YmP0), 2);
}
};
diff --git a/geometry/point2d.hpp b/geometry/point2d.hpp
index 409e7936f9..180fc61aeb 100644
--- a/geometry/point2d.hpp
+++ b/geometry/point2d.hpp
@@ -34,10 +34,7 @@ namespace m2
}
// TODO (@y, @m): rename to SquaredLength.
- T SquareLength(Point<T> const & p) const
- {
- return math::sqr(x - p.x) + math::sqr(y - p.y);
- }
+ T SquareLength(Point<T> const & p) const { return pow(x - p.x, 2) + pow(y - p.y, 2); }
double Length(Point<T> const & p) const
{
diff --git a/geometry/triangle2d.cpp b/geometry/triangle2d.cpp
index 318394da50..47710439c2 100644
--- a/geometry/triangle2d.cpp
+++ b/geometry/triangle2d.cpp
@@ -6,10 +6,12 @@
#include "base/math.hpp"
-#include "std/chrono.hpp"
-#include "std/random.hpp"
+#include <chrono>
+#include <limits>
+#include <random>
using namespace m2::robust;
+using namespace std;
namespace m2
{
@@ -57,7 +59,7 @@ m2::PointD GetRandomPointInsideTriangle(m2::TriangleD const & t)
{
size_t kDistribMax = 1000;
- auto const seed = static_cast<uint32_t>(system_clock::now().time_since_epoch().count());
+ auto const seed = static_cast<uint32_t>(chrono::system_clock::now().time_since_epoch().count());
default_random_engine engine(seed);
uniform_int_distribution<size_t> distrib(0, kDistribMax);
double const r1 = sqrt(static_cast<double>(distrib(engine)) / kDistribMax);
@@ -70,7 +72,7 @@ m2::PointD GetRandomPointInsideTriangles(vector<m2::TriangleD> const & v)
if (v.empty())
return m2::PointD();
- auto const seed = static_cast<uint32_t>(system_clock::now().time_since_epoch().count());
+ auto const seed = static_cast<uint32_t>(chrono::system_clock::now().time_since_epoch().count());
default_random_engine engine(seed);
uniform_int_distribution<size_t> distrib(0, v.size() - 1);
return GetRandomPointInsideTriangle(v[distrib(engine)]);