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

pointd_to_pointu_tests.cpp « coding_tests « coding - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b5c286d98f9ac29fb9f01c01af64a3010ad5efb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "testing/testing.hpp"

#include "coding/pointd_to_pointu.hpp"

#include "base/logging.hpp"

#include <cmath>

using namespace std;

namespace
{
uint32_t const kCoordBits = POINT_COORD_BITS;
}  // namespace

UNIT_TEST(PointDToPointU_Epsilons)
{
  m2::PointD const arrPt[] = {{-180, -180}, {-180, 180}, {180, 180}, {180, -180}};
  m2::PointD const arrD[] = {{1, 1}, {1, -1}, {-1, -1}, {-1, 1}};
  size_t const count = ARRAY_SIZE(arrPt);

  /*
  double eps = 1.0;
  for (; true; eps = eps / 10.0)
  {
    size_t i = 0;
    for (; i < count; ++i)
    {
      m2::PointU p = PointDToPointU(arrPt[i].x, arrPt[i].y, kCoordBits);
      m2::PointU p1 = PointDToPointU(arrPt[i].x + arrD[i].x * eps,
                                    arrPt[i].y + arrD[i].y * eps,
                                    kCoordBits);

      if (p != p1) break;
    }
    if (i == count) break;
  }

  LOG(LINFO, ("Epsilon = ", eps));
  */

  for (size_t i = 0; i < count; ++i)
  {
    m2::PointU const p1 = PointDToPointU(arrPt[i].x, arrPt[i].y, kCoordBits);
    m2::PointU const p2(p1.x + arrD[i].x, p1.y + arrD[i].y);
    m2::PointD const p3 = PointUToPointD(p2, kCoordBits);

    LOG(LINFO, ("Dx = ", p3.x - arrPt[i].x, "Dy = ", p3.y - arrPt[i].y));
  }
}