~ubuntu-branches/ubuntu/maverick/ntop/maverick

« back to all changes in this revision

Viewing changes to gdchart0.94c/gd-1.8.3/mathmake.c

  • Committer: Bazaar Package Importer
  • Author(s): Dennis Schoen
  • Date: 2002-04-12 11:38:47 UTC
  • Revision ID: james.westby@ubuntu.com-20020412113847-4k4yydw0pzybc6g8
Tags: upstream-2.0.0
ImportĀ upstreamĀ versionĀ 2.0.0

Show diffs side-by-side

added added

removed removed

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