contrib/oxl/mvl/HMatrix1D.h
Go to the documentation of this file.
00001 // This is oxl/mvl/HMatrix1D.h
00002 #ifndef HMatrix1D_h_
00003 #define HMatrix1D_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 //
00010 // A class to hold a line-to-line projective transformation matrix
00011 // and to perform common operations using it e.g. transfer point.
00012 //
00013 // \verbatim
00014 //  Modifications
00015 //   22 Oct 2002 - Peter Vanroose - added vgl_homg_point_1d interface
00016 //   23 Oct 2002 - Peter Vanroose - using fixed 3x3 matrices throughout
00017 // \endverbatim
00018 
00019 #include <vnl/vnl_double_2x2.h>
00020 #include <vgl/vgl_homg_point_1d.h>
00021 #include <vcl_iosfwd.h>
00022 
00023 class HMatrix1D
00024 {
00025   // Data Members--------------------------------------------------------------
00026   vnl_double_2x2 t12_matrix_;
00027   vnl_double_2x2 t21_matrix_;
00028 
00029  public:
00030   // Constructors/Initializers/Destructors-------------------------------------
00031 
00032   HMatrix1D();
00033   HMatrix1D(const HMatrix1D& M);
00034   HMatrix1D(const HMatrix1D&,const HMatrix1D&);// product of two HMatrix1Ds
00035   HMatrix1D(vnl_double_2x2 const& M);
00036   HMatrix1D(const double* t_matrix);
00037   HMatrix1D(vcl_istream& s);
00038  ~HMatrix1D();
00039   static HMatrix1D read(char const* filename);
00040   static HMatrix1D read(vcl_istream&);
00041 
00042   // Operations----------------------------------------------------------------
00043 
00044   //: Return the transformed point given by $x_2 = {\tt H} x_1$
00045   vgl_homg_point_1d<double> operator()(const vgl_homg_point_1d<double>& x1) const;
00046   //: Return the transformed point given by $x_1 = {\tt H}^{-1} x_2$
00047   vgl_homg_point_1d<double> preimage(const vgl_homg_point_1d<double>& x2) const;
00048 
00049   // deprecated. also misnomers :
00050  private:
00051   //: Return the transformed point given by $x_2 = {\tt H} x_1$
00052   vgl_homg_point_1d<double> transform_to_plane2(const vgl_homg_point_1d<double>& x1) const
00053   { return (*this)(x1); }
00054   //: Return the transformed point given by $x_1 = {\tt H}^{-1} x_2$
00055   vgl_homg_point_1d<double> transform_to_plane1(const vgl_homg_point_1d<double>& x2) const
00056   { return this->preimage(x2); }
00057  public:
00058 
00059   // Data Access---------------------------------------------------------------
00060 
00061   double get (unsigned int row_index, unsigned int col_index) const;
00062   void get (double *t_matrix) const;
00063   void get (vnl_matrix<double>* t_matrix) const;
00064   const vnl_double_2x2& get_matrix () const { return t12_matrix_; }
00065   const vnl_double_2x2& get_inverse () const { return t21_matrix_; }
00066 
00067   void set (const double *t_matrix);
00068   void set (vnl_double_2x2 const& t_matrix);
00069   void set_inverse (vnl_double_2x2 const& t21_matrix);
00070 };
00071 
00072 vcl_ostream& operator << (vcl_ostream& s, const HMatrix1D& H);
00073 vcl_istream& operator >> (vcl_istream& s, HMatrix1D& H);
00074 
00075 #endif // HMatrix1D_h_