point2d.h
Go to the documentation of this file.
1 #ifndef POINT2D_H
2 #define POINT2D_H
3 
4 #include <memory>
5 #include <opencv2/core/core.hpp>
6 #include <tuw_geometry/utils.h>
7 
8 namespace tuw {
9 
10 
11 class Point2D;
12 class Polar2D;
13 using Point2DPtr = std::shared_ptr< Point2D >;
14 using Point2DConstPtr = std::shared_ptr< Point2D const>;
15 
19 class Point2D : public cv::Vec<double, 3 > {
20 public:
24  Point2D();
29  Point2D ( const Point2D &p );
34  Point2D ( const cv::Point &p );
40  Point2D ( double x, double y );
47  Point2D ( double x, double y, double h );
52  Point2D ( const Polar2D& p );
53  template<typename T> Point2D ( const cv::Vec<T,3> &p ) : cv::Vec<double,3> ( p ) {};
54  template<typename T> Point2D ( const cv::Vec<T,2> &p ) : cv::Vec<double,3> ( p ) {};
55  template<typename T> Point2D ( const cv::Point_<T> &p ) : cv::Vec<double,3> ( p.x,p.y,1. ) {};
56 
63  Point2D &set ( double x, double y );
70  Point2D &set ( double x, double y, double h );
75  const double &x () const;
80  double &x ();
85  const double &y () const;
90  double &y ();
95  const double &h () const;
100  double &h ();
105  void set_x (double v);
110  double get_x () const;
115  void set_y (double v);
120  double get_y () const;
125  void set_h (double v);
130  double get_h () const;
137  double angle () const;
144  double radius () const;
149  cv::Vec<double, 2> vector () const;
154  double distanceTo ( const Point2D &p ) const;
159  const cv::Point_<double> &cv () const;
164  cv::Point_<double> &cv () ;
173  bool inside ( double x0, double y0, double x1, double y1 ) const;
180  friend std::ostream &operator << ( std::ostream &os, const Point2D &o ) {
181  os << "[" << o.x() << ", " << o.y() << "]";
182  return os;
183  }
189  std::string str(const char* format = "[%6.4lf, %6.4lf, %6.5lf]") const;
190 
196  bool equal( const Point2D& o, double tolerance = 0.0001 ) const ;
197 };
198 
199 
200 };
201 
208 namespace cv {
209 template<typename _Tp> static inline tuw::Point2D operator * ( const Matx<_Tp, 3, 3>& a, const tuw::Point2D& b ) {
210  Matx<_Tp, 3, 1> c ( a, b, Matx_MatMulOp() );
211  return reinterpret_cast<const tuw::Point2D&> ( c );
212 }
213 }
214 #endif //POINT2D_H
215 
const double & y() const
Definition: point2d.cpp:49
double get_h() const
Definition: point2d.cpp:113
bool inside(double x0, double y0, double x1, double y1) const
Definition: point2d.cpp:171
void set_h(double v)
Definition: point2d.cpp:106
cv::Vec< double, 2 > vector() const
Definition: point2d.cpp:120
bool equal(const Point2D &o, double tolerance=0.0001) const
Definition: point2d.cpp:192
Definition: point2d.h:208
friend std::ostream & operator<<(std::ostream &os, const Point2D &o)
Definition: point2d.h:180
std::shared_ptr< Point2D const > Point2DConstPtr
Definition: point2d.h:14
const double & h() const
Definition: point2d.cpp:63
static tuw::Point2D operator*(const Matx< _Tp, 3, 3 > &a, const tuw::Point2D &b)
Definition: point2d.h:209
double distanceTo(const Point2D &p) const
Definition: point2d.cpp:127
std::shared_ptr< Point2D > Point2DPtr
Definition: point2d.h:13
double radius() const
Definition: point2d.cpp:160
Definition: command.h:8
double angle() const
Definition: point2d.cpp:151
double get_y() const
Definition: point2d.cpp:99
void set_x(double v)
Definition: point2d.cpp:78
std::string str(const char *format="[%6.4lf, %6.4lf, %6.5lf]") const
Definition: point2d.cpp:180
const double & x() const
Definition: point2d.cpp:35
std::string format(const cv::Mat_< int8_t > &m)
Definition: utils.cpp:11
void set_y(double v)
Definition: point2d.cpp:92
Point2D(const cv::Vec< T, 2 > &p)
Definition: point2d.h:54
Point2D(const cv::Point_< T > &p)
Definition: point2d.h:55
Point2D(const cv::Vec< T, 3 > &p)
Definition: point2d.h:53
double get_x() const
Definition: point2d.cpp:85
const cv::Point_< double > & cv() const
Definition: point2d.cpp:135


tuw_geometry
Author(s): Markus Bader
autogenerated on Mon Jun 10 2019 15:33:09