-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigonometry.py
More file actions
128 lines (106 loc) · 2.17 KB
/
trigonometry.py
File metadata and controls
128 lines (106 loc) · 2.17 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
def Factorial(a):
fat = 1
num = a
while (num > 0):
fat = fat * num
num = num - 1
return fat
def CalculatePi():
pi = 0
exp = 0
while (exp < 10000001):
pi = pi + (4*((-1)**exp)/((2*exp)+1))
exp = exp + 1
return pi
def LapNumbers(b):
ang = b
laps = int(ang/360)
return laps
def EquivalentAngle(c):
ang = c
equi_ang = ang % 360
return equi_ang
def ConvertToRad(d):
ang = d
eq_ang = EquivalentAngle(ang)
pi = CalculatePi()
ang_rad = (eq_ang*pi)/180
return ang_rad
def Sine(e):
ang = e
ang_rad = ConvertToRad(ang)
pi = CalculatePi()
exp = 0
sin = 0
if (ang == 90 or ang == -270):
sin = 1
return sin
if (ang == 270 or ang == -90):
sin = -1
return sin
if (ang == 180 or ang == -180):
sin = 0
return sin
else:
while (exp <= 84):
sin = sin + (((-1)**exp)*(ang_rad ** ((2*exp)+1)))/(Factorial((2*exp) + 1))
exp = exp + 1
return sin
def Cossine(f):
ang = f
ang_rad = ConvertToRad(ang)
pi = CalculatePi()
exp = 0
cos = 0
if (ang == 90 or ang == -270):
cos = 0
return cos
if (ang == 180 or ang == -180):
cos = -1
return cos
if (ang == 270 or ang == -90):
cos = 0
return cos
else:
while (exp <= 84):
cos = cos + (((-1)**exp)*(ang_rad ** ((2*exp))))/(Factorial((2*exp)))
exp = exp + 1
return cos
def Tangent(g):
ang = g
sin = Sine(g)
cos = Cossine(g)
if (cos == 0):
tan = "It doesn't exist!"
return tan
if (ang == 45 or ang == -315):
tan = 1
return tan
if (ang == 135 or ang == -225):
tan = -1
return tan
else:
tan = sin/cos
return tan
def TFR(h):
ang = h
sin = Sine(h)
cos = Cossine(h)
tfr = (sin**2)+(cos**2)
return tfr
x = int(input("Please, input an angle (degrees): "))
rad = ConvertToRad(x)
laps = LapNumbers(x)
eq_angle = EquivalentAngle(x)
sin = Sine(x)
cos = Cossine(x)
tan = Tangent(x)
tfr = TFR(x)
print(str(x) + "º is equal to the angle " + str(eq_angle) + "º")
print(str(x) + " as radians: " + str(rad))
print("Number of laps: " + str(laps))
print("Sine of " + str(x) + ": " + str(sin))
print("Cossine of " + str(x) + ": " + str(cos))
print("Tangent of " + str(x) + ": " + str(tan))
print("Trigonometry Fundamental Relation = " + str(tfr))
print("Done! All counts are finished! ;)")