1 |
– |
/* Copyright (c) 1994 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 |
|
* Routines for 3-d vectors |
6 |
|
*/ |
7 |
|
|
8 |
|
#include <stdio.h> |
9 |
+ |
#include <stdlib.h> |
10 |
|
#include <math.h> |
11 |
|
#include "parser.h" |
12 |
|
|
17 |
|
{ |
18 |
|
static double len; |
19 |
|
|
20 |
< |
len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; |
20 |
> |
len = DOT(v, v); |
21 |
|
|
22 |
|
if (len <= 0.0) |
23 |
|
return(0.0); |
24 |
|
|
25 |
< |
len = sqrt(len); |
25 |
> |
if (len <= 1.0+FTINY && len >= 1.0-FTINY) |
26 |
> |
len = 0.5 + 0.5*len; /* first order approximation */ |
27 |
> |
else |
28 |
> |
len = sqrt(len); |
29 |
|
|
30 |
|
v[0] /= len; |
31 |
|
v[1] /= len; |
35 |
|
} |
36 |
|
|
37 |
|
|
38 |
+ |
void |
39 |
|
fcross(vres, v1, v2) /* vres = v1 X v2 */ |
40 |
|
register FVECT vres, v1, v2; |
41 |
|
{ |