GlobeEngine
AxisAlignedBoundingBox.h
Go to the documentation of this file.
1 
9 #ifndef GlobeEngine_AxisAlignedBoundingBox_h
10 #define GlobeEngine_AxisAlignedBoundingBox_h
11 
12 #include <vmmlib/vmmlib.hpp>
13 
14 namespace ge {
15 
16  template<int DIM, class TYPE> struct Bound
17  {
18  vmml::vector< DIM, TYPE> min;
19  vmml::vector< DIM, TYPE> max;
20  };
21 
22  template <int DIM, class TYPE> class AxisAlignedBoundingBox
23  {
24  public:
26  AxisAlignedBoundingBox(const vmml::vector< DIM, TYPE>& _min, const vmml::vector< DIM, TYPE>& _side) {
27  this->set(_min, _side);
28  };
29 
31 
32  void clear() {
33  this->points.min = vmml::vector< DIM, TYPE>::ZERO;
34  this->points.max = vmml::vector< DIM, TYPE>::ZERO;
35  this->side = vmml::vector< DIM, TYPE>::ZERO;
36  }
37 
38  void set(const vmml::vector< DIM, TYPE>& _min, const vmml::vector< DIM, TYPE>& _side) {
39  this->points.min = _min;
40  this->side = _side;
41  this->points.max = this->points.min + this->side;
42  }
43 
44  void setMinMax(const vmml::vector< DIM, TYPE>& _min, const vmml::vector< DIM, TYPE>& _max) {
45  this->points.min = _min;
46  this->points.max = _max;
47  this->setSides();
48  }
49 
50  void set(const Bound< DIM, TYPE>& _points) {
51  this->points.min = _points.min;
52  this->points.max = _points.max;
53  this->setSides();
54  }
55 
56  void resetMin(const vmml::vector< DIM, TYPE>& _in) {
57  this->points.min = _in;
58  this->setSides();
59  }
60 
61  void resetMax(const vmml::vector< DIM, TYPE>& _in) {
62  this->points.max = _in;
63  this->setSides();
64  }
65 
66  vmml::vector< DIM, TYPE> getMin() const { return this->points.min; }
67  vmml::vector< DIM, TYPE> getMax() const { return this->points.max; }
68  vmml::vector< DIM, TYPE> getSides() const { return this->side; }
69 
70  private:
71  void setSides() {
72  this->side = this->points.max - this->points.min;
73  }
74 
75  // Points describing minimum and maximum
76  Bound< DIM, TYPE> points;
77  // Sidelenghts of all edges
78  vmml::vector< DIM, TYPE> side;
79  };
80 
85 
90 
91 }
92 #endif
AxisAlignedBoundingBox< 3, double > AxisAlignedBoundingBox3d
Definition: AxisAlignedBoundingBox.h:84
vmml::vector< DIM, TYPE > max
Definition: AxisAlignedBoundingBox.h:19
AxisAlignedBoundingBox(const vmml::vector< DIM, TYPE > &_min, const vmml::vector< DIM, TYPE > &_side)
Definition: AxisAlignedBoundingBox.h:26
AxisAlignedBoundingBox< 2, double > AxisAlignedBoundingBox2d
Definition: AxisAlignedBoundingBox.h:82
AxisAlignedBoundingBox< 3, float > AxisAlignedBoundingBox3f
Definition: AxisAlignedBoundingBox.h:83
void clear()
Definition: AxisAlignedBoundingBox.h:32
void resetMax(const vmml::vector< DIM, TYPE > &_in)
Definition: AxisAlignedBoundingBox.h:61
vmml::vector< DIM, TYPE > getMax() const
Definition: AxisAlignedBoundingBox.h:67
~AxisAlignedBoundingBox()
Definition: AxisAlignedBoundingBox.h:30
AxisAlignedBoundingBox< 3, double > AABB3d
Definition: AxisAlignedBoundingBox.h:89
AxisAlignedBoundingBox< 2, double > AABB2d
Definition: AxisAlignedBoundingBox.h:87
void set(const Bound< DIM, TYPE > &_points)
Definition: AxisAlignedBoundingBox.h:50
void set(const vmml::vector< DIM, TYPE > &_min, const vmml::vector< DIM, TYPE > &_side)
Definition: AxisAlignedBoundingBox.h:38
void setMinMax(const vmml::vector< DIM, TYPE > &_min, const vmml::vector< DIM, TYPE > &_max)
Definition: AxisAlignedBoundingBox.h:44
vmml::vector< DIM, TYPE > getMin() const
Definition: AxisAlignedBoundingBox.h:66
Definition: AxisAlignedBoundingBox.h:22
vmml::vector< DIM, TYPE > getSides() const
Definition: AxisAlignedBoundingBox.h:68
AxisAlignedBoundingBox< 2, float > AxisAlignedBoundingBox2f
Definition: AxisAlignedBoundingBox.h:81
Definition: AvalancheTrainingSimulationEngine.h:28
vmml::vector< DIM, TYPE > min
Definition: AxisAlignedBoundingBox.h:18
void resetMin(const vmml::vector< DIM, TYPE > &_in)
Definition: AxisAlignedBoundingBox.h:56
AxisAlignedBoundingBox()
Definition: AxisAlignedBoundingBox.h:25
AxisAlignedBoundingBox< 3, float > AABB3f
Definition: AxisAlignedBoundingBox.h:88
AxisAlignedBoundingBox< 2, float > AABB2f
Definition: AxisAlignedBoundingBox.h:86
Definition: AxisAlignedBoundingBox.h:16