-
Notifications
You must be signed in to change notification settings - Fork 6
/
make_sintab.c
44 lines (36 loc) · 934 Bytes
/
make_sintab.c
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
44
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv) {
if(argc != 3) {
fprintf(stderr,"usage: makesintab nb scaling\n");
exit(-1);
}
int nb = atoi(argv[1]);
int scaling = atoi(argv[2]);
printf("// generated by make_sintab %d %d\n\n",nb,scaling);
printf("int sintab[%d] = {\n ", nb);
for(int i=0; i<nb; ++i) {
double alpha = (double)(i)*2*M_PI/(double)(nb);
printf("%d",(int)(sin(alpha)*(double)(scaling)));
if(i != nb-1) {
printf(",");
}
if(!((i+1)%20)) {
printf("\n ");
}
}
printf("};\n");
printf("int costab[%d] = {\n ", nb);
for(int i=0; i<nb; ++i) {
double alpha = (double)(i)*2*M_PI/(double)(nb);
printf("%d",(int)(cos(alpha)*(double)(scaling)));
if(i != nb-1) {
printf(",");
}
if(!((i+1)%20)) {
printf("\n ");
}
}
printf("};\n");
}