--- ray/src/px/pcond4.c 1996/10/04 16:10:43 3.3 +++ ray/src/px/pcond4.c 1996/10/05 08:05:27 3.6 @@ -99,8 +99,11 @@ compveil() /* compute veiling image */ t2 = DOT(rdirscan(py)[px], rdirscan(y)[x]); if (t2 <= FTINY) continue; + /* use approximation instead t2 = acos(t2); t2 = 1./(t2*t2); + */ + t2 = .5 / (1. - t2); copycolor(ctmp, fovscan(y)[x]); scalecolor(ctmp, t2); addcolor(vsum, ctmp); @@ -177,7 +180,12 @@ double La; }; double l10La; register int i; - /* interpolate/extrapolate data */ + /* check limits */ + if (La <= 7.85e-4) + return(resfreq[0]); + if (La >= 1.78e3) + return(resfreq[NPOINTS-1]); + /* interpolate data */ l10La = log10(La); for (i = 0; i < NPOINTS-2 && l10lum[i+1] <= l10La; i++) ; @@ -196,11 +204,8 @@ int y; register COLOR *sl0, *sl1, *mysl; register int i; - if (y < sb->nread - sb->nscans) { - fprintf(stderr, "%s: internal - cannot backspace in getascan\n", - progname); - exit(1); - } + if (y < sb->nread - sb->nscans) /* too far back? */ + return(NULL); for ( ; y >= sb->nread; sb->nread++) { /* read as necessary */ mysl = bscan(sb, sb->nread); if (sb->sampr == 1) { @@ -211,6 +216,8 @@ int y; } } else { sl0 = getascan(sb->next, 2*y); + if (sl0 == NULL) + return(NULL); sl1 = getascan(sb->next, 2*y+1); for (i = 0; i < sb->len; i++) { copycolor(mysl[i], sl0[2*i]); @@ -283,6 +290,12 @@ SCANBAR *sb; double dx, dy; int ix, iy; + if (sb->sampr == 1) { /* no need to interpolate */ + sl0 = getascan(sb, y); + copycolor(col, sl0[x]); + return; + } + /* compute coordinates for sb */ ix = dx = (x+.5)/sb->sampr - .5; if (ix >= sb->len-1) ix--; dx -= (double)ix; @@ -291,6 +304,11 @@ SCANBAR *sb; dy -= (double)iy; /* get scanlines */ sl0 = getascan(sb, iy); + if (sl0 == NULL) { + fprintf(stderr, "%s: internal - cannot backspace in ascanval\n", + progname); + exit(1); + } sl1 = getascan(sb, iy+1); /* 2D linear interpolation */ copycolor(col, sl0[ix]); @@ -355,9 +373,10 @@ initacuity() /* initialize variable acuity sampling } fcross(cp, diffx, diffy); omega = 0.5 * sqrt(DOT(cp,cp)); - tsampr(x,y) = PI/180. / sqrt(omega) / - hacuity(plum(fovscan(y)[x])); - if (tsampr(x,y) > maxsr) + if (omega <= FTINY) + tsampr(x,y) = 1.; + else if ((tsampr(x,y) = PI/180. / sqrt(omega) / + hacuity(plum(fovscan(y)[x]))) > maxsr) maxsr = tsampr(x,y); } /* copy perimeter (easier) */