mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
polygon.h
1 // clang: TomasFormat
2 #ifndef MRS_LIB_POLYGON_H
3 #define MRS_LIB_POLYGON_H
4 
5 #include <ros/ros.h>
6 #include <eigen3/Eigen/Eigen>
7 #include <vector>
8 #include <geometry_msgs/Point.h>
9 #include <mrs_lib/safety_zone/line_operations.h>
10 
11 namespace mrs_lib
12 {
13 class Polygon {
14 public:
15  Polygon(const Eigen::MatrixXd vertices);
16 
17  bool isPointInside(const double px, const double py);
18  bool doesSectionIntersect(const double startX, const double startY, const double endX, const double endY);
19  bool isClockwise();
20  void inflateSelf(double amount);
21 
22  std::vector<geometry_msgs::Point> getPointMessageVector(const double z);
23 
24 private:
25  Eigen::MatrixXd vertices;
26 
27 public:
28  // exceptions
29  struct WrongNumberOfVertices : public std::exception
30  {
31  const char* what() const throw() {
32  return "Polygon: wrong number of vertices was supplied!";
33  }
34  };
35 
36  struct WrongNumberOfColumns : public std::exception
37  {
38  const char* what() const throw() {
39  return "Polygon: wrong number of colums, it should be =2!";
40  }
41  };
42 
43  struct ExtraVertices : public std::exception
44  {
45  const char* what() const throw() {
46  return "Polygon: useless vertices detected, polygon methods may break!";
47  }
48  };
49 };
50 } // namespace mrs_lib
51 
52 #endif // MRS_LIB_POLYGON_H
mrs_lib::Polygon::WrongNumberOfVertices
Definition: polygon.h:29
mrs_lib
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition: attitude_converter.h:29
mrs_lib::Polygon
Definition: polygon.h:13
mrs_lib::Polygon::ExtraVertices
Definition: polygon.h:43
mrs_lib::Polygon::WrongNumberOfColumns
Definition: polygon.h:36