1 #include <stdio.h>
2 #include <math.h>
3
4 #define scale 1024
5
6 int basis[91];
7 int cost[360];
8
main(void)9 main (void)
10 {
11 int i;
12 printf ("#define costScale %d\n", scale);
13 printf ("int cost[] = {\n ");
14 for (i = 0; (i <= 90); i++)
15 {
16 basis[i] = cos ((double) i * .0174532925) * scale;
17 }
18 for (i = 0; (i < 90); i++)
19 {
20 printf ("%d,\n ", cost[i] = basis[i]);
21 }
22 for (i = 90; (i < 180); i++)
23 {
24 printf ("%d,\n ", cost[i] = -basis[180 - i]);
25 }
26 for (i = 180; (i < 270); i++)
27 {
28 printf ("%d,\n ", cost[i] = -basis[i - 180]);
29 }
30 for (i = 270; (i < 359); i++)
31 {
32 printf ("%d,\n ", cost[i] = basis[360 - i]);
33 }
34 printf ("%d\n", cost[359] = basis[1]);
35 printf ("};\n");
36 printf ("#define sintScale %d\n", scale);
37 printf ("int sint[] = {\n ");
38 for (i = 0; (i < 360); i++)
39 {
40 int val;
41 val = cost[(i + 270) % 360];
42 if (i != 359)
43 {
44 printf ("%d,\n ", val);
45 }
46 else
47 {
48 printf ("%d\n", val);
49 }
50 }
51 printf ("};\n");
52 }
53