forked from paulvangentcom/python_corona_simulation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.py
52 lines (41 loc) · 1.49 KB
/
environment.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
'''
file that contains all functions to define destinations in the
environment of the simulated world.
'''
import numpy as np
def build_hospital(xmin, xmax, ymin, ymax, plt, addcross=True):
'''builds hospital
Defines hospital and returns wall coordinates for
the hospital, as well as coordinates for a red cross
above it
Keyword arguments
-----------------
xmin : int or float
lower boundary on the x axis
xmax : int or float
upper boundary on the x axis
ymin : int or float
lower boundary on the y axis
ymax : int or float
upper boundary on the y axis
plt : matplotlib.pyplot object
the plot object to which to append the hospital drawing
if None, coordinates are returned
Returns
-------
None
'''
#plot walls
plt.plot([xmin, xmin], [ymin, ymax], color = 'black')
plt.plot([xmax, xmax], [ymin, ymax], color = 'black')
plt.plot([xmin, xmax], [ymin, ymin], color = 'black')
plt.plot([xmin, xmax], [ymax, ymax], color = 'black')
#plot red cross
if addcross:
xmiddle = xmin + ((xmax - xmin) / 2)
height = np.min([0.3, (ymax - ymin) / 5])
plt.plot([xmiddle, xmiddle], [ymax, ymax + height], color='red',
linewidth = 3)
plt.plot([xmiddle - (height / 2), xmiddle + (height / 2)],
[ymax + (height / 2), ymax + (height / 2)], color='red',
linewidth = 3)