contrib/oxl/mvl/HomgLine2D.cxx
Go to the documentation of this file.
00001 // This is oxl/mvl/HomgLine2D.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 
00008 #include "HomgLine2D.h"
00009 
00010 #include <vcl_iostream.h>
00011 
00012 #include <vnl/algo/vnl_svd.h>
00013 
00014 #include <mvl/Homg2D.h>
00015 #include <mvl/HomgLineSeg2D.h>
00016 #include <mvl/HomgOperator2D.h>
00017 
00018 //--------------------------------------------------------------
00019 //
00020 //: Construct an ImplicitLine by clipping against the given bounding rectangle.
00021 //  The return line has been allocated using new.
00022 HomgLineSeg2D HomgLine2D::clip(int rect1_x, int rect1_y, int rect2_x, int rect2_y) const
00023 {
00024   return HomgOperator2D::clip_line_to_lineseg(*this, rect1_x, rect1_y, rect2_x, rect2_y);
00025 }
00026 
00027 //--------------------------------------------------------------
00028 //
00029 //: Return some two points which are on the line.
00030 //  The algorithm actually returns an orthonormal basis for the nullspace of l.
00031 void HomgLine2D::get_2_points_on_line(HomgPoint2D* p1, HomgPoint2D* p2) const
00032 {
00033   vnl_matrix<double> M(get_vector().data_block(), 1, 3);
00034   vnl_svd<double> svd(M);
00035   p1->set(svd.V(0,1), svd.V(1,1), svd.V(2,1));
00036   p2->set(svd.V(0,2), svd.V(1,2), svd.V(2,2));
00037 }
00038 
00039 //-----------------------------------------------------------------------------
00040 //
00041 //: Print to vcl_ostream in the format "<HomgLine2D x y w>"
00042 vcl_ostream& operator<<(vcl_ostream& s, const HomgLine2D& p)
00043 {
00044   return s << "<HomgLine2D " << p.get_vector() << ">";
00045 }