line2d.h
Go to the documentation of this file.
1 #ifndef LINE2D_H
2 #define LINE2D_H
3 
4 #include "tuw_geometry/polar2d.h"
5 #include <cstdio>
6 
7 namespace tuw {
8 class Line2D;
9 using Line2DPtr = std::shared_ptr< Line2D > ;
10 using Line2DConstPtr = std::shared_ptr< Line2D const>;
11 
16 class Line2D : public cv::Vec<double,3> {
17 public:
19  Line2D();
24  Line2D ( const Line2D &l );
30  Line2D ( cv::Vec<double,3> &l, bool normalize = true );
39  Line2D ( const double &x0, const double &y0, const double &x1, const double &y1, bool normalize = true );
46  Line2D ( const Point2D &pt1, const Point2D &pt2, bool normalize = true );
50  double &a();
54  const double &a() const;
58  double &b();
62  const double &b() const;
66  double &c();
70  const double &c() const;
74  void normalize();
82  double distanceTo ( const double &x, const double &y ) const;
89  double distanceTo ( const Point2D &p ) const;
97  Point2D pointOnLine ( const double &x, const double &y ) const;
104  Point2D pointOnLine ( const Point2D &p ) const;
111  Point2D intersection ( const Line2D &l ) const;
116  cv::Vec<double,2> normal() const;
126  Line2D &set ( const double &x0, const double &y0, const double &x1, const double &y1, bool normalize = true );
134  Line2D &set ( const Point2D &p0, const Point2D &p1, bool normalize = true );
139  cv::Vec<double,3> &cv ();
144  const cv::Vec<double,3> &cv () const;
149  Polar2D toPolar() const;
150 
151 
152  friend std::ostream &operator << ( std::ostream &os, const Line2D &o ) {
153  os << "[" << o.a() << ", " << o.b() << ", " << o.c() << "]";
154  return os;
155  };
156 
157 };
158 
159 };
160 #endif // LINE2D_H
std::shared_ptr< Line2D > Line2DPtr
Prototype.
Definition: line2d.h:9
Point2D pointOnLine(const double &x, const double &y) const
Definition: line2d.cpp:49
friend std::ostream & operator<<(std::ostream &os, const Line2D &o)
Definition: line2d.h:152
Line2D()
constructor
Definition: line2d.cpp:5
std::shared_ptr< Line2D const > Line2DConstPtr
Definition: line2d.h:10
Point2D intersection(const Line2D &l) const
Definition: line2d.cpp:57
Polar2D toPolar() const
Definition: line2d.cpp:78
cv::Vec< double, 2 > normal() const
Definition: line2d.cpp:61
cv::Vec< double, 3 > & cv()
Definition: line2d.cpp:72
Definition: command.h:8
double distanceTo(const double &x, const double &y) const
Definition: line2d.cpp:41
double & c()
Definition: line2d.cpp:31
double & b()
Definition: line2d.cpp:25
double & a()
Definition: line2d.cpp:19
void normalize()
Definition: line2d.cpp:37


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