geometry.cpp
Go to the documentation of this file.
1#include "geometry.h"
2
3#include <algorithm>
4#include <limits>
5#include <vector>
6
7#include <boost/geometry/algorithms/assign.hpp>
8#include <boost/geometry/algorithms/detail/distance/interface.hpp>
9
10#include <SimoxUtility/algorithm/apply.hpp>
11
13{
14
15 float
16 computeDistance(const std::vector<polygon_type>& obstacles, const Eigen::Vector2f& pt)
17 {
18 const point_type point(pt.x(), pt.y());
19
20 float dist = std::numeric_limits<float>::max();
21 for (const auto& obstacle : obstacles)
22 {
23 const float d = boost::geometry::distance(point, obstacle);
24 dist = std::min(d, dist);
25 }
26
27 return dist;
28 }
29
31 toPolygon(const std::vector<Eigen::Vector2f>& hull)
32 {
33 std::vector<point_type> points = simox::alg::apply(hull, toPoint);
34 points.push_back(points.front()); // close polygon
35
36 polygon_type polygon;
37 boost::geometry::assign_points(polygon, points);
38
39 return polygon;
40 }
41
43 toPoint(const Eigen::Vector2f& pt)
44 {
45 return {pt.x(), pt.y()};
46 }
47
48 Eigen::Vector2f
50 {
51 return {pt.x(), pt.y()};
52 }
53
54} // namespace armarx::navigation::util::geometry
This file is part of ArmarX.
Definition geometry.cpp:13
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
float computeDistance(const std::vector< polygon_type > &obstacles, const Eigen::Vector2f &pt)
Definition geometry.cpp:16
boost::geometry::model::polygon< point_type > polygon_type
Definition geometry.h:36