forked from snavely/bundler_sfm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoundingBox.h
59 lines (46 loc) · 1.75 KB
/
BoundingBox.h
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
51
52
53
54
55
56
57
58
59
/*
* Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu)
* and the University of Washington
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
/* BoundingBox.h */
/* Routines for bounding boxes */
#ifndef __bounding_box_h__
#define __bounding_box_h__
#include <vector>
#include "vector.h"
class BoundingBox {
public:
BoundingBox() { }
BoundingBox(double xmin, double ymin, double xmax, double ymax) :
m_xmin(xmin), m_xmax(xmax), m_ymin(ymin), m_ymax(ymax) { }
BoundingBox(double x, double y) :
m_xmin(x), m_xmax(x), m_ymin(y), m_ymax(y) { }
/* Returns the area of the bounding box */
double Area();
BoundingBox Intersect(const BoundingBox &bbox) const;
/* Returns true iff the box contains the given point */
bool Contains(double x, double y);
bool Contains(const BoundingBox &bbox);
void Scale(double scale);
void Print();
double Width() { return m_xmax - m_xmin; }
double Height() { return m_ymax - m_ymin; }
double m_xmin, m_xmax;
double m_ymin, m_ymax;
};
/* Create a bounding box for a set of points */
BoundingBox CreateBoundingBox(const std::vector<v2_t> &points);
/* Return the union of two bounding boxes */
BoundingBox BoundingBoxUnion(const BoundingBox &bb1, const BoundingBox &bb2);
#endif /* __bounding_box_h__ */