This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebGLProject
107 lines (62 loc) · 1.76 KB
/
WebGLProject
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
import math
# expression = '2*x**2+x-3*e(-x)'
# x = 3
# e = math.exp
# arr = list(expression)
# res = expression.split('+')
# print(res)
# print(eval(expression))
exp = math.exp
log = math.log10
cos = math.cos
sin = math.sin
tan = math.tan
pi = math.pi
sqrt = math.sqrt
class differentiate:
def __init__(self,expression,xval):
self.x = xval
self.expression = expression
def evaluateDiff(self):
delta = 10**(-10)
x = self.x
funcValInit = eval(self.expression)
x = self.x+delta
funcValFinal = eval(self.expression)
diffVal = (funcValFinal - funcValInit)/delta
return diffVal
class integrate:
def __init__(self,lima,limb,equation):
self.a = lima
self.b = limb
self.equation = equation
self.n = 100000
def evaluateInt(self):
interval = (self.b - self.a)/self.n
i = 0
Areasum = 0
while(i < self.n):
x = self.a + interval*i
Areasum += interval * eval(self.equation)
i+=1
return Areasum
class complex_number:
def __init__(self,Re,Im):
self.Re = Re
self.Im = Im
def __repr__(self):
return '({},{})'.format(self.Re,self.Im)
def modulus(self):
return sqrt(self.Re**2 + self.Im**2)
def argz(self):
return math.atan(self.Im/self.Re)
def conjugate(self):
return complex_number(self.Re,-self.Im)
def polar(self):
val = (self.modulus(),self.argz())
return val
def complex_power(self,n):
(modulus,argz) = self.polar()
modulus = modulus**n
argz = n*argz
return complex_number(modulus*math.cos(argz),modulus*math.sin(argz))