29 |
|
FILE *fp; /* stream pointer */ |
30 |
|
VIEW vw; /* view for picture */ |
31 |
|
RESOLU rs; /* image resolution and orientation */ |
32 |
+ |
float pa; /* pixel aspect ratio */ |
33 |
|
COLOR *scan[WINSIZ]; /* input scanline window */ |
34 |
|
COLOR coef; /* coefficient */ |
35 |
|
COLOR expos; /* recorded exposure */ |
49 |
|
|
50 |
|
char vray[6][4] = {"Ox", "Oy", "Oz", "Dx", "Dy", "Dz"}; |
51 |
|
|
52 |
+ |
char vpsize[] = "S"; |
53 |
+ |
|
54 |
|
char vnfiles[] = "nfiles"; |
55 |
|
char vxmax[] = "xmax"; |
56 |
|
char vymax[] = "ymax"; |
117 |
|
setcolor(input[nfiles].coef, 1.0, 1.0, 1.0); |
118 |
|
setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); |
119 |
|
copystruct(&input[nfiles].vw, &stdview); |
120 |
+ |
input[nfiles].pa = 1.0; |
121 |
|
} |
122 |
|
nfiles = 0; |
123 |
|
original = 0; |
248 |
|
} else if (iscolcor(s)) { /* color correction */ |
249 |
|
colcorval(ctmp, s); |
250 |
|
multcolor(input[nfiles].expos, ctmp); |
251 |
+ |
} else if (isaspect(s)) { |
252 |
+ |
input[nfiles].pa *= aspectval(s); |
253 |
|
} else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0) |
254 |
|
gotview++; |
255 |
|
/* echo line */ |
314 |
|
|
315 |
|
init() /* perform final setup */ |
316 |
|
{ |
317 |
< |
double l_colin(), l_expos(), l_ray(); |
317 |
> |
double l_colin(), l_expos(), l_ray(), l_psize(); |
318 |
|
register int i; |
319 |
|
/* define constants */ |
320 |
|
varset(vnfiles, ':', (double)nfiles); |
329 |
|
funset(vbrtin, 1, '=', l_colin); |
330 |
|
for (i = 0; i < 6; i++) |
331 |
|
funset(vray[i], 1, '=', l_ray); |
332 |
+ |
funset(vpsize, 1, '=', l_psize); |
333 |
|
/* set brightness function */ |
334 |
|
if (!strcmp(ourfmt, CIEFMT)) |
335 |
|
ourbright = xyz_bright; |
528 |
|
if (viewray(lorg[fn], ldir[fn], |
529 |
|
&input[fn].vw, loc[0], loc[1]) < 0) |
530 |
|
errno = ERANGE; |
531 |
+ |
ltick[fn] = eclock; |
532 |
|
} |
525 |
– |
ltick[fn] = eclock; |
533 |
|
} |
534 |
|
i = 6; |
535 |
|
while (i--) |
537 |
|
return(i < 3 ? lorg[fn][i] : ldir[fn][i-3]); |
538 |
|
eputs("Bad call to l_ray()!\n"); |
539 |
|
quit(1); |
540 |
+ |
} |
541 |
+ |
|
542 |
+ |
|
543 |
+ |
double |
544 |
+ |
l_psize() /* compute pixel size in steradians */ |
545 |
+ |
{ |
546 |
+ |
static unsigned long ltick[MAXINP]; |
547 |
+ |
static double psize[MAXINP]; |
548 |
+ |
FVECT dir0, org1, dir1; |
549 |
+ |
FLOAT loc[2]; |
550 |
+ |
double d; |
551 |
+ |
int fn; |
552 |
+ |
|
553 |
+ |
d = argument(1); |
554 |
+ |
if (d > -.5 && d < .5) |
555 |
+ |
return((double)nfiles); |
556 |
+ |
fn = d - .5; |
557 |
+ |
if (fn < 0 || fn >= nfiles) { |
558 |
+ |
errno = EDOM; |
559 |
+ |
return(0.0); |
560 |
+ |
} |
561 |
+ |
if (ltick[fn] < eclock) /* need to compute? */ |
562 |
+ |
if (input[fn].vw.type == 0 || input[fn].vw.type == VT_PAR) |
563 |
+ |
errno = EDOM; |
564 |
+ |
else { |
565 |
+ |
errno = 0; |
566 |
+ |
dir0[0] = funvalue(vray[3], 1, &d); |
567 |
+ |
if (errno) |
568 |
+ |
return(0.0); |
569 |
+ |
dir0[1] = funvalue(vray[4], 1, &d); |
570 |
+ |
if (errno) |
571 |
+ |
return(0.0); |
572 |
+ |
dir0[2] = funvalue(vray[5], 1, &d); |
573 |
+ |
if (errno) |
574 |
+ |
return(0.0); |
575 |
+ |
pix2loc(loc, &input[fn].rs, xscan+1, ymax-yscan); |
576 |
+ |
psize[fn] = 0.0; |
577 |
+ |
if (viewray(org1, dir1, |
578 |
+ |
&input[fn].vw, loc[0], loc[1]) < 0) |
579 |
+ |
errno = ERANGE; |
580 |
+ |
else { |
581 |
+ |
/* approximate solid angle */ |
582 |
+ |
psize[fn] = dist2(dir0, dir1) * input[fn].pa / |
583 |
+ |
(1.0 + input[fn].pa*input[fn].pa); |
584 |
+ |
ltick[fn] = eclock; |
585 |
+ |
} |
586 |
+ |
} |
587 |
+ |
return(psize[fn]); |
588 |
|
} |
589 |
|
|
590 |
|
|