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