point.h
Go to the documentation of this file.
00001 #ifndef _LAMA_COMMON_POINT_H_
00002 #define _LAMA_COMMON_POINT_H_
00003 
00004 #include <cmath>
00005 
00006 #include <geometry_msgs/Point.h>
00007 #include <geometry_msgs/Point32.h>
00008 
00009 namespace lama_common
00010 {
00011 
00012 struct Point2
00013 {
00014   double x;
00015   double y;
00016 
00017   Point2(): x(0), y(0) {}
00018   Point2(const double x_, const double y_): x(x_), y(y_) {}
00019   Point2(const Point2& p) : x(p.x), y(p.y) {}
00020   Point2(const geometry_msgs::Point& p) : x(p.x), y(p.y) {}
00021   Point2(const geometry_msgs::Point32& p) : x(p.x), y(p.y) {}
00022 
00023   bool operator==(const Point2 &p)
00024   {
00025     return (p.x == x && p.y == y);
00026   }
00027 
00028   friend std::ostream &operator<<(std::ostream &os, const Point2 &p);
00029 };
00030 
00031 template<typename T>
00032 double pointDistanceSquared2(const T &pa, const T &pb)
00033 {
00034   const double dx = pa.x - pb.x;
00035   const double dy = pa.y - pb.y;
00036   return dx * dx + dy * dy;
00037 }
00038 
00039 template<typename T>
00040 double pointDistance2(const T &pa, const T &pb)
00041 {
00042   return std::sqrt(pointDistanceSquared2(pa, pb));
00043 }
00044 
00045 } // namespace lama_common
00046 
00047 #endif // _LAMA_COMMON_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