ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/mgflib/fvect.c
Revision: 1.1
Committed: Tue Jun 21 14:45:44 1994 UTC (29 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# User Rev Content
1 greg 1.1 /* Copyright (c) 1994 Regents of the University of California */
2    
3     #ifndef lint
4     static char SCCSid[] = "$SunId$ LBL";
5     #endif
6    
7     /*
8     * Routines for 3-d vectors
9     */
10    
11     #include <stdio.h>
12     #include <math.h>
13     #include "parser.h"
14    
15    
16     double
17     normalize(v) /* normalize a vector, return old magnitude */
18     register FVECT v;
19     {
20     static double len;
21    
22     len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
23    
24     if (len <= 0.0)
25     return(0.0);
26    
27     len = sqrt(len);
28    
29     v[0] /= len;
30     v[1] /= len;
31     v[2] /= len;
32    
33     return(len);
34     }
35    
36    
37     fcross(vres, v1, v2) /* vres = v1 X v2 */
38     register FVECT vres, v1, v2;
39     {
40     vres[0] = v1[1]*v2[2] - v1[2]*v2[1];
41     vres[1] = v1[2]*v2[0] - v1[0]*v2[2];
42     vres[2] = v1[0]*v2[1] - v1[1]*v2[0];
43     }