--- ray/src/px/pf3.c 1989/02/02 10:49:26 1.1 +++ ray/src/px/pf3.c 1992/10/02 16:23:41 2.3 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -12,9 +12,11 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#include + #include "color.h" -#define FTINY 1e-7 +#define FTINY 1e-7 extern double rad; /* output pixel radius for filtering */ @@ -38,13 +40,12 @@ extern char *progname; float *exptable; /* exponent table */ -#define lookexp(x) exptable[(int)(-10.*(x)+.5)] +#define lookexp(x) exptable[(int)(-10.*(x)+.5)] initmask() /* initialize gaussian lookup table */ { extern char *malloc(); - extern double exp(); register int x; exptable = (float *)malloc(100*sizeof(float)); @@ -66,7 +67,7 @@ int c, r; static double d; static int y; register int x; - register COLOR *scan; + register COLOR *scan; wsum = 0; setcolor(csum, 0.0, 0.0, 0.0); @@ -101,19 +102,19 @@ int c, r; static COLOR ctmp; static int y; register int x; - register COLOR *scan; + register COLOR *scan; wsum = FTINY; setcolor(csum, 0.0, 0.0, 0.0); - for (y = ycent+1-yrad; y <= ycent+yrad; y++) { + for (y = ycent-yrad; y <= ycent+yrad; y++) { if (y < 0 || y >= yres) continue; - dy = (y_r*y - r)/rad; + dy = (y_r*(y+.5) - (r+.5))/rad; scan = scanin[y%barsize]; - for (x = xcent+1-xrad; x <= xcent+xrad; x++) { + for (x = xcent-xrad; x <= xcent+xrad; x++) { if (x < 0 || x >= xres) continue; - dx = (x_c*x - c)/rad; + dx = (x_c*(x+.5) - (c+.5))/rad; weight = lookexp(-(dx*dx + dy*dy)); wsum += weight; copycolor(ctmp, scan[x]);