"Initial commit to Gerrit"
[profile/ivi/gpsd.git] / test_trig.c
1 /*
2  * Copyright (c) 2006 Chris Kuethe <chris.kuethe@gmail.com>
3  * Copyright (c) 2009 BBN Technologies (Greg Troxel)
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /*
19  * This program provides a way to check sin/cos.
20  */
21
22 #include <stdio.h>
23 #include <math.h>
24
25 int test_trig(void);
26
27 int main(void) {
28         test_trig();
29
30         /* For now, no evaluation. */
31         return 0;
32 }
33
34 #define Deg2Rad(x) ((x) * (2 * M_PI / 360.0))
35
36 int test_trig(void) {
37         int i;
38         double arg;
39         double res;
40
41         for (i = 0; i <= 360; i++) {
42                 arg = Deg2Rad(i);
43                 res = sin(arg);
44                 printf("sin(%.30f) = %.30f\n", arg, res);
45         }
46
47         for (i = 0; i <= 360; i++) {
48                 arg = Deg2Rad(i);
49                 res = cos(arg);
50                 printf("cos(%.30f) = %.30f\n", arg, res);
51         }
52
53         /* Always claim success. */
54         return 0;
55 }