-
Notifications
You must be signed in to change notification settings - Fork 6
/
field.py
60 lines (48 loc) · 1.17 KB
/
field.py
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
import numpy as np
from numpy import sin, cos, exp, pi, tan, log, sinh, cosh, tanh, sinc, sqrt, cbrt, angle, real, imag, abs, arcsin, arccos, arctan, arcsinh, arccosh, arctanh
from numpy import pi, e
potential_expr = None
obstacle_expr = None
def setPotential(expr):
global potential_expr
potential_expr = expr
test_pot_expr()
def setObstacle(expr):
global obstacle_expr
obstacle_expr = expr
test_obs_expr()
def test_pot_expr():
global potential_expr
x = 0
y = 0
try:
a = eval(potential_expr)
except:
print(potential_expr)
print('Erreur de calcul du potentiel : mis à 0 par défaut')
potential_expr = '0'
input('Appuyez sur une touche poour continuer')
def test_obs_expr():
global obstacle_expr
x = 0
y = 0
try:
a = eval(obstacle_expr)
except e:
print('Erreur lors de la definition de l\'obsatcle : Mis à False par défaut')
obstacle_expr = 'False'
input('Appuyez sur une touche poour continuer')
def isObstacle(x, y):
a = False
try:
a = eval(obstacle_expr)
except:
pass
return a
def getPotential(x, y):
a = 0 + 0j
try:
a = eval(potential_expr)
except:
pass
return a