File: mathmake.c

package info (click to toggle)
libgd 1.3-1.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 660 kB
  • ctags: 310
  • sloc: ansic: 19,947; perl: 132; makefile: 122; sh: 6
file content (43 lines) | stat: -rw-r--r-- 883 bytes parent folder | download | duplicates (24)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <math.h>

#define scale 1024

int basis[91];
int cost[360];

main(void) {
	int i;
	printf("#define costScale %d\n", scale);
	printf("int cost[] = {\n  ");
	for (i=0; (i <= 90); i++) {
		basis[i] = cos((double)i * .0174532925) * scale;
	}
	for (i=0; (i < 90); i++) {
		printf("%d,\n  ", cost[i] = basis[i]);
	}
	for (i=90; (i < 180); i++) {
		printf("%d,\n  ", cost[i] = -basis[180-i]);
	}
	for (i=180; (i < 270); i++) {
		printf("%d,\n  ", cost[i] = -basis[i-180]);
	}
	for (i=270; (i < 359); i++) {
		printf("%d,\n  ", cost[i] = basis[360-i]);
	}
	printf("%d\n", cost[359] = basis[1]);
	printf("};\n");
	printf("#define sintScale %d\n", scale);
	printf("int sint[] = {\n  ");
	for (i=0; (i<360); i++) {
		int val;
		val = cost[(i + 270) % 360];
		if (i != 359) {
			printf("%d,\n  ", val);
		} else {
			printf("%d\n", val);
		}
	}
	printf("};\n");
}