AABB.hpp
Go to the documentation of this file.
1 
38 
39 #include <limits>
40 #include <iostream>
41 
42 namespace lvr2
43 {
44 
48 template<typename T>
49 class AABB
50 {
54  size_t m_count;
55 
56 public:
57  AABB();
58 
66  template<typename P>
67  AABB(P* points, size_t count) : AABB()
68  {
69  for (size_t i = 0; i < count; i++)
70  {
71  addPoint(points[i]);
72  }
73  }
74 
84  template<typename P>
85  AABB(P& points, size_t count) : AABB()
86  {
87  for(size_t i = 0; i < count; i++)
88  {
89  addPoint(points[i]);
90  }
91  }
92 
94  const Vector3<T>& min() const;
95 
97  const Vector3<T>& max() const;
98 
100  Vector3<T> avg() const;
101 
103  size_t count() const;
104 
106  template<typename P>
107  void addPoint(const P& point)
108  {
109  for (int axis = 0; axis < 3; axis++)
110  {
111  double val = point[axis];
112  if (val < m_min[axis])
113  {
114  m_min[axis] = val;
115  }
116  if (val > m_max[axis])
117  {
118  m_max[axis] = val;
119  }
120  m_sum[axis] += val;
121  }
122  m_count++;
123  }
124 
126  T difference(int axis) const;
127 
129  int longestAxis() const;
130 };
131 
132 } // namespace lvr2
133 
134 #include "lvr2/registration/AABB.tcc"
size_t m_count
Definition: AABB.hpp:54
Vector3< T > m_sum
Definition: AABB.hpp:53
T difference(int axis) const
Calculates the size of the Bounding Box along a certain axis.
const Vector3< T > & max() const
Returns the "upper right" Corner of the Bounding Box, as in the largest x, y, z of the Point Cloud...
Vector3< T > m_max
Definition: AABB.hpp:52
AABB(P &points, size_t count)
Construct a new AABB object.
Definition: AABB.hpp:85
Eigen::Matrix< T, 3, 1 > Vector3
Eigen 3D vector.
Vector3< T > avg() const
Returns the average of all the Points in the Point Cloud.
size_t count() const
Returns the number of Points in the Point Cloud.
AABB(P *points, size_t count)
Construct a new AABB object.
Definition: AABB.hpp:67
int longestAxis() const
Calculates the axis that has the largest size of the Bounding Box.
Vector3< T > m_min
Definition: AABB.hpp:51
void addPoint(const P &point)
adds a Point to the Point Cloud
Definition: AABB.hpp:107
const Vector3< T > & min() const
Returns the "lower left" Corner of the Bounding Box, as in the smallest x, y, z of the Point Cloud...
A struct to calculate the Axis Aligned Bounding Box and Average Point of a Point Cloud.
Definition: AABB.hpp:49


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:06