Room.cpp
Go to the documentation of this file.
1 #include "Room.h"
2 
3 #include <tuple>
4 
5 #include <boost/geometry/algorithms/centroid.hpp>
6 #include <boost/geometry/algorithms/detail/envelope/interface.hpp>
7 #include <boost/geometry/algorithms/detail/within/interface.hpp>
8 #include <boost/geometry/geometries/box.hpp>
9 
12 
14 {
15 
16  bool
17  Room::isInside(const Eigen::Vector3f& point, const bool restrictTo2dCheck) const
18  {
21 
22  const bool isInsideXY = boost::geometry::within(pt, poly);
23 
24  if (restrictTo2dCheck)
25  {
26  return isInsideXY;
27  }
28 
29  const bool isInsideZ = point.z() >= zFloor and point.z() <= (zFloor + height);
30  return isInsideXY and isInsideZ;
31  }
32 
33  Eigen::Vector2f
34  Room::center() const
35  {
38 
39  boost::geometry::centroid(poly, center);
40 
42  }
43 
44  std::tuple<Eigen::Vector2f, Eigen::Vector2f>
45  Room::aabb() const
46  {
48  boost::geometry::model::box<util::geometry::point_type> box;
49 
50  boost::geometry::envelope(poly, box);
51 
52  return {util::geometry::fromPoint(box.min_corner()),
53  util::geometry::fromPoint(box.max_corner())};
54  }
55 
56  bool
57  Room::isInside(const Eigen::Vector2f& point) const
58  {
61 
62  return boost::geometry::within(pt, poly);
63  }
64 
65 } // namespace armarx::navigation::algorithms
armarx::navigation::algorithms::Room::center
Eigen::Vector2f center() const
Definition: Room.cpp:34
armarx::navigation::util::geometry::toPolygon
polygon_type toPolygon(const std::vector< Eigen::Vector2f > &hull)
Definition: geometry.cpp:31
armarx::navigation::algorithms
This file is part of ArmarX.
Definition: aron_conversions.cpp:25
geometry.h
armarx::navigation::util::geometry::point_type
boost::geometry::model::d2::point_xy< float > point_type
Definition: geometry.h:35
armarx::navigation::algorithms::Room::polygon
std::vector< Eigen::Vector2f > polygon
Definition: Room.h:37
armarx::navigation::util::geometry::fromPoint
Eigen::Vector2f fromPoint(const point_type &pt)
Definition: geometry.cpp:49
armarx::navigation::conv::to2D
std::vector< Eigen::Vector2f > to2D(const std::vector< Eigen::Vector3f > &v)
Definition: eigen.cpp:29
armarx::navigation::util::geometry::polygon_type
boost::geometry::model::polygon< point_type > polygon_type
Definition: geometry.h:36
armarx::navigation::algorithms::Room::zFloor
float zFloor
Definition: Room.h:40
armarx::navigation::algorithms::Room::aabb
std::tuple< Eigen::Vector2f, Eigen::Vector2f > aabb() const
Definition: Room.cpp:45
eigen.h
armarx::navigation::algorithms::Room::height
float height
Definition: Room.h:38
armarx::navigation::algorithms::Room::isInside
bool isInside(const Eigen::Vector3f &point, bool restrictTo2dCheck=false) const
Definition: Room.cpp:17
Room.h
armarx::navigation::util::geometry::toPoint
point_type toPoint(const Eigen::Vector2f &pt)
Definition: geometry.cpp:43