paramDistortion.c
Go to the documentation of this file.
00001 /*******************************************************
00002  *
00003  * Author: Hirokazu Kato
00004  *
00005  *         kato@sys.im.hiroshima-cu.ac.jp
00006  *
00007  * Revision: 2.1
00008  * Date: 99/07/16
00009  *
00010 *******************************************************/
00011 
00012 #include <stdio.h>
00013 #include <math.h>
00014 #include <AR/param.h>
00015 
00016 #define  PD_LOOP   3
00017 
00018 int arParamObserv2Ideal( const double dist_factor[4], const double ox, const double oy,
00019                          double *ix, double *iy )
00020 {
00021     double  z02, z0, p, q, z, px, py;
00022     int     i;
00023 
00024     px = ox - dist_factor[0];
00025     py = oy - dist_factor[1];
00026     p = dist_factor[2]/100000000.0;
00027     z02 = px*px+ py*py;
00028     q = z0 = sqrt(px*px+ py*py);
00029 
00030     for( i = 1; ; i++ ) {
00031         if( z0 != 0.0 ) {
00032             z = z0 - ((1.0 - p*z02)*z0 - q) / (1.0 - 3.0*p*z02);
00033             px = px * z / z0;
00034             py = py * z / z0;
00035         }
00036         else {
00037             px = 0.0;
00038             py = 0.0;
00039             break;
00040         }
00041         if( i == PD_LOOP ) break;
00042 
00043         z02 = px*px+ py*py;
00044         z0 = sqrt(px*px+ py*py);
00045     }
00046 
00047     *ix = px / dist_factor[3] + dist_factor[0];
00048     *iy = py / dist_factor[3] + dist_factor[1];
00049 
00050     return(0);
00051 }
00052 
00053 int arParamIdeal2Observ( const double dist_factor[4], const double ix, const double iy,
00054                          double *ox, double *oy )
00055 {
00056     double    x, y, d;
00057 
00058     x = (ix - dist_factor[0]) * dist_factor[3];
00059     y = (iy - dist_factor[1]) * dist_factor[3];
00060     if( x == 0.0 && y == 0.0 ) {
00061         *ox = dist_factor[0];
00062         *oy = dist_factor[1];
00063     }
00064     else {
00065         d = 1.0 - dist_factor[2]/100000000.0 * (x*x+y*y);
00066         *ox = x * d + dist_factor[0];
00067         *oy = y * d + dist_factor[1];
00068     }
00069 
00070     return(0);
00071 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


ar_recog
Author(s): Graylin Trevor Jay and Christopher Crick
autogenerated on Fri Jan 25 2013 12:15:00