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

Comparing ray/src/common/fvect.c (file contents):
Revision 2.1 by greg, Tue Nov 12 16:55:09 1991 UTC vs.
Revision 2.4 by gwlarson, Wed Aug 12 17:57:19 1998 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1998 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4 < static char SCCSid[] = "$SunId$ LBL";
4 > static char SCCSid[] = "$SunId$ SGI";
5   #endif
6  
7   /*
# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *     8/14/85
11   */
12  
13 + #include  <math.h>
14   #include  "fvect.h"
15  
16  
# Line 25 | Line 26 | double
26   dist2(p1, p2)                   /* return square of distance between points */
27   register FVECT  p1, p2;
28   {
29 <        static FVECT  delta;
29 >        FVECT  delta;
30  
31          delta[0] = p2[0] - p1[0];
32          delta[1] = p2[1] - p1[1];
# Line 39 | Line 40 | dist2line(p, ep1, ep2)         /* return square of distance t
40   FVECT  p;               /* the point */
41   FVECT  ep1, ep2;        /* points on the line */
42   {
43 <        static double  d, d1, d2;
43 >        register double  d, d1, d2;
44  
45          d = dist2(ep1, ep2);
46          d1 = dist2(ep1, p);
# Line 54 | Line 55 | dist2lseg(p, ep1, ep2)         /* return square of distance t
55   FVECT  p;               /* the point */
56   FVECT  ep1, ep2;        /* the end points */
57   {
58 <        static double  d, d1, d2;
58 >        register double  d, d1, d2;
59  
60          d = dist2(ep1, ep2);
61          d1 = dist2(ep1, p);
# Line 95 | Line 96 | double
96   normalize(v)                    /* normalize a vector, return old magnitude */
97   register FVECT  v;
98   {
99 <        static double  len;
99 >        register double  len;
100          
101          len = DOT(v, v);
102          
103          if (len <= 0.0)
104                  return(0.0);
105          
106 <        /****** problematic
107 <        if (len >= (1.0-FTINY)*(1.0-FTINY) &&
108 <                        len <= (1.0+FTINY)*(1.0+FTINY))
109 <                return(1.0);
109 <        ******/
106 >        if (len <= 1.0+FTINY && len >= 1.0-FTINY)
107 >                len = 0.5 + 0.5*len;    /* first order approximation */
108 >        else
109 >                len = sqrt(len);
110  
111        len = sqrt(len);
111          v[0] /= len;
112          v[1] /= len;
113          v[2] /= len;
114 +
115          return(len);
116   }
117  
# Line 120 | Line 120 | spinvector(vres, vorig, vnorm, theta)  /* rotate vector
120   FVECT  vres, vorig, vnorm;
121   double  theta;
122   {
123        extern double  cos(), sin();
123          double  sint, cost, normprod;
124          FVECT  vperp;
125          register int  i;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines