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
13namespace safety_zone
14{
15
16// exceptions
17struct WrongNumberOfVertices : public std::exception
18{
19 const char* what() const throw() {
20 return "Polygon: wrong number of vertices was supplied!";
21 }
22};
23
24struct WrongNumberOfColumns : public std::exception
25{
26 const char* what() const throw() {
27 return "Polygon: wrong number of colums, it should be =2!";
28 }
29};
30
31struct ExtraVertices : public std::exception
32{
33 const char* what() const throw() {
34 return "Polygon: useless vertices detected, polygon methods may break!";
35 }
36};
37
38class Polygon {
39public:
40 Polygon(const Eigen::MatrixXd vertices);
41
42 bool isPointInside(const double px, const double py);
43 bool doesSectionIntersect(const double startX, const double startY, const double endX, const double endY);
44 bool isClockwise();
45 void inflateSelf(double amount);
46
47 std::vector<geometry_msgs::msg::Point> getPointMessageVector(const double z);
48
49private:
50 Eigen::MatrixXd vertices;
51};
52
53} // namespace safety_zone
54
55} // namespace mrs_lib
56
57#endif // MRS_LIB_POLYGON_H
Definition polygon.h:38
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24