def cityGrid(option):
if option == 1 :
sx = (0, 0.8, 0.8)
sy = (0, 0, 0.3)
label = (0.5, 0.015)
else :
sx = (0, 0.3, 0.8)
sy = (0, 0.3, 0.3)
label = (0.5, 0.315)
a_s = []
x_s = [0]
y_s = [0]
for theta in range(0,4501):
a = math.radians(theta/100)
a_s.append(a)
x_s.append(math.cos(a))
y_s.append(math.sin(a))
x_s.append(0)
y_s.append(0)
fig = plt.figure(figsize = (12, 9))
ax = fig.add_subplot(111, xlim = (-0.04, 1.04), ylim = (-0.03, .78))
#Remove axes and ticks.
for side in ['bottom', 'left', 'top', 'right']:
ax.spines[side].set_visible(False)
ax.set_xticks([])
ax.set_yticks([])
#City.
plt.fill(x_s, y_s, "#DDDDDD")
#Grid.
#Horizontal.
for i in range(0, 36):
y = i / 50
x = math.sqrt(1 - y**2)
ax.plot((y,x), (y,y),
ls = ':',
c = '#000000',
lw = 0.5)
#Vertical.
for i in range(0, 51):
x = i / 50
if i < 36:
y = x
else:
y = math.sqrt(1-x**2)
ax.plot((x,x), (0,y),
ls = ':',
c = '#000000',
lw = 0.5)
#Diagonal.
if option == 2:
for i in range(0, 51):
x = i / 50
d = math.sqrt(2-x**2)
ax.plot((x, (x+d)/2), (0,(d-x)/2),
ls = ':',
c = '#000000',
lw = 0.5)
for i in range(0, 71):
x = i / 100
if i < 51:
ax.plot((x, 2*x), (x, 0),
ls = ':',
c = '#000000',
lw = 0.5)
else:
d = math.sqrt(2- 4*x**2)/2
ax.plot((x, x+d), (x, x-d),
ls = ':',
c = '#000000',
lw = 0.5)
#Scooter.
ax.plot(sx, sy,
c = '#22A884',
lw = 3)
#Drone.
ax.plot((0, 0.8), (0, 0.3),
c = '#440154',
lw = 3)
#Annotations
variables = [("Drone Path", (0.5, 0.225), '#440154', 'center', 'bottom'),
("Scooter Path", label, '#22A884', 'center', 'bottom'),
("θ", (0.1, 0.015), '#000000', 'center', 'center')]
for v in variables:
plt.annotate(v[0], v[1], c = v[2],
fontsize = 20,
fontweight = "bold",
ha = v[3],
va = v[4])
fig.savefig("2023.01.20 Classic" + str(option) + ".png")