comparison sankaku.c @ 0:01387a2e419e

initial version
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 07 Dec 2010 15:39:45 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:01387a2e419e
1 #include <math.h>
2 #include "sankaku.h"
3
4 #define SANKAKU 100000
5
6 int mysin[181];
7 int mycos[181];
8
9 void sankakuf()
10 {
11 int i;
12 for (i = 0; i < 181; i++) {
13 mysin[i] = sin(i / 360.0 * pi2) * SANKAKU;
14 }
15 for (i = 0; i < 181; i++) {
16 mycos[i] = cos(i / 360.0 * pi2) * SANKAKU;
17 }
18 }
19
20 int Mycos(int c)
21 {
22 c %= 360;
23 if (c < 0)
24 c += 360;
25 if ((c <= 180))
26 return (mycos[c]);
27 if (c > 180)
28 return (mycos[180 - (c - 180)]);
29 return (0);
30 }
31
32 int Mysin(int c)
33 {
34 c %= 360;
35 if (c < 0)
36 c += 360;
37 if (c <= 180)
38 return (mysin[c]);
39 if (c > 180)
40 return (mysin[180 - (c - 180)] * -1);
41 return (0);
42 }