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
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
This file is part of ArmarX.
std::vector< Eigen::Vector2f > to2D(const std::vector< Eigen::Vector3f > &v)
Definition eigen.cpp:29
Eigen::Vector2f fromPoint(const point_type &pt)
Definition geometry.cpp:49
boost::geometry::model::d2::point_xy< float > point_type
Definition geometry.h:35
point_type toPoint(const Eigen::Vector2f &pt)
Definition geometry.cpp:43
polygon_type toPolygon(const std::vector< Eigen::Vector2f > &hull)
Definition geometry.cpp:31
boost::geometry::model::polygon< point_type > polygon_type
Definition geometry.h:36
bool isInside(const Eigen::Vector3f &point, bool restrictTo2dCheck=false) const
Definition Room.cpp:17
std::vector< Eigen::Vector2f > polygon
Definition Room.h:37
std::tuple< Eigen::Vector2f, Eigen::Vector2f > aabb() const
Definition Room.cpp:45
Eigen::Vector2f center() const
Definition Room.cpp:34