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

Comparing ray/src/rt/sphere.c (file contents):
Revision 1.5 by greg, Wed Oct 23 13:43:48 1991 UTC vs.
Revision 2.6 by schorsch, Thu Jun 26 00:58:10 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  sphere.c - compute ray intersection with spheres.
9 *
10 *     8/19/85
6   */
7  
8 + #include "copyright.h"
9 +
10   #include  "ray.h"
11  
12   #include  "otypes.h"
# Line 23 | Line 20 | register RAY  *r;
20          double  root[2];        /* quadratic roots */
21          int  nroots;
22          double  t;
23 <        register FLOAT  *ap;
23 >        register RREAL  *ap;
24          register int  i;
25  
26          if (so->oargs.nfargs != 4)
# Line 43 | Line 40 | register RAY  *r;
40           *  quadratic equation in t is then solved for the
41           *  smallest positive root, which is our point of
42           *  intersection.
43 <         *      Because the ray direction is normalized, a is always 1.
43 >         *      Since the ray is normalized, a should always be
44 >         *  one.  We compute it here to prevent instability in the
45 >         *  intersection calculation.
46           */
47 <
48 <        a = 1.0;                /* compute quadratic coefficients */
50 <        b = c = 0.0;
47 >                                /* compute quadratic coefficients */
48 >        a = b = c = 0.0;
49          for (i = 0; i < 3; i++) {
50 +                a += r->rdir[i]*r->rdir[i];
51                  t = r->rorg[i] - ap[i];
52                  b += 2.0*r->rdir[i]*t;
53                  c += t*t;
# Line 78 | Line 77 | register RAY  *r;
77          }
78          r->rod = -DOT(r->rdir, r->ron);
79          r->rox = NULL;
80 +        r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
81 +        r->uv[0] = r->uv[1] = 0.0;
82  
83          return(1);                      /* hit */
84   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines