contrib/rpl/rgrl/rgrl_trans_mixed_spline.cxx
Go to the documentation of this file.
00001 #include "rgrl_trans_mixed_spline.h"
00002 //:
00003 // \file
00004 #include <vcl_cassert.h>
00005 
00006 void
00007 rgrl_trans_mixed_spline::
00008 map_loc( vnl_vector< double > const& from,
00009          vnl_vector< double > & to ) const
00010 {
00011   vnl_vector< double > temp_to;
00012   to.set( 0 );
00013 
00014   for ( unsigned i = 0; i < trans_splines_.size(); ++i ) {
00015     trans_splines_[i].map_location( from, temp_to );
00016     to += temp_to;
00017   }
00018 }
00019 
00020 void
00021 rgrl_trans_mixed_spline::
00022 map_dir( vnl_vector< double > const& from_loc,
00023          vnl_vector< double > const& from_dir,
00024          vnl_vector< double > & to_dir ) const
00025 {
00026   vnl_vector<double> delta;
00027   vnl_vector<double> delta2;
00028 
00029   map_loc( from_loc, delta );
00030   // There is a potential bug:
00031   // if from2 locates outside the spline boundary, the result won't be correct.
00032   vnl_vector<double> from2 = from_loc + from_dir / from_dir.two_norm() ;
00033   //vnl_vector<double> from2 = from_loc + from_dir;
00034 
00035   map_loc( from2, delta2 );
00036   to_dir = from2 + delta2 - from_loc - delta ;
00037 }
00038 
00039 //: Compute jacobian w.r.t. location
00040 void
00041 rgrl_trans_mixed_spline::
00042 jacobian_wrt_loc( vnl_matrix<double>& jac, vnl_vector<double> const& from_loc ) const
00043 {
00044   assert( !"rgrl_trans_mixed_spline::jacobian_wrt_loc() is not implemented!" );
00045 }
00046 
00047 rgrl_transformation_sptr
00048 rgrl_trans_mixed_spline::
00049 scale_by( double scale ) const
00050 {
00051   assert( !"rgrl_trans_mixed_spline::scale_by() is not implemented!" );
00052   return 0;
00053 }
00054 
00055 
00056 vnl_matrix<double>
00057 rgrl_trans_mixed_spline::
00058 transfer_error_covar( vnl_vector<double> const& p ) const
00059 {
00060   unsigned dim = p.size();
00061   vnl_matrix<double> transfer_err_cov(dim, dim, 0);
00062 
00063   for ( unsigned i = 0; i < trans_splines_.size(); ++i ) {
00064     transfer_err_cov += trans_splines_[i].transfer_error_covar( p );
00065   }
00066 
00067   return transfer_err_cov;
00068 }
00069 
00070 //: make a clone copy
00071 rgrl_transformation_sptr
00072 rgrl_trans_mixed_spline::
00073 clone() const
00074 {
00075   return new rgrl_trans_mixed_spline( *this );
00076 }