AABox.hpp
Go to the documentation of this file.
1 
2 namespace GfxTL
3 {
4  template <class Point>
5  AABox<Point>::AABox(const PointType& pmin, const PointType& pmax) : _pmin(pmin), _pmax(pmax)
6  {
7  }
8 
9  template <class Point>
10  void
12  {
13  for (unsigned int i = 0; i < Dim; ++i)
14  {
15  _pmin[i] = -std::numeric_limits<ScalarType>::infinity();
16  _pmax[i] = std::numeric_limits<ScalarType>::infinity();
17  }
18  }
19 
20  template <class Point>
21  void
22  AABox<Point>::Split(unsigned int axis,
23  ScalarType s,
24  AABox<Point>* left,
25  AABox<Point>* right) const
26  {
27  *left = *right = *this;
28  if (_pmax[axis] > s)
29  {
30  left->_pmax[axis] = s;
31  }
32  if (_pmin[axis] < s)
33  {
34  right->_pmin[axis] = s;
35  }
36  }
37 
38  template <class Point>
39  void
40  AABox<Point>::Center(Point* center) const
41  {
42  *center = _pmin;
43  *center += _pmax;
44  *center /= 2;
45  }
46 
47  template <class Point>
48  Point
49  AABox<Point>::operator[](unsigned int index) const
50  {
51  Point p;
52  for (unsigned int i = 0; i < Dim; ++i)
53  {
54  if (index & (1 << i))
55  {
56  p[i] = _pmin[i];
57  }
58  else
59  {
60  p[i] = _pmax[i];
61  }
62  }
63  return p;
64  }
65 
66  template <class Point>
67  Point&
69  {
70  return _pmin;
71  }
72 
73  template <class Point>
74  const Point&
75  AABox<Point>::Min() const
76  {
77  return _pmin;
78  }
79 
80  template <class Point>
81  Point&
83  {
84  return _pmax;
85  }
86 
87  template <class Point>
88  const Point&
89  AABox<Point>::Max() const
90  {
91  return _pmax;
92  }
93 
94  template <class Point>
95  typename AABox<Point>::ScalarType
97  {
98  return (_pmax - _pmin).Length();
99  }
100 
101  template <class Point>
102  bool
104  {
105  for (unsigned int i = 0; i < Dim; ++i)
106  if (_pmin[i] > p[i] || _pmax[i] < p[i])
107  {
108  return false;
109  }
110  return true;
111  }
112 
113  template <class Point>
114  AABox<Point>&
116  {
117  for (unsigned int i = 0; i < Dim; ++i)
118  {
119  if (_pmin[i] > p[i])
120  {
121  _pmin[i] = p[i];
122  }
123  if (_pmax[i] < p[i])
124  {
125  _pmax[i] = p[i];
126  }
127  }
128  return *this;
129  }
130 }; // namespace GfxTL
GfxTL::VectorXD
Definition: MatrixXX.h:24
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::Split
std::vector< std::string > Split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelperTemplates.h:36
armarx::operator+=
std::vector< T > & operator+=(std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:96
Point
Definition: PointCloud.h:21
GfxTL
Definition: AABox.h:9
GfxTL::AABox::AABox
AABox()
Definition: AABox.h:30
GfxTL::AABox< GfxTL::VectorXD >::ScalarType
GfxTL::VectorXD ::ScalarType ScalarType
Definition: AABox.h:23
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
GfxTL::AABox
Definition: AABox.h:19