contrib/oxl/mvl/HomgLineSeg2D.h
Go to the documentation of this file.
00001 // This is oxl/mvl/HomgLineSeg2D.h
00002 #ifndef HomgLineSeg2D_h_
00003 #define HomgLineSeg2D_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief Homogeneous 2D line segment
00010 //
00011 // A class to hold homogeneous 3-vectors for the two endpoints and
00012 // line for a 2D line segment.
00013 //
00014 // \verbatim
00015 //  Modifications:
00016 //   Peter Vanroose - 11 Mar 97 - added operator==
00017 // \endverbatim
00018 
00019 #include <mvl/HomgLine2D.h>
00020 #include <mvl/HomgPoint2D.h>
00021 #include <vcl_iosfwd.h>
00022 
00023 class HomgLineSeg2D : public HomgLine2D
00024 {
00025   HomgPoint2D point1_;
00026   HomgPoint2D point2_;
00027  public:
00028 
00029   // Constructors/Initializers/Destructors-------------------------------------
00030 
00031   HomgLineSeg2D () {}
00032   HomgLineSeg2D (const HomgPoint2D& point1, const HomgPoint2D& point2);
00033   HomgLineSeg2D (double x0, double y0, double x1, double y1);
00034   ~HomgLineSeg2D () {}
00035 
00036   // Data Access---------------------------------------------------------------
00037 
00038   // get the line through the two points.
00039   const HomgLine2D& get_line () const;
00040   const HomgPoint2D& get_point1 () const;
00041   const HomgPoint2D& get_point2 () const;
00042 
00043   void set (const HomgPoint2D& point1, const HomgPoint2D& point2);
00044 
00045   double picking_distance(const HomgPoint2D& point1) const;
00046 };
00047 
00048 vcl_ostream& operator<<(vcl_ostream& s, const HomgLineSeg2D& );
00049 
00050 //--------------------------------------------------------------
00051 //
00052 //: Return the line through the two points.
00053 inline const HomgLine2D& HomgLineSeg2D::get_line () const
00054 {
00055   return *this;
00056 }
00057 
00058 //--------------------------------------------------------------
00059 //
00060 //: Return the first point of the line segment
00061 inline const HomgPoint2D& HomgLineSeg2D::get_point1 () const
00062 {
00063   return point1_;
00064 }
00065 
00066 //--------------------------------------------------------------
00067 //
00068 //: Return the second point of the line segment
00069 inline const HomgPoint2D& HomgLineSeg2D::get_point2 () const
00070 {
00071   return point2_;
00072 }
00073 
00074 #endif // HomgLineSeg2D_h_