| 15 |
|
|
| 16 |
|
#define DEGREE (PI/180.) |
| 17 |
|
|
| 18 |
< |
#define MAXNT 180 /* maximum number of theta divisions */ |
| 18 |
> |
#define MAXNT 181 /* maximum number of theta divisions */ |
| 19 |
|
#define MAXNP 360 /* maximum number of phi divisions */ |
| 20 |
|
|
| 21 |
|
extern char *progname; /* global argv[0] */ |
| 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 || (t < sntp[0]-1) & (frac >= 0.5)) |
| 401 |
> |
if ((t < sntp[0]-1) & (!t | (frac >= 0.5))) { |
| 402 |
|
frac -= 0.5; |
| 403 |
< |
else { |
| 403 |
> |
} else { |
| 404 |
|
frac += 0.5; |
| 405 |
|
--t; |
| 406 |
|
} |
| 424 |
|
} |
| 425 |
|
pvals[i*(nphi+1) + nphi] = phdiv[sntp[1]]; |
| 426 |
|
} |
| 427 |
+ |
/* duplicate final row */ |
| 428 |
+ |
memcpy(pvals+ntheta*(nphi+1), pvals+(ntheta-1)*(nphi+1), |
| 429 |
+ |
sizeof(*pvals)*(nphi+1)); |
| 430 |
|
tvals[0] = .0f; |
| 431 |
|
tvals[ntheta] = (float)tsize; |
| 432 |
|
} |
| 473 |
|
int t, p; |
| 474 |
|
|
| 475 |
|
dv[2] = DOT(dvec, ourview.vdir); |
| 476 |
< |
theta = (float)((1./DEGREE) * acos(dv[2])); |
| 476 |
> |
theta = acos(dv[2]); |
| 477 |
|
if (theta >= maxtheta) |
| 478 |
|
return(.0f); |
| 479 |
|
dv[0] = DOT(dvec, ourview.hvec); |
| 480 |
|
dv[1] = DOT(dvec, ourview.vvec); |
| 481 |
< |
phi = (float)((1./DEGREE) * atan2(-dv[0], dv[1])); |
| 482 |
< |
while (phi < .0f) phi += 360.f; |
| 481 |
> |
phi = atan2(-dv[0], dv[1]); |
| 482 |
> |
while (phi < .0f) phi += (float)(2.*PI); |
| 483 |
|
t = (int)(theta/maxtheta * sntp[0]); |
| 484 |
< |
p = (int)(phi*(1./360.) * sntp[1]); |
| 484 |
> |
p = (int)(phi*(1./(2.*PI)) * sntp[1]); |
| 485 |
|
/* hack for non-uniform sensor grid */ |
| 486 |
+ |
theta *= (float)(1./DEGREE); |
| 487 |
+ |
phi *= (float)(1./DEGREE); |
| 488 |
|
while (t+1 < sntp[0] && theta >= s_theta(t+1)) |
| 489 |
|
++t; |
| 490 |
|
while (t-1 >= 0 && theta <= s_theta(t-1)) |
| 547 |
|
continue; |
| 548 |
|
} |
| 549 |
|
rr.rmax = .0; |
| 550 |
< |
rayorigin(&rr, PRIMARY, NULL, NULL); |
| 550 |
> |
rayorigin(&rr, PRIMARY|SPECULAR, NULL, NULL); |
| 551 |
|
scalecolor(rr.rcoef, sf); |
| 552 |
|
if (ray_pqueue(&rr) == 1) |
| 553 |
|
addcolor(vsum, rr.rcol); |
| 563 |
|
continue; |
| 564 |
|
} |
| 565 |
|
rr.rmax = .0; |
| 566 |
< |
rayorigin(&rr, PRIMARY, NULL, NULL); |
| 566 |
> |
rayorigin(&rr, PRIMARY|SPECULAR, NULL, NULL); |
| 567 |
|
scalecolor(rr.rcoef, sf); |
| 568 |
|
if (ray_pqueue(&rr) == 1) |
| 569 |
|
addcolor(vsum, rr.rcol); |