FACT++  1.0
void palUnpcd ( double  disco,
double *  x,
double *  y 
)

Definition at line 119 of file palUnpcd.c.

References COPYSIGN, DMIN, PAL__D2PI, t, and telData::w.

Referenced by t_pcd().

119  {
120 
121  const double THIRD = 1.0/3.0;
122 
123  double rp,q,r,d,w,s,t,f,c,t3,f1,f2,f3,w1,w2,w3;
124  double c2;
125 
126  /* Distance of the point from the origin. */
127  rp = sqrt( (*x)*(*x)+(*y)*(*y));
128 
129  /* If zero, or if no distortion, no action is necessary. */
130  if (rp != 0.0 && disco != 0.0) {
131 
132  /* Begin algebraic solution. */
133  q = 1.0/(3.0*disco);
134  r = rp/(2.0*disco);
135  w = q*q*q+r*r;
136 
137  /* Continue if one real root, or three of which only one is positive. */
138  if (w > 0.0) {
139 
140  d = sqrt(w);
141  w = r+d;
142  s = COPYSIGN(pow(fabs(w),THIRD),w);
143  w = r-d;
144  t = COPYSIGN(pow(fabs(w),THIRD),w);
145  f = s+t;
146 
147  } else {
148  /* Three different real roots: use geometrical method instead. */
149  w = 2.0/sqrt(-3.0*disco);
150  c = 4.0*rp/(disco*w*w*w);
151  c2 = c*c;
152  s = sqrt(1.0-DMIN(c2,1.0));
153  t3 = atan2(s,c);
154 
155  /* The three solutions. */
156  f1 = w*cos((PAL__D2PI-t3)/3.0);
157  f2 = w*cos((t3)/3.0);
158  f3 = w*cos((PAL__D2PI+t3)/3.0);
159 
160  /* Pick the one that moves [X,Y] least. */
161  w1 = fabs(f1-rp);
162  w2 = fabs(f2-rp);
163  w3 = fabs(f3-rp);
164  if (w1 < w2) {
165  f = ( w1 < w3 ? f1 : f3 );
166  } else {
167  f = ( w2 < w3 ? f2 : f3 );
168  }
169  }
170 
171  /* Remove the distortion. */
172  f = f/rp;
173  *x *= f;
174  *y *= f;
175  }
176 }
#define DMIN(A, B)
Definition: palmac.h:129
double w
Definition: palObs.c:168
#define COPYSIGN(a, b)
Definition: palUnpcd.c:116
TT t
Definition: test_client.c:26
static const double PAL__D2PI
Definition: palmac.h:66

+ Here is the caller graph for this function: