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

Comparing ray/src/rt/srcsupp.c (file contents):
Revision 1.4 by greg, Fri Jun 21 16:44:01 1991 UTC vs.
Revision 1.7 by greg, Tue Jun 25 15:34:17 1991 UTC

# Line 105 | Line 105 | register OBJREC  *so;
105          theta = PI/180.0/2.0 * so->oargs.farg[3];
106          if (theta <= FTINY)
107                  objerror(so, USER, "zero size");
108 <        src->ss = theta >= PI/4 ? 1.0 : tan(theta);
108 >        src->ss = theta >= PI/4.0 ? 1.0 : tan(theta);
109          src->ss2 = 2.0*PI * (1.0 - cos(theta));
110   }
111  
# Line 168 | Line 168 | FVECT  ocent;
168   OBJREC  *op;
169   {
170          double  maxrad2;
171 <        double  d2;
171 >        double  d;
172          register int  i, j;
173          register FACE  *f;
174          
175          f = getface(op);
176 +        if (f->area == 0.)
177 +                return(0.);
178          for (i = 0; i < 3; i++) {
179                  ocent[i] = 0.;
180                  for (j = 0; j < f->nv; j++)
181                          ocent[i] += VERTEX(f,j)[i];
182                  ocent[i] /= (double)f->nv;
183          }
184 <        if (f->area == 0.)
185 <                return(0.);
184 >        d = DOT(ocent,f->norm);
185 >        for (i = 0; i < 3; i++)
186 >                ocent[i] += (f->offset - d)*f->norm[i];
187          maxrad2 = 0.;
188          for (j = 0; j < f->nv; j++) {
189 <                d2 = dist2(VERTEX(f,j), ocent);
190 <                if (d2 > maxrad2)
191 <                        maxrad2 = d2;
189 >                d = dist2(VERTEX(f,j), ocent);
190 >                if (d > maxrad2)
191 >                        maxrad2 = d;
192          }
193          return(maxrad2);
194   }
# Line 289 | Line 292 | FVECT  nrm;            /* source surface normal */
292                                          /* else check horizon */
293          d1 = 1. - sp->siz/(2.*PI);
294          return(1.-FTINY-d*d > d1*d1);
295 + }
296 +
297 +
298 + double
299 + spotdisk(oc, op, sp, pos)       /* intersect spot with object op */
300 + FVECT  oc;
301 + OBJREC  *op;
302 + register SPOT  *sp;
303 + FVECT  pos;
304 + {
305 +        FVECT  onorm;
306 +        double  offs, d, dist;
307 +        register int  i;
308 +
309 +        offs = getplaneq(onorm, op);
310 +        d = -DOT(onorm, sp->aim);
311 +        if (d >= -FTINY && d <= FTINY)
312 +                return(0.);
313 +        dist = (DOT(pos, onorm) - offs)/d;
314 +        if (dist < 0.)
315 +                return(0.);
316 +        for (i = 0; i < 3; i++)
317 +                oc[i] = pos[i] + dist*sp->aim[i];
318 +        return(sp->siz*dist*dist/PI/(d*d));
319 + }
320 +
321 +
322 + double
323 + beamdisk(oc, op, sp, dir)       /* intersect beam with object op */
324 + FVECT  oc;
325 + OBJREC  *op;
326 + register SPOT  *sp;
327 + FVECT  dir;
328 + {
329 +        FVECT  onorm;
330 +        double  offs, d, dist;
331 +        register int  i;
332 +
333 +        offs = getplaneq(onorm, op);
334 +        d = -DOT(onorm, dir);
335 +        if (d >= -FTINY && d <= FTINY)
336 +                return(0.);
337 +        dist = (DOT(sp->aim, onorm) - offs)/d;
338 +        for (i = 0; i < 3; i++)
339 +                oc[i] = sp->aim[i] + dist*dir[i];
340 +        return(sp->siz/PI/(d*d));
341   }
342  
343  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines