--- ray/src/gen/mkillum2.c 1992/08/13 10:03:19 2.4 +++ ray/src/gen/mkillum2.c 1997/07/09 11:24:52 2.8 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1995 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -71,11 +71,12 @@ char *nm; u[0] = VERTEX(fa,i)[0] - VERTEX(fa,j)[0]; u[1] = VERTEX(fa,i)[1] - VERTEX(fa,j)[1]; u[2] = VERTEX(fa,i)[2] - VERTEX(fa,j)[2]; - if (DOT(u,u) >= fa->area-FTINY) + if ((r1 = DOT(u,u)) >= fa->area-FTINY) break; } if (i < fa->nv) { /* got one! -- let's align our axes */ - normalize(u); + r2 = 1.0/sqrt(r1); + u[0] *= r2; u[1] *= r2; u[2] *= r2; fcross(v, fa->norm, u); } else /* oh well, we'll just have to wing it */ mkaxes(u, v, fa->norm); @@ -162,8 +163,8 @@ char *nm; nalt = nazi = 1; else { n = 4.*PI * il->sampdens; - nalt = sqrt(n/PI) + .5; - nazi = PI*nalt + .5; + nalt = sqrt(2./PI*n) + .5; + nazi = PI/2.*nalt + .5; } n = nalt*nazi; distarr = (float *)calloc(n, 3*sizeof(float)); @@ -259,7 +260,7 @@ char *nm; r1 = r3*cos(r2); r2 = r3*sin(r2); for (j = 0; j < 3; j++) - org[j] = CO_P0(co)[j] + r1*u[j] + r1*v[j] + + org[j] = CO_P0(co)[j] + r1*u[j] + r2*v[j] + .001*co->ad[j]; /* send sample */ @@ -305,9 +306,9 @@ register struct rtproc *rt; bzero(rt->buf+6*rt->nrays, 6*sizeof(float)); errno = 0; if ( process(rt->pd, (char *)rt->buf, (char *)rt->buf, - 3*sizeof(float)*rt->nrays, + 3*sizeof(float)*(rt->nrays+1), 6*sizeof(float)*(rt->nrays+1)) < - 3*sizeof(float)*rt->nrays ) + 3*sizeof(float)*(rt->nrays+1) ) error(SYSTEM, "error reading from rtrace process"); i = rt->nrays; while (i--) {