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.19 by greg, Sat Jun 29 21:03:44 2013 UTC vs.
Revision 2.20 by greg, Thu Dec 4 05:26:27 2014 UTC

# Line 10 | Line 10 | static const char      RCSid[] = "$Id$";
10   #define _USE_MATH_DEFINES
11   #include  <math.h>
12   #include  "fvect.h"
13 + #include  "random.h"
14  
15   double
16   Acos(double x)                  /* insurance for touchy math library */
# Line 147 | Line 148 | FVECT  v
148          return(len);
149   }
150  
151 +
152 + int
153 + getperpendicular(               /* choose random perpedicular direction */
154 +        FVECT vp,                       /* returns normalized */
155 +        const FVECT v                   /* input vector must be normalized */
156 + )
157 + {
158 +        FVECT   v1;
159 +        int     i;
160 +                                        /* randomize other coordinates */
161 +        v1[0] = 0.5 - frandom();
162 +        v1[1] = 0.5 - frandom();
163 +        v1[2] = 0.5 - frandom();
164 +        for (i = 3; i--; )
165 +                if ((-0.6 < v[i]) & (v[i] < 0.6))
166 +                        break;
167 +        if (i < 0)
168 +                return(0);
169 +        v1[i] = 1.0;
170 +        VCROSS(vp, v1, v);
171 +        return(normalize(vp) > 0.0);
172 + }
173  
174   int
175   closestapproach(                        /* closest approach of two rays */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines