9 |
|
* |
10 |
|
* No interpolation in this version. |
11 |
|
* |
12 |
< |
* External symbols declared in standard.h |
12 |
> |
* External symbols declared in rtmath.h |
13 |
|
*/ |
14 |
|
|
15 |
|
#include "copyright.h" |
16 |
|
|
17 |
|
#include <math.h> |
18 |
|
|
19 |
+ |
#include "rtmath.h" |
20 |
+ |
|
21 |
|
#ifndef NCOSENTRY |
22 |
< |
#define NCOSENTRY 256 |
22 |
> |
#define NCOSENTRY 1024 |
23 |
|
#endif |
24 |
|
|
23 |
– |
#ifdef M_PI |
24 |
– |
#define PI ((double)M_PI) |
25 |
– |
#else |
26 |
– |
#define PI 3.14159265358979323846 |
27 |
– |
#endif |
25 |
|
|
29 |
– |
|
26 |
|
double |
27 |
< |
tcos(x) /* approximate cosine */ |
32 |
< |
register double x; |
27 |
> |
tcos(double x) /* approximate cosine */ |
28 |
|
{ |
29 |
|
static double costab[NCOSENTRY+1]; |
30 |
|
register int i; |
36 |
|
if (x < 0.) |
37 |
|
x = -x; |
38 |
|
i = (NCOSENTRY*2./PI) * x + 0.5; |
39 |
< |
if (i >= 4*NCOSENTRY) |
40 |
< |
i %= 4*NCOSENTRY; |
39 |
> |
while (i >= 4*NCOSENTRY) |
40 |
> |
i -= 4*NCOSENTRY; |
41 |
|
switch (i / NCOSENTRY) { |
42 |
|
case 0: |
43 |
|
return(costab[i]); |