geometry.h
Go to the documentation of this file.
1#pragma once
2
3// TODO To be moved to Simox after ROBDEKON demo
4
5#include <vector>
6
7#include <boost/geometry.hpp>
8#include <boost/geometry/algorithms/area.hpp>
9#include <boost/geometry/algorithms/assign.hpp>
10#include <boost/geometry/algorithms/detail/within/interface.hpp>
11#include <boost/geometry/core/cs.hpp>
12#include <boost/geometry/geometries/point_xy.hpp>
13#include <boost/geometry/geometries/polygon.hpp>
14#include <boost/geometry/geometries/register/point.hpp>
15
16#include <VirtualRobot/MathTools.h>
17
18BOOST_GEOMETRY_REGISTER_POINT_2D(Eigen::Vector2f, float, cs::cartesian, x(), y())
19
20namespace armarx::geometry
21{
22 namespace bg = boost::geometry;
23
24 class ConvexHull
25 {
26 public:
27 using Point = bg::model::d2::point_xy<float>;
28
29 ConvexHull(const VirtualRobot::MathTools::ConvexHull2D& hull) : ConvexHull(hull.vertices)
30 {
31 }
32
33 ConvexHull(const std::vector<Eigen::Vector2f>& hull)
34 {
35 boost::geometry::assign_points(polygon, hull);
36 }
37
38 bool
39 contains(const Eigen::Vector2f& point) const
40 {
41 return bg::within(Point(point.x(), point.y()), polygon);
42 }
43
44 float
45 area() const
46 {
47 return static_cast<float>(bg::area(polygon));
48 }
49
50 private:
51 bg::model::polygon<Point> polygon;
52 };
53
54 // inline float area()
55 // {
56
57 // return bg::area(polygon);
58 // }
59
60} // namespace armarx::geometry
bool contains(const MemoryID &general, const MemoryID &specific)
Indicates whether general is "less specific" than, or equal to, specific, i.e.
Definition MemoryID.cpp:563
This file offers overloads of toIce() and fromIce() functions for STL container types.
Eigen::Vector3f Point