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

Comparing ray/src/ot/o_cone.c (file contents):
Revision 1.2 by greg, Sat Oct 14 11:19:30 1989 UTC vs.
Revision 2.5 by greg, Tue Jun 14 17:10:06 2005 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1986 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   *  o_cone.c - routines for intersecting cubes with cones.
6   *
# Line 11 | Line 8 | static char SCCSid[] = "$SunId$ LBL";
8   */
9  
10   #include  "standard.h"
14
11   #include  "octree.h"
16
12   #include  "object.h"
18
13   #include  "cone.h"
14  
15   #define  ROOT3          1.732050808
# Line 35 | Line 29 | static char SCCSid[] = "$SunId$ LBL";
29  
30   extern double  mincusize;               /* minimum cube size */
31  
32 + static int findcseg(FVECT ep0, FVECT ep1, CONE *co, FVECT p);
33  
34 < o_cone(o, cu)                   /* determine if cone intersects cube */
35 < OBJREC  *o;
36 < register CUBE  *cu;
34 >
35 >
36 > extern int
37 > o_cone(         /* determine if cone intersects cube */
38 >        OBJREC  *o,
39 >        register CUBE  *cu
40 > )
41   {
43        double  dist2lseg(), findcseg();
42          CONE  *co;
43          FVECT  ep0, ep1;
44 + #ifdef STRICT
45          FVECT  cumin, cumax;
46          CUBE  cukid;
47 +        register int  j;
48 + #endif
49          double  r;
50          FVECT  p;
51 <        register int  i, j;
51 >        register int  i;
52                                          /* get cone arguments */
53          co = getcone(o, 0);
54                                          /* get cube center */
# Line 56 | Line 57 | register CUBE  *cu;
57                  p[i] = cu->cuorg[i] + r;
58          r *= ROOT3;                     /* bounding radius for cube */
59  
60 <        if (findcseg(ep0, ep1, co, p) > 0.0) {
60 >        if (findcseg(ep0, ep1, co, p)) {
61                                          /* check min. distance to cone */
62                  if (dist2lseg(p, ep0, ep1) > (r+FTINY)*(r+FTINY))
63                          return(O_MISS);
# Line 91 | Line 92 | register CUBE  *cu;
92   }
93  
94  
95 < double
96 < findcseg(ep0, ep1, co, p)       /* find line segment from cone closest to p */
97 < FVECT  ep0, ep1;
98 < register CONE  *co;
99 < FVECT  p;
95 > static int
96 > findcseg(       /* find line segment from cone closest to p */
97 >        FVECT  ep0,
98 >        FVECT  ep1,
99 >        register CONE  *co,
100 >        FVECT  p
101 > )
102   {
103          double  d;
104          FVECT  v;
105          register int  i;
106                                          /* find direction from axis to point */
107 <        for (i = 0; i < 3; i++)
105 <                v[i] = p[i] - CO_P0(co)[i];
107 >        VSUB(v, p, CO_P0(co));
108          d = DOT(v, co->ad);
109          for (i = 0; i < 3; i++)
110 <                v[i] = v[i] - d*co->ad[i];
111 <        d = normalize(v);
112 <        if (d > 0.0)                    /* find endpoints of segment */
113 <                for (i = 0; i < 3; i++) {
114 <                        ep0[i] = CO_R0(co)*v[i] + CO_P0(co)[i];
115 <                        ep1[i] = CO_R1(co)*v[i] + CO_P1(co)[i];
116 <                }
117 <        return(d);                      /* return distance from axis */
110 >                v[i] -= d*co->ad[i];
111 >        if (normalize(v) == 0.0)
112 >                return(0);
113 >                                        /* find endpoints of segment */
114 >        for (i = 0; i < 3; i++) {
115 >                ep0[i] = CO_R0(co)*v[i] + CO_P0(co)[i];
116 >                ep1[i] = CO_R1(co)*v[i] + CO_P1(co)[i];
117 >        }
118 >        return(1);                      /* return distance from axis */
119   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines