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

bounding_box.cpp « geometry - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ef0e7ee0d06a7921ddba6c4fa341b2e9974f31ca (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
#include "geometry/bounding_box.hpp"

#include <algorithm>

using namespace std;

namespace m2
{
BoundingBox::BoundingBox(vector<PointD> const & points)
{
  for (auto const & p : points)
    Add(p);
}

void BoundingBox::Add(double x, double y)
{
  m_min.x = min(m_min.x, x);
  m_min.y = min(m_min.y, y);
  m_max.x = max(m_max.x, x);
  m_max.y = max(m_max.y, y);
}

bool BoundingBox::HasPoint(double x, double y) const
{
  return x >= m_min.x && x <= m_max.x && y >= m_min.y && y <= m_max.y;
}

bool BoundingBox::HasPoint(double x, double y, double eps) const
{
  return x >= m_min.x - eps && x <= m_max.x + eps && y >= m_min.y - eps && y <= m_max.y + eps;
}
}  // namespace m2