1 // This is oxl/mvl/HomgLine2D.h 2 #ifndef HomgLine2D_h_ 3 #define HomgLine2D_h_ 4 5 //-------------------------------------------------------------- 6 //: 7 // \file 8 // \brief Homogeneous 3-vector for a 2D line 9 // 10 // A class to hold a homogeneous 3-vector for a 2D line. 11 // 12 // \verbatim 13 // Modifications: 14 // Peter Vanroose - 11 Mar 97 - added operator== 15 // \endverbatim 16 17 #include <iostream> 18 #include <iosfwd> 19 #ifdef _MSC_VER 20 # include <vcl_msvc_warnings.h> 21 #endif 22 #include <mvl/Homg2D.h> 23 24 class HomgLineSeg2D; 25 class HomgPoint2D; 26 27 class HomgLine2D : public Homg2D 28 { 29 public: 30 31 HomgLine2D () = default; 32 HomgLine2D (const HomgLine2D& that) = default; HomgLine2D(double px,double py,double pw)33 HomgLine2D (double px, double py, double pw): Homg2D (px, py, pw) {} HomgLine2D(const vnl_double_3 & vector_ptr)34 explicit HomgLine2D (const vnl_double_3& vector_ptr): Homg2D (vector_ptr) {} 35 ~HomgLine2D () = default; 36 37 HomgLine2D& operator=(const HomgLine2D& that) = default; 38 39 //: Return true iff the line is the line at infinity. 40 // If tol == 0, x() and y() must be exactly 0. 41 // Otherwise, tol is used as tolerance value (default: 1e-12), 42 // and $max(|x|,|y|) <= \mbox{tol} \times |w|$ is checked. 43 inline bool ideal(double tol = 1e-12) const { 44 #define mvl_abs(x) ((x)<0?-(x):(x)) 45 return mvl_abs(x()) <= tol*mvl_abs(w()) && mvl_abs(y()) <= tol*mvl_abs(w()); 46 #undef mvl_abs 47 } 48 49 // Clip the infinite line to the given bounding box and return 50 HomgLineSeg2D clip(int x0, int y0, int x1, int y1) const; 51 52 // Return 2 points on the line. 53 void get_2_points_on_line(HomgPoint2D* p1, HomgPoint2D* p2) const; 54 }; 55 56 std::ostream& operator<<(std::ostream& s, const HomgLine2D& ); 57 58 #endif // HomgLine2D_h_ 59