BoundingBox.h
1 #ifndef H_DYNACOE_BOUNDING_BOX
2 #define H_DYNACOE_BOUNDING_BOX
3 
4 
5 namespace Dynacoe {
6 class BoundingBox {
7  public:
8  BoundingBox() :
9  x(0.f),
10  y(0.f),
11  width(0.f),
12  height(0.f){}
13  BoundingBox(float x_, float y_, float w_, float h_) :
14  x(x_),
15  y(y_),
16  width(w_),
17  height(h_)
18  {}
19 
20 
21  bool ContainsPoint(const Dynacoe::Vector & a) const {
22  return (a.x >= x &&
23  a.x <= x+width &&
24  a.y >= y &&
25  a.y <= y+width);
26  }
27 
28  bool ContainsBox(const BoundingBox & a) const {
29  return (a.x >= x &&
30  a.x+a.width <= x+width &&
31  a.y >= y &&
32  a.y+a.height <= y+width);
33  }
34 
35 
36  bool Overlaps(const BoundingBox & other) const {
37  return
38  x < other.x+other.width && x+width > other.x &&
39  y+other.height > other.y && y < other.y+other.height;
40 
41  }
42 
43 
44  float x;
45  float y;
46  float width;
47  float height;
48 };
49 
50 }
51 
52 
53 #endif
3D and 2D positional vector.
Definition: Vector.h:55
Definition: AssetID.h:37