bounding_box.cpp
Go to the documentation of this file.
2 
3 namespace tango_gl {
4 BoundingBox::BoundingBox(const std::vector<float>& vertices) {
5  // Set min and max to the first vertice.
8  size_t vertices_count = vertices.size() / 3;
9  for (size_t i = 1; i < vertices_count; i += 3) {
13 
17  }
18 }
19 
21  const glm::quat& rotation,
22  const glm::mat4& transformation) {
23  // The current bounding box.
24  glm::vec3 min, max;
25 
26  // If the mesh has been rotated, we need to derive a new bounding box
27  // based on the original one, if it just been translated or scaled,
28  // we can still use the original one with current model matrix applied.
29  if (rotation == glm::quat(1.0f, 0.0f, 0.0f, 0.0f)) {
32  } else {
33  std::vector<glm::vec3> box;
34  // Derive 8 vertices of the new bounding box from original min and max.
35  box.push_back(bounding_min_);
36  box.push_back(bounding_max_);
37 
40 
43 
46 
48  max = min;
49  for (size_t i = 1; i < box.size(); i++) {
51  min.x = std::min(temp.x, min.x);
52  min.y = std::min(temp.y, min.y);
53  min.z = std::min(temp.z, min.z);
54 
55  max.x = std::max(temp.x, max.x);
56  max.y = std::max(temp.y, max.y);
57  max.z = std::max(temp.z, max.z);
58  }
59  }
60  return util::SegmentAABBIntersect(min, max, segment.start, segment.end);
61 }
62 } // namespace tango_gl
glm::min
GLM_FUNC_DECL genType min(genType const &x, genType const &y)
tango_gl::BoundingBox::IsIntersecting
bool IsIntersecting(const Segment &segment, const glm::quat &rotation, const glm::mat4 &transformation)
Definition: bounding_box.cpp:20
tango_gl::util::ApplyTransform
glm::vec3 ApplyTransform(const glm::mat4 &mat, const glm::vec3 &vec)
Definition: util.cpp:237
tango_gl::vertices
static const float vertices[]
Definition: quad.cpp:39
tango_gl::BoundingBox::bounding_min_
glm::vec3 bounding_min_
Definition: bounding_box.h:38
glm::vec3
highp_vec3 vec3
Definition: type_vec.hpp:392
glm::detail::tquat
Definition: fwd.hpp:41
glm::detail::tvec3
Definition: type_mat.hpp:37
box
box
glm::detail::tmat4x4
Definition: type_mat.hpp:47
bounding_box.h
tango_gl::Segment
Definition: segment.h:23
glm::detail::tvec3::z
T z
Definition: type_vec3.hpp:86
tango_gl::util::SegmentAABBIntersect
bool SegmentAABBIntersect(const glm::vec3 &aabb_min, const glm::vec3 &aabb_max, const glm::vec3 &start, const glm::vec3 &end)
Definition: util.cpp:198
glm::max
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
glm::detail::tvec3::y
T y
Definition: type_vec3.hpp:85
glm::detail::tvec3::x
T x
Definition: type_vec3.hpp:84
tango_gl::BoundingBox::bounding_max_
glm::vec3 bounding_max_
Definition: bounding_box.h:39
f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
segment
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedSegmentReturnType< N >::Type segment(Index start, Index n=N)
glm::rotation
GLM_FUNC_DECL detail::tquat< T, P > rotation(detail::tvec3< T, P > const &orig, detail::tvec3< T, P > const &dest)
transformation
transformation
tango_gl
Definition: axis.cpp:20
tango_gl::BoundingBox::BoundingBox
BoundingBox()
Definition: bounding_box.h:28
i
int i


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:06