1 #ifndef GEOMETRY_TOOLS_H_ 2 #define GEOMETRY_TOOLS_H_ 4 #include <geometry_msgs/Polygon.h> 5 #include <geometry_msgs/Point.h> 16 template<
typename T,
typename S>
18 return sqrt(pow(one.x-two.x,2.0) + pow(one.y-two.y,2.0) + pow(one.z-two.z,2.0));
29 if(polygon.points.size() > 1)
31 for (
int i = 0, j = polygon.points.size() - 1; i < polygon.points.size(); j = i++)
46 template<
typename T,
typename S>
47 bool pointsNearby(
const T &one,
const S &two,
const double &proximity){
60 for (
int i = 0, j = polygon.points.size()-1; i < polygon.points.size(); j = i++) {
61 if ( ((polygon.points[i].y > point.y) != (polygon.points[j].y>point.y)) &&
62 (point.x < (polygon.points[j].x-polygon.points[i].x) * (point.y-polygon.points[i].y) / (polygon.points[j].y-polygon.points[i].y) + polygon.points[i].x) ){
66 return bool(cross % 2);
75 template<
typename T,
typename S>
78 double delta_x, delta_y;
79 delta_x = end.x - origin.x;
80 delta_y = end.y - origin.y;
82 double yaw = atan(delta_x/delta_y);
double pointsDistance(const T &one, const S &two)
Calculate distance between two points.
TFSIMD_FORCE_INLINE Vector3 cross(const Vector3 &v) const
bool pointsNearby(const T &one, const S &two, const double &proximity)
Evaluate whether two points are approximately adjacent, within a specified proximity distance...
double polygonPerimeter(const geometry_msgs::Polygon &polygon)
Calculate polygon perimeter.
double yawOfVector(const T &origin, const S &end)
Calculate the yaw of vector defined by origin and end points.
bool pointInPolygon(const T &point, const geometry_msgs::Polygon &polygon)
Evaluate if point is inside area defined by polygon. Undefined behaviour for points on line...