00001
00002 #ifndef vgl_h_matrix_2d_h_
00003 #define vgl_h_matrix_2d_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <vcl_vector.h>
00020 #include <vnl/vnl_matrix_fixed.h>
00021 #include <vgl/vgl_homg_point_2d.h>
00022 #include <vgl/vgl_homg_line_2d.h>
00023 #include <vgl/vgl_conic.h>
00024 #include <vcl_iosfwd.h>
00025
00026
00027
00028
00029 template <class T>
00030 class vgl_h_matrix_2d
00031 {
00032
00033 protected:
00034 vnl_matrix_fixed<T,3,3> t12_matrix_;
00035
00036 public:
00037
00038
00039
00040 vgl_h_matrix_2d();
00041 vgl_h_matrix_2d(const vgl_h_matrix_2d<T>& M);
00042 vgl_h_matrix_2d(vnl_matrix_fixed<T,3,3> const& M);
00043 vgl_h_matrix_2d(const T* t_matrix);
00044 vgl_h_matrix_2d(vcl_istream& s);
00045 vgl_h_matrix_2d(char const* filename);
00046
00047 ~vgl_h_matrix_2d();
00048
00049
00050
00051 vgl_homg_point_2d<T> operator()(vgl_homg_point_2d<T> const& p) const;
00052 vgl_homg_point_2d<T> operator*(vgl_homg_point_2d<T> const& p) const { return (*this)(p);}
00053 bool operator==(vgl_h_matrix_2d<T> const& M) { return t12_matrix_ == M.get_matrix(); }
00054
00055 vgl_homg_line_2d<T> preimage(vgl_homg_line_2d<T> const& l) const;
00056 vgl_homg_line_2d<T> correlation(vgl_homg_point_2d<T> const& p) const;
00057 vgl_homg_point_2d<T> correlation(vgl_homg_line_2d<T> const& l) const;
00058
00059
00060 vgl_conic<T> operator() (vgl_conic<T> const& C) const;
00061
00062
00063 vgl_homg_point_2d<T> preimage(vgl_homg_point_2d<T> const& p) const;
00064 vgl_conic<T> preimage(vgl_conic<T> const& C) const;
00065 vgl_homg_line_2d<T> operator()(vgl_homg_line_2d<T> const& l) const;
00066 vgl_homg_line_2d<T> operator*(vgl_homg_line_2d<T> const& l) const { return (*this)(l);}
00067
00068
00069 vgl_h_matrix_2d operator*(const vgl_h_matrix_2d& h2) const { return vgl_h_matrix_2d<T>(t12_matrix_ * h2.t12_matrix_); }
00070
00071
00072
00073 T get(unsigned int row_index, unsigned int col_index) const;
00074 void get(T *t_matrix) const;
00075 void get(vnl_matrix<T>* t_matrix) const;
00076 const vnl_matrix_fixed<T,3,3>& get_matrix() const { return t12_matrix_; }
00077 const vgl_h_matrix_2d get_inverse () const;
00078
00079 void set(const T *t_matrix);
00080 void set(vnl_matrix_fixed<T,3,3> const& t_matrix);
00081
00082
00083
00084
00085 void set_identity();
00086
00087
00088 void set_translation(const T tx, const T ty);
00089
00090
00091
00092 void set_rotation(const T theta);
00093
00094
00095
00096
00097
00098
00099
00100 void set_scale(const T scale);
00101
00102
00103
00104
00105
00106
00107
00108 void set_aspect_ratio(const T aspect_ratio);
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 bool projective_basis(vcl_vector<vgl_homg_point_2d<T> > const& four_points);
00122
00123
00124
00125
00126
00127
00128 bool projective_basis(vcl_vector<vgl_homg_line_2d<T> > const& four_lines
00129 #ifdef VCL_VC_6
00130 , int dummy=0
00131 #endif
00132 );
00133
00134 bool read(vcl_istream& s);
00135 bool read(char const* filename);
00136 };
00137
00138 template <class T> vcl_ostream& operator<<(vcl_ostream& s, const vgl_h_matrix_2d<T>& h);
00139 template <class T> vcl_istream& operator>>(vcl_istream& s, vgl_h_matrix_2d<T>& h);
00140
00141 #define VGL_H_MATRIX_2D_INSTANTIATE(T) extern "please include vgl/algo/vgl_h_matrix_2d.txx first"
00142
00143 #endif // vgl_h_matrix_2d_h_