ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pf3.c
(Generate patch)

Comparing ray/src/px/pf3.c (file contents):
Revision 2.2 by greg, Mon Sep 21 12:14:12 1992 UTC vs.
Revision 2.5 by greg, Fri Jun 18 13:36:20 1993 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include  <stdio.h>
14  
15 + #include  <math.h>
16 +
17   #include  "color.h"
18  
19   #define  FTINY          1e-7
# Line 36 | Line 38 | extern COLOR  *scanout;                /* output scan line */
38  
39   extern char  *progname;
40  
41 < float  *exptable;               /* exponent table */
41 > float  *gausstable;             /* gauss lookup table */
42  
43 < #define  lookexp(x)             exptable[(int)(-10.*(x)+.5)]
43 > #define  lookgauss(x)           gausstable[(int)(-10.*(x)+.5)]
44  
45  
46   initmask()                      /* initialize gaussian lookup table */
47   {
48          extern char  *malloc();
49 <        extern double  exp();
49 >        double  d;
50          register int  x;
51  
52 <        exptable = (float *)malloc(100*sizeof(float));
53 <        if (exptable == NULL) {
52 >        gausstable = (float *)malloc(100*sizeof(float));
53 >        if (gausstable == NULL) {
54                  fprintf(stderr, "%s: out of memory in initmask\n", progname);
55                  quit(1);
56          }
57 <        for (x = 0; x < 100; x++)
58 <                exptable[x] = exp(-x*0.1);
57 >        d = x_c*y_r*0.25/rad/rad;
58 >        gausstable[0] = exp(-d)/sqrt(d);
59 >        for (x = 1; x < 100; x++)
60 >                if ((gausstable[x] = exp(-x*0.1)/sqrt(x*0.1)) > gausstable[0])
61 >                        gausstable[x] = gausstable[0];
62   }
63  
64  
# Line 71 | Line 76 | int  c, r;
76          wsum = 0;
77          setcolor(csum, 0.0, 0.0, 0.0);
78          for (y = ycent+1-yrad; y <= ycent+yrad; y++) {
79 <                if (y < 0 || y >= yres)
80 <                        continue;
81 <                d = y_r < 1.0 ? y_r*y - r : y - ycent;
79 >                if (y < 0) continue;
80 >                if (y >= yres) break;
81 >                d = y_r < 1.0 ? y_r*y - r : (double)(y - ycent);
82                  if (d > 0.5+FTINY || d < -0.5-FTINY)
83                          continue;
84                  scan = scanin[y%barsize];
85                  for (x = xcent+1-xrad; x <= xcent+xrad; x++) {
86 <                        if (x < 0 || x >= xres)
87 <                                continue;
88 <                        d = x_c < 1.0 ? x_c*x - c : x - xcent;
86 >                        if (x < 0) continue;
87 >                        if (x >= xres) break;
88 >                        d = x_c < 1.0 ? x_c*x - c : (double)(x - xcent);
89                          if (d > 0.5+FTINY || d < -0.5-FTINY)
90                                  continue;
91                          wsum++;
# Line 106 | Line 111 | int  c, r;
111          wsum = FTINY;
112          setcolor(csum, 0.0, 0.0, 0.0);
113          for (y = ycent-yrad; y <= ycent+yrad; y++) {
114 <                if (y < 0 || y >= yres)
115 <                        continue;
114 >                if (y < 0) continue;
115 >                if (y >= yres) break;
116                  dy = (y_r*(y+.5) - (r+.5))/rad;
117                  scan = scanin[y%barsize];
118                  for (x = xcent-xrad; x <= xcent+xrad; x++) {
119 <                        if (x < 0 || x >= xres)
120 <                                continue;
119 >                        if (x < 0) continue;
120 >                        if (x >= xres) break;
121                          dx = (x_c*(x+.5) - (c+.5))/rad;
122 <                        weight = lookexp(-(dx*dx + dy*dy));
122 >                        weight = lookgauss(-(dx*dx + dy*dy));
123                          wsum += weight;
124                          copycolor(ctmp, scan[x]);
125                          scalecolor(ctmp, weight);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines