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)
6  : _pmin(pmin)
7  , _pmax(pmax)
8  {}
9 
10  template< class Point >
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 AABox< Point >::Split(unsigned int axis, ScalarType s,
22  AABox< Point >* left, AABox< Point >* right) const
23  {
24  *left = *right = *this;
25  if (_pmax[axis] > s)
26  {
27  left->_pmax[axis] = s;
28  }
29  if (_pmin[axis] < s)
30  {
31  right->_pmin[axis] = s;
32  }
33  }
34 
35  template< class Point >
36  void AABox< Point >::Center(Point* center) const
37  {
38  *center = _pmin;
39  *center += _pmax;
40  *center /= 2;
41  }
42 
43  template< class Point >
45  {
46  Point p;
47  for (unsigned int i = 0; i < Dim; ++i)
48  {
49  if (index & (1 << i))
50  {
51  p[i] = _pmin[i];
52  }
53  else
54  {
55  p[i] = _pmax[i];
56  }
57  }
58  return p;
59  }
60 
61  template< class Point >
63  {
64  return _pmin;
65  }
66 
67  template< class Point >
68  const Point& AABox< Point >::Min() const
69  {
70  return _pmin;
71  }
72 
73  template< class Point >
75  {
76  return _pmax;
77  }
78 
79  template< class Point >
80  const Point& AABox< Point >::Max() const
81  {
82  return _pmax;
83  }
84 
85  template< class Point >
87  {
88  return (_pmax - _pmin).Length();
89  }
90 
91  template< class Point >
92  bool AABox< Point >::IsInside(const Point& p) const
93  {
94  for (unsigned int i = 0; i < Dim; ++i)
95  if (_pmin[i] > p[i] || _pmax[i] < p[i])
96  {
97  return false;
98  }
99  return true;
100  }
101 
102  template< class Point >
104  {
105  for (unsigned int i = 0; i < Dim; ++i)
106  {
107  if (_pmin[i] > p[i])
108  {
109  _pmin[i] = p[i];
110  }
111  if (_pmax[i] < p[i])
112  {
113  _pmax[i] = p[i];
114  }
115  }
116  return *this;
117  }
118 };
119 
GfxTL::VectorXD
Definition: MatrixXX.h:21
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:35
armarx::operator+=
std::vector< T > & operator+=(std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:89
Point
Definition: PointCloud.h:21
GfxTL
Definition: AABox.h:8
GfxTL::AABox::AABox
AABox()
Definition: AABox.h:25
GfxTL::AABox< GfxTL::VectorXD >::ScalarType
GfxTL::VectorXD ::ScalarType ScalarType
Definition: AABox.h:22
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
GfxTL::AABox
Definition: AABox.h:18