This commit is contained in:
√(noham)² 2023-07-18 16:57:46 +02:00
parent e002665cf8
commit 101732b815
2 changed files with 34 additions and 34 deletions

View File

@ -64,39 +64,6 @@ def position(fposition, newv):
xxold = xxbase.copy()
# while(t<tf):
# plt.figure(1,figsize=[16,9])
# plt.clf()
# nb = 360
# r=np.linspace(1,1,nb)
# theta=np.linspace(0,2*np.pi,nb)
# plt.polar(theta, r)
# # plt.scatter(1*np.pi, 0.5)
# dst = distances(xxold)
# statusc = status(dst)
# print(statusc)
# vt = phi(dst)
# # print('vitesses : ', vt)
# xx = position(xxold, vt)
# # print('position : ', xx)
# plt.scatter(xx/10*np.pi, y, c=colors)
# for i in range(len(xx)):
# plt.plot(xx[i]/10*np.pi, y[i], color=statusc[i])
# plt.title('Vitesse maximale : ' + str(U) + 'm.s-¹\ndistance minimale entre deux voitures : ' + str(Wm) + 'm\nnombre de voitures : ' + str(nbv))
# plt.draw()
# plt.pause(0.00001)
# t += dt
# xxold = xx.copy()
while(t < tf):
plt.figure(1, figsize=[16, 9])
plt.clf()
@ -109,6 +76,8 @@ while(t < tf):
dst = distances(xxold)
statusc = status(dst)
print(dst)
print(statusc)
vt = phi(dst)
xx = position(xxold, vt)

View File

@ -1,4 +1,5 @@
from colour import Color
import matplotlib.pyplot as plt
def rainbow_gradient(distances):
num_colors = len(distances)
@ -31,4 +32,34 @@ distances = [0.05263158, 0.05263158, 0.05263158, 0.05263158, 0.05263158,
gradient = rainbow_gradient(distances)
print(gradient)
# Create a figure and axis
fig, ax = plt.subplots()
# Set the background color of the plot
fig.set_facecolor('white')
# Hide the axis labels
ax.set_axis_off()
# Calculate the width and height of each color patch
width = 1.0 / len(gradient)
height = 1.0
# Iterate through the colors and plot a rectangle for each
for i, color in enumerate(gradient):
# Calculate the x-coordinate of the color patch
x = i * width
# Plot the color patch
rect = plt.Rectangle((x, 0), width, height, facecolor=color)
ax.add_patch(rect)
# Set the aspect ratio to 'auto' to ensure the patches are square
ax.set_aspect('auto')
# Set the limits of the x-axis
ax.set_xlim(0, 1)
# Display the plot
plt.show()