angular_point.h
Go to the documentation of this file.
00001 #pragma once
00002 #ifndef LAMA_COMMON_ANGULAR_POINT_H
00003 #define LAMA_COMMON_ANGULAR_POINT_H
00004 
00005 #include <cmath>
00006 #include <vector>
00007 
00008 #include <geometry_msgs/Point32.h>
00009 #include <geometry_msgs/Polygon.h>
00010 #include <lama_msgs/PlaceProfile.h>
00011 
00012 namespace lama_common
00013 {
00014 
00017 struct AngularPoint
00018 {
00019   AngularPoint(geometry_msgs::Point32 point, int32_t index_) :
00020     angle(std::atan2(point.y, point.x)),
00021     index(index_)
00022   {
00023   }
00024 
00025   double angle;
00026   int32_t index;
00027 
00028   bool operator<(const AngularPoint& other) const {return angle < other.angle;}
00029 };
00030 
00031 inline std::vector<AngularPoint> toAngularPoints(const geometry_msgs::Polygon& polygon)
00032 {
00033   std::vector<AngularPoint> angular_points;
00034   const size_t point_count = polygon.points.size();
00035   angular_points.reserve(point_count);
00036   for (size_t i = 0; i < point_count; ++i)
00037   {
00038     angular_points.push_back(AngularPoint(polygon.points[i], i));
00039   }
00040   return angular_points;
00041 }
00042 
00043 inline std::vector<AngularPoint> toAngularPoints(const lama_msgs::PlaceProfile& profile)
00044 {
00045   std::vector<AngularPoint> angular_points;
00046   const size_t point_count = profile.polygon.points.size();
00047   angular_points.reserve(point_count);
00048   for (size_t i = 0; i < point_count; ++i)
00049   {
00050     angular_points.push_back(AngularPoint(profile.polygon.points[i], i));
00051   }
00052   return angular_points;
00053 }
00054 
00055 } /* namespace lama_common */
00056 
00057 #endif /* LAMA_COMMON_ANGULAR_POINT_H */


lama_common
Author(s): Gaël Ecorchard , Karel Košnar , Vojtěch Vonásek
autogenerated on Thu Jun 6 2019 22:02:03