summaryrefslogtreecommitdiff
path: root/tests/test_trig.c
blob: 760dd0e726b937f9b67c40cf7603bcb5b57b30cd (plain)
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
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright (c) 2006 Chris Kuethe <chris.kuethe@gmail.com>
 * Copyright (c) 2009 BBN Technologies (Greg Troxel)
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * This program provides a way to check sin/cos.
 */

#include <stdio.h>
#include <math.h>

int test_trig(void);

int main(void) {
	test_trig();

	/* For now, no evaluation. */
	return 0;
}

#define Deg2Rad(x) ((x) * (2 * M_PI / 360.0))

int test_trig(void) {
	int i;
	double arg;
	double res;

	for (i = 0; i <= 360; i++) {
		arg = Deg2Rad(i);
		res = sin(arg);
		printf("sin(%.30f) = %.30f\n", arg, res);
	}

	for (i = 0; i <= 360; i++) {
		arg = Deg2Rad(i);
		res = cos(arg);
		printf("cos(%.30f) = %.30f\n", arg, res);
	}

	/* Always claim success. */
	return 0;
}