27 |
|
#define wscan(y) (ourweigh+(y)*hresolu) |
28 |
|
#define zscan(y) (ourzbuf+(y)*hresolu) |
29 |
|
#define averaging (ourweigh != NULL) |
30 |
+ |
#define usematrix (hasmatrix & !averaging) |
31 |
+ |
#define zisnorm (!usematrix | ourview.type != VT_PER) |
32 |
|
|
33 |
|
#define MAXWT 1000. /* maximum pixel weight (averaging) */ |
34 |
|
|
69 |
|
COLR backcolr = BLKCOLR; /* background color */ |
70 |
|
COLOR backcolor = BLKCOLOR; /* background color (float) */ |
71 |
|
double backz = 0.0; /* background z value */ |
72 |
< |
int normdist = 1; /* normalized distance? */ |
72 |
> |
int normdist = 1; /* i/o normalized distance? */ |
73 |
|
double ourexp = -1; /* original picture exposure */ |
74 |
|
int expadj = 0; /* exposure adjustment (f-stops) */ |
75 |
|
double rexpadj = 1; /* real exposure adjustment */ |
586 |
|
|
587 |
|
if (pos[2] <= 0) /* empty pixel */ |
588 |
|
return(0); |
589 |
< |
if (!averaging && hasmatrix) { |
589 |
> |
if (usematrix) { |
590 |
|
pos[0] += theirview.hoff - .5; |
591 |
|
pos[1] += theirview.voff - .5; |
592 |
+ |
if (normdist && theirview.type == VT_PER) |
593 |
+ |
d = sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
594 |
+ |
+ pos[1]*pos[1]*theirview.vn2); |
595 |
+ |
else |
596 |
+ |
d = 1.; |
597 |
+ |
pos[2] += d*theirview.vfore; |
598 |
|
if (theirview.type == VT_PER) { |
599 |
< |
if (normdist) /* adjust distance */ |
592 |
< |
pos[2] /= sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
593 |
< |
+ pos[1]*pos[1]*theirview.vn2); |
599 |
> |
pos[2] /= d; |
600 |
|
pos[0] *= pos[2]; |
601 |
|
pos[1] *= pos[2]; |
602 |
|
} |
603 |
|
multp3(pos, pos, theirs2ours); |
604 |
< |
if (pos[2] <= 0) |
604 |
> |
if (pos[2] <= ourview.vfore) |
605 |
|
return(0); |
606 |
|
if (ourview.type == VT_PER) { |
607 |
|
pos[0] /= pos[2]; |
609 |
|
} |
610 |
|
pos[0] += .5 - ourview.hoff; |
611 |
|
pos[1] += .5 - ourview.voff; |
612 |
+ |
pos[2] -= ourview.vfore; |
613 |
|
} else { |
614 |
|
if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY) |
615 |
|
return(0); |
616 |
< |
if (!normdist && theirview.type == VT_PER) /* adjust */ |
616 |
> |
if (!normdist & theirview.type == VT_PER) /* adjust */ |
617 |
|
pos[2] *= sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
618 |
|
+ pos[1]*pos[1]*theirview.vn2); |
619 |
|
pt[0] += tdir[0]*pos[2]; |
846 |
|
clipaft() /* perform aft clipping as indicated */ |
847 |
|
{ |
848 |
|
register int x, y; |
849 |
+ |
int adjtest = ourview.type == VT_PER & zisnorm; |
850 |
|
double tstdist; |
851 |
|
double yzn2, vx; |
852 |
|
|
854 |
|
return; |
855 |
|
tstdist = ourview.vaft - ourview.vfore; |
856 |
|
for (y = 0; y < vresolu; y++) { |
857 |
< |
if (ourview.type == VT_PER) { /* adjust distance */ |
857 |
> |
if (adjtest) { /* adjust test */ |
858 |
|
yzn2 = (y+.5)/vresolu + ourview.voff - .5; |
859 |
|
yzn2 = 1. + yzn2*yzn2*ourview.vn2; |
860 |
|
tstdist = (ourview.vaft - ourview.vfore)*sqrt(yzn2); |
861 |
|
} |
862 |
|
for (x = 0; x < hresolu; x++) |
863 |
|
if (zscan(y)[x] > tstdist) { |
864 |
< |
if (ourview.type == VT_PER) { |
864 |
> |
if (adjtest) { |
865 |
|
vx = (x+.5)/hresolu + ourview.hoff - .5; |
866 |
|
if (zscan(y)[x] <= (ourview.vaft - |
867 |
|
ourview.vfore) * |
902 |
|
} |
903 |
|
|
904 |
|
|
905 |
< |
writedistance(fname) /* write out z file */ |
905 |
> |
writedistance(fname) /* write out z file (alters buffer) */ |
906 |
|
char *fname; |
907 |
|
{ |
908 |
< |
int donorm = normdist && ourview.type == VT_PER && |
909 |
< |
!averaging && hasmatrix; |
908 |
> |
int donorm = normdist & !zisnorm ? 1 : |
909 |
> |
ourview.type == VT_PER & !normdist & zisnorm ? -1 : 0; |
910 |
|
int fd; |
911 |
|
int y; |
904 |
– |
float *zout; |
912 |
|
|
913 |
|
if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) |
914 |
|
syserror(fname); |
908 |
– |
if (donorm |
909 |
– |
&& (zout = (float *)malloc(hresolu*sizeof(float))) == NULL) |
910 |
– |
syserror(progname); |
915 |
|
for (y = vresolu-1; y >= 0; y--) { |
916 |
|
if (donorm) { |
917 |
< |
double vx, yzn2; |
917 |
> |
double vx, yzn2, d; |
918 |
|
register int x; |
919 |
|
yzn2 = (y+.5)/vresolu + ourview.voff - .5; |
920 |
|
yzn2 = 1. + yzn2*yzn2*ourview.vn2; |
921 |
|
for (x = 0; x < hresolu; x++) { |
922 |
|
vx = (x+.5)/hresolu + ourview.hoff - .5; |
923 |
< |
zout[x] = zscan(y)[x] |
924 |
< |
* sqrt(vx*vx*ourview.hn2 + yzn2); |
923 |
> |
d = sqrt(vx*vx*ourview.hn2 + yzn2); |
924 |
> |
if (donorm > 0) |
925 |
> |
zscan(y)[x] *= d; |
926 |
> |
else |
927 |
> |
zscan(y)[x] /= d; |
928 |
|
} |
929 |
< |
} else |
930 |
< |
zout = zscan(y); |
924 |
< |
if (write(fd, (char *)zout, hresolu*sizeof(float)) |
929 |
> |
} |
930 |
> |
if (write(fd, (char *)zscan(y), hresolu*sizeof(float)) |
931 |
|
< hresolu*sizeof(float)) |
932 |
|
syserror(fname); |
933 |
|
} |
928 |
– |
if (donorm) |
929 |
– |
free((char *)zout); |
934 |
|
close(fd); |
935 |
|
} |
936 |
|
|
1015 |
|
float fbuf[6*(PACKSIZ+1)]; |
1016 |
|
register float *fbp; |
1017 |
|
register int i; |
1018 |
+ |
double vx, vy; |
1019 |
|
|
1020 |
|
if (queuesiz == 0) |
1021 |
|
return; |
1050 |
|
} else |
1051 |
|
setcolr(pscan(queue[i][1])[queue[i][0]], |
1052 |
|
fbp[0], fbp[1], fbp[2]); |
1053 |
< |
zscan(queue[i][1])[queue[i][0]] = fbp[3]; |
1053 |
> |
if (zisnorm) |
1054 |
> |
zscan(queue[i][1])[queue[i][0]] = fbp[3]; |
1055 |
> |
else { |
1056 |
> |
vx = (queue[i][0]+.5)/hresolu + ourview.hoff - .5; |
1057 |
> |
vy = (queue[i][1]+.5)/vresolu + ourview.voff - .5; |
1058 |
> |
zscan(queue[i][1])[queue[i][0]] = fbp[3] / sqrt(1. + |
1059 |
> |
vx*vx*ourview.hn2 + vy*vy*ourview.vn2); |
1060 |
> |
} |
1061 |
|
fbp += 4; |
1062 |
|
} |
1063 |
|
queuesiz = 0; |