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"
lvr2::AABB::min
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.
lvr2::AABB::difference
T difference(int axis) const
Calculates the size of the Bounding Box along a certain axis.
lvr2::AABB::AABB
AABB(P &points, size_t count)
Construct a new AABB object.
Definition: AABB.hpp:85
lvr2::AABB
A struct to calculate the Axis Aligned Bounding Box and Average Point of a Point Cloud.
Definition: AABB.hpp:49
lvr2::AABB::longestAxis
int longestAxis() const
Calculates the axis that has the largest size of the Bounding Box.
lvr2::AABB::addPoint
void addPoint(const P &point)
adds a Point to the Point Cloud
Definition: AABB.hpp:107
MatrixTypes.hpp
lvr2::Vector3
Eigen::Matrix< T, 3, 1 > Vector3
Eigen 3D vector.
Definition: MatrixTypes.hpp:115
lvr2::AABB::m_count
size_t m_count
Definition: AABB.hpp:54
lvr2::AABB::max
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.
lvr2::AABB::avg
Vector3< T > avg() const
Returns the average of all the Points in the Point Cloud.
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::AABB::m_sum
Vector3< T > m_sum
Definition: AABB.hpp:53
lvr2::AABB::AABB
AABB(P *points, size_t count)
Construct a new AABB object.
Definition: AABB.hpp:67
lvr2::AABB::count
size_t count() const
Returns the number of Points in the Point Cloud.
lvr2::AABB::m_max
Vector3< T > m_max
Definition: AABB.hpp:52
lvr2::AABB::m_min
Vector3< T > m_min
Definition: AABB.hpp:51
lvr2::AABB::AABB
AABB()


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 Wed Mar 2 2022 00:37:22