00001
00040 \endverbatim
00041
00042 #ifndef __BASE_2D__
00043 #define __BASE_2D__
00044
00045
00046 namespace Function_2D{
00047
00048
00050
00069 class Base_2D{
00070
00071 public:
00072 typedef double real_type;
00073
00074 inline Base_2D(const real_type in_offset_x = 0,
00075 const real_type in_offset_y = 0,
00076 const real_type in_scale_x = 1,
00077 const real_type in_scale_y = 1,
00078 const real_type in_rotation_angle = 0,
00079 const real_type out_offset = 0,
00080 const real_type out_scale = 1);
00081
00082 virtual ~Base_2D();
00083
00084 inline real_type operator()(const real_type x,
00085 const real_type y) const;
00086
00087
00088 protected:
00089 virtual inline real_type base_value_proxy(const real_type x,
00090 const real_type y) const=0;
00091
00092 inline void update_input_rotation(const real_type a);
00093
00094
00096
00097
00098
00099 real_type input_offset_x,input_offset_y;
00101
00103
00104
00105
00106 real_type input_scale_x,input_scale_y;
00108
00111 real_type input_rotation_angle;
00112
00114
00115
00116 real_type cos_a,sin_a;
00118
00120 real_type output_scale;
00121
00123 real_type output_offset;
00124
00125
00126 };
00127
00128
00129
00131 class Direct_interface_2D:public Base_2D{
00132
00133 public:
00134
00135 inline Direct_interface_2D(const real_type in_offset_x = 0,
00136 const real_type in_offset_y = 0,
00137 const real_type in_scale_x = 1,
00138 const real_type in_scale_y = 1,
00139 const real_type in_rotation_angle = 0,
00140 const real_type out_offset = 0,
00141 const real_type out_scale = 1);
00142
00143 inline void set_input_offset(const real_type x,const real_type y);
00144 inline void set_input_scale(const real_type x,const real_type y);
00145 inline void set_input_rotation(const real_type a);
00146
00147 inline void set_output_offset(const real_type o);
00148 inline void set_output_scale(const real_type s);
00149
00150 };
00151
00152
00153
00154
00156
00160 class Filter_interface_2D:public Base_2D{
00161
00162 public:
00163
00164 inline Filter_interface_2D(const real_type center_x = 0,
00165 const real_type center_y = 0,
00166 const real_type sigma_x = 1,
00167 const real_type sigma_y = 1,
00168 const real_type sig_scale_x = 1,
00169 const real_type sig_scale_y = 1,
00170 const real_type orientation_angle = 0,
00171 const real_type out_sigma_scale = 1);
00172
00173
00174 inline void set_center(const real_type x,const real_type y);
00175 inline void set_orientation(const real_type o);
00176 inline void set_sigma(const real_type x,const real_type y);
00177
00178 protected:
00180
00181
00182 real_type sigma_scale_x,sigma_scale_y;
00184
00186 real_type output_sigma_scale;
00187 };
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 Base_2D::Base_2D(const real_type in_offset_x,
00214 const real_type in_offset_y,
00215 const real_type in_scale_x,
00216 const real_type in_scale_y,
00217 const real_type in_rotation_angle,
00218 const real_type out_offset,
00219 const real_type out_scale):
00220
00221 input_offset_x(in_offset_x),
00222 input_offset_y(in_offset_y),
00223 input_scale_x(in_scale_x),
00224 input_scale_y(in_scale_y),
00225 input_rotation_angle(in_rotation_angle),
00226 cos_a(cos(in_rotation_angle)),
00227 sin_a(sin(in_rotation_angle)),
00228 output_scale(out_scale),
00229 output_offset(out_offset){
00230 }
00231
00232 Base_2D::~Base_2D(){
00233 }
00234
00235 Base_2D::real_type Base_2D::operator()(const real_type x,
00236 const real_type y) const{
00237
00238
00239 const real_type off_x = x + input_offset_x;
00240 const real_type off_y = y + input_offset_y;
00241
00242 const real_type input_x = (off_x*cos_a + off_y*sin_a)*input_scale_x;
00243 const real_type input_y =(-off_x*sin_a + off_y*cos_a)*input_scale_y;
00244
00245 return base_value_proxy(input_x,input_y)*output_scale + output_offset;
00246 }
00247
00248 void Base_2D::update_input_rotation(const real_type a){
00249 input_rotation_angle = a;
00250 cos_a = cos(input_rotation_angle);
00251 sin_a = sin(input_rotation_angle);
00252 }
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264 Direct_interface_2D::Direct_interface_2D(const real_type in_offset_x,
00265 const real_type in_offset_y,
00266 const real_type in_scale_x,
00267 const real_type in_scale_y,
00268 const real_type in_rotation_angle,
00269 const real_type out_offset,
00270 const real_type out_scale):
00271 Base_2D(in_offset_x,in_offset_y,
00272 in_scale_x,in_scale_y,
00273 in_rotation_angle,
00274 out_offset,out_scale){}
00275
00276
00277
00278 void Direct_interface_2D::set_input_offset(const real_type x,
00279 const real_type y){
00280
00281 input_offset_x = x;
00282 input_offset_y = y;
00283 }
00284
00285 void Direct_interface_2D::set_input_scale(const real_type x,
00286 const real_type y){
00287
00288 input_scale_x = x;
00289 input_scale_y = y;
00290 }
00291
00292 void Direct_interface_2D::set_input_rotation(const real_type a){
00293
00294 update_input_rotation(a);
00295 }
00296
00297 void Direct_interface_2D::set_output_scale(const real_type s){
00298
00299 output_scale = s;
00300 }
00301
00302 void Direct_interface_2D::set_output_offset(const real_type o){
00303
00304 output_offset = o;
00305 }
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 Filter_interface_2D::Filter_interface_2D(const real_type center_x,
00319 const real_type center_y,
00320 const real_type sigma_x,
00321 const real_type sigma_y,
00322 const real_type sig_scale_x,
00323 const real_type sig_scale_y,
00324 const real_type orientation_angle,
00325 const real_type out_sigma_scale):
00326 Base_2D(-center_x,-center_y,
00327 sig_scale_x/sigma_x,
00328 sig_scale_y/sigma_y,
00329 -orientation_angle,
00330 0,
00331 out_sigma_scale/(sigma_x*sigma_y)),
00332 sigma_scale_x(sig_scale_x),
00333 sigma_scale_y(sig_scale_y),
00334 output_sigma_scale(out_sigma_scale){
00335 }
00336
00337
00338 void Filter_interface_2D::set_center(const real_type x,const real_type y){
00339
00340 input_offset_x = -x;
00341 input_offset_y = -y;
00342 }
00343
00344 void Filter_interface_2D::set_orientation(const real_type o){
00345
00346 update_input_rotation(-o);
00347 }
00348
00349 void Filter_interface_2D::set_sigma(const real_type x,const real_type y){
00350
00351 input_scale_x = sigma_scale_x / x;
00352 input_scale_y = sigma_scale_y / y;
00353 output_scale = output_sigma_scale / (x*y);
00354 }
00355
00356
00357 }
00358
00359 #endif