207 |
|
char *sfile |
208 |
|
) |
209 |
|
{ |
210 |
+ |
int warnedneg; |
211 |
|
char linebuf[8192]; |
212 |
|
int nelem = 1000; |
213 |
|
float *sarr = (float *)malloc(sizeof(float)*nelem); |
244 |
|
} |
245 |
|
++ntp[1]; |
246 |
|
} |
247 |
+ |
warnedneg = 0; |
248 |
|
ntp[0] = 0; /* get thetas + data */ |
249 |
|
while (fgets(linebuf, sizeof(linebuf), fp) != NULL) { |
250 |
|
++ntp[0]; |
262 |
|
cp = fskip(cp); |
263 |
|
if (cp == NULL) |
264 |
|
break; |
265 |
+ |
if (i && sarr[i] < .0) { |
266 |
+ |
if (!warnedneg++) { |
267 |
+ |
sprintf(errmsg, |
268 |
+ |
"Negative value(s) in sensor file '%s' (ignored)\n", sfile); |
269 |
+ |
error(WARNING, errmsg); |
270 |
+ |
} |
271 |
+ |
sarr[i] = .0; |
272 |
+ |
} |
273 |
|
++i; |
274 |
|
} |
275 |
|
if (i == ntp[0]*(ntp[1]+1)) |
398 |
|
tvals[i] = 1. - ( (1.-frac)*cos(thdiv[t]) + |
399 |
|
frac*cos(thdiv[t+1]) ); |
400 |
|
/* offset b/c sensor values are centered */ |
401 |
< |
if (t <= 0 || frac > 0.5) |
401 |
> |
if (!t || (t < sntp[0]-1) & (frac >= 0.5)) |
402 |
|
frac -= 0.5; |
403 |
< |
else if (t >= sntp[0]-1 || frac < 0.5) { |
403 |
> |
else { |
404 |
|
frac += 0.5; |
405 |
|
--t; |
406 |
|
} |
413 |
|
if ((prob -= (1.-frac)*rowp[p]/rowsum[t] + |
414 |
|
frac*rowp1[p]/rowsum[t+1]) <= .0) |
415 |
|
break; |
416 |
< |
if (p >= sntp[1]) { |
416 |
> |
if (p >= sntp[1]) { /* should never happen? */ |
417 |
|
p = sntp[1] - 1; |
418 |
|
prob = .5; |
419 |
|
} |
470 |
|
int t, p; |
471 |
|
|
472 |
|
dv[2] = DOT(dvec, ourview.vdir); |
473 |
< |
theta = (float)((1./DEGREE) * acos(dv[2])); |
473 |
> |
theta = acos(dv[2]); |
474 |
|
if (theta >= maxtheta) |
475 |
|
return(.0f); |
476 |
|
dv[0] = DOT(dvec, ourview.hvec); |
477 |
|
dv[1] = DOT(dvec, ourview.vvec); |
478 |
< |
phi = (float)((1./DEGREE) * atan2(-dv[0], dv[1])); |
479 |
< |
while (phi < .0f) phi += 360.f; |
478 |
> |
phi = atan2(-dv[0], dv[1]); |
479 |
> |
while (phi < .0f) phi += (float)(2.*PI); |
480 |
|
t = (int)(theta/maxtheta * sntp[0]); |
481 |
< |
p = (int)(phi*(1./360.) * sntp[1]); |
481 |
> |
p = (int)(phi*(1./(2.*PI)) * sntp[1]); |
482 |
|
/* hack for non-uniform sensor grid */ |
483 |
+ |
theta *= (float)(1./DEGREE); |
484 |
+ |
phi *= (float)(1./DEGREE); |
485 |
|
while (t+1 < sntp[0] && theta >= s_theta(t+1)) |
486 |
|
++t; |
487 |
|
while (t-1 >= 0 && theta <= s_theta(t-1)) |