-
Notifications
You must be signed in to change notification settings - Fork 0
/
sinus.c
96 lines (83 loc) · 2.08 KB
/
sinus.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sinus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ael-kadh <ael-kadh@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/12/13 19:21:08 by ael-kadh #+# #+# */
/* Updated: 2013/12/13 21:55:27 by ael-kadh ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
static double deg_rad(int x)
{
double rad;
if (x == 0)
return (0);
rad = (x * (PI / 180));
return (rad);
}
double sinus(int n)
{
double res;
double x;
x = deg_rad(n);
if (x < 0)
{
res = 1.27323954 * x + .405284735 * x * x;
if (res < 0)
res = .225 * (res *-res - res) + res;
else
res = .225 * (res * res - res) + res;
}
else
{
res = 1.27323954 * x - 0.405284735 * x * x;
if (res < 0)
res = .225 * (res *-res - res) + res;
else
res = .225 * (res * res - res) + res;
}
return (res);
}
double cosinus(int n)
{
double res;
double x;
x = deg_rad(n);
x += 1.57079632;
if (x > 3.14159265)
x -= 6.28318531;
if (x < 0)
{
res = 1.27323954 * x + 0.405284735 * x * x;
if (res < 0)
res = .225 * (res *-res - res) + res;
else
res = .225 * (res * res - res) + res;
}
else
{
res = 1.27323954 * x - 0.405284735 * x * x;
if (res < 0)
res = .225 * (res *-res - res) + res;
else
res = .225 * (res * res - res) + res;
}
return (res);
}
double tangente(int n)
{
double res;
double x;
x = deg_rad(n);
res = sinus(x) / cosinus(x);
return (res);
}
double cotangente(int n)
{
double res;
res = 1 / tangente(n);
return (res);
}