Go to the documentation of this file.00001
00002 #ifndef vpgl_reg_fundamental_matrix_txx_
00003 #define vpgl_reg_fundamental_matrix_txx_
00004
00005
00006
00007 #include "vpgl_reg_fundamental_matrix.h"
00008 #include <vnl/vnl_fwd.h>
00009 #include <vgl/vgl_point_2d.h>
00010
00011
00012 template <class T>
00013 vpgl_reg_fundamental_matrix<T>::vpgl_reg_fundamental_matrix() :
00014 vpgl_fundamental_matrix<T>()
00015 {
00016 vnl_matrix_fixed<T,3,3> default_matrix( (T)0 );
00017 default_matrix(0,1) = default_matrix(0,2) = (T)1;
00018 default_matrix(1,0) = default_matrix(2,0) = -(T)1;
00019 set_matrix( default_matrix );
00020 }
00021
00022
00023
00024 template <class T>
00025 vpgl_reg_fundamental_matrix<T>::vpgl_reg_fundamental_matrix(
00026 const vgl_point_2d<T>& pr,
00027 const vgl_point_2d<T>& pl ) :
00028 vpgl_fundamental_matrix<T>()
00029 {
00030 set_from_points( pr, pl );
00031 }
00032
00033
00034 template <class T>
00035 vpgl_reg_fundamental_matrix<T>::vpgl_reg_fundamental_matrix(
00036 const vpgl_fundamental_matrix<T>& fm )
00037 {
00038 set_from_params( fm.get_matrix()(0,2), fm.get_matrix()(2,1) );
00039 }
00040
00041
00042
00043 template <class T>
00044 bool vpgl_reg_fundamental_matrix<T>::set_from_points(
00045 const vgl_point_2d<T>& pr,
00046 const vgl_point_2d<T>& pl )
00047 {
00048 T ex = pl.x() - pr.x();
00049 T ey = pl.y() - pr.y();
00050 if ( ex == 0 && ey == 0 ) return false;
00051 vnl_matrix_fixed<T,3,3> fm( (T)0 );
00052 fm.put( 0, 2, ey );
00053 fm.put( 1, 2, -ex );
00054 fm.put( 2, 0, -ey );
00055 fm.put( 2, 1, ex );
00056 set_matrix( fm );
00057 return true;
00058 }
00059
00060
00061
00062 template <class T>
00063 void vpgl_reg_fundamental_matrix<T>::set_from_params( T a, T b )
00064 {
00065 vnl_matrix_fixed<T,3,3> fm( (T)0 );
00066 fm.put( 0, 2, a );
00067 fm.put( 1, 2, -b );
00068 fm.put( 2, 0, -a );
00069 fm.put( 2, 1, b );
00070 set_matrix( fm );
00071 };
00072
00073
00074
00075 #undef vpgl_REG_FUNDAMENTAL_MATRIX_INSTANTIATE
00076 #define vpgl_REG_FUNDAMENTAL_MATRIX_INSTANTIATE(T) \
00077 template class vpgl_reg_fundamental_matrix<T >
00078
00079 #endif // vpgl_reg_fundamental_matrix_txx_