This commit is contained in:
changwu 2023-05-21 19:13:18 +08:00
parent d5e7fdf687
commit db61a8b742
2 changed files with 28 additions and 24 deletions

View File

@ -34,18 +34,17 @@ for i in range(0, n):
# inity[i] = 22-abs(i-17)*20/17
# finalx[i] = 5+3*int(i%7)
# finaly[i] = 60
# finalz[i] = 75+3*int(i/7)
initx[i] = 15+3*int(i%7)
inity[i] = 80
initz[i] = 75+3*int(i/7)
# finalz[i] = 75+3*int(i/7)
# finaly[i] = finalz[i]-15
initx[i] = 15+3*int(i%7)
initz[i] = 75+3*int(i/7)
inity[i] = initz[i]+5
psai = 2*math.pi*i/35
finalx[i] = 120+10*math.cos(psai)
finaly[i] = 80
finalz[i] = 50+10*math.sin(psai)
finaly[i] = 80+10*math.sin(psai)
finalz[i] = 50
# initx[i] = 20 + 8 * math.cos(math.pi * 2 * i / n)
# inity[i] = 80 + 8 * math.sin(math.pi * 2 * i / n)
@ -124,7 +123,7 @@ con = getcon(initx,inity,initz)
tasks = gettasks(dis)
for i in range(0, n):
state[i, 0] = int(random.random() * n)
state[i, 0] = int(i)
#定义个体寻找相同点的函数
@ -553,9 +552,9 @@ while (1):
jishu = jishu + 1
#或许需要在第30步时再一次分配
np.savetxt('D:/wsf1x.csv', hisplacex, fmt="%f", delimiter=",")
np.savetxt('D:/wsf1y.csv', hisplacey, fmt="%f", delimiter=",")
np.savetxt('D:/wsf1z.csv', hisplacez, fmt="%f", delimiter=",")
np.savetxt('D:/wsf2x.csv', hisplacex, fmt="%f", delimiter=",")
np.savetxt('D:/wsf2y.csv', hisplacey, fmt="%f", delimiter=",")
np.savetxt('D:/wsf2z.csv', hisplacez, fmt="%f", delimiter=",")
np.savetxt('D:/speed1x.csv', speedx, fmt="%f", delimiter=",")
np.savetxt('D:/speed1y.csv', speedy, fmt="%f", delimiter=",")
np.savetxt('D:/speed1z.csv', speedz, fmt="%f", delimiter=",")
@ -621,5 +620,8 @@ ax.plot3D(100,100,0)
ax.scatter3D(placex,placey,placez,c='blue',s = 0.1)
ax.scatter3D(initx,inity,initz,c='red',s = 0.5)
ax.scatter3D(finalx,finaly,finalz,c='red',s = 0.5)
# xcnt = []
# for i in range(0,500):
# xcnt.append(i)
# plt.scatter(hisplacex)
plt.show()

View File

@ -3,19 +3,21 @@ import random
import math
import numpy as np
import matplotlib.pyplot as plt
cnt = np.zeros(500)
for t in range(0,500):
cnt[t] = t
xt = np.zeros(500)
vx = np.loadtxt("D:/speed1x.csv",delimiter=",", dtype=float)
vy = np.loadtxt("D:/speed1y.csv",delimiter=",", dtype=float)
vz = np.loadtxt("D:/speed1z.csv",delimiter=",", dtype=float)
cnt = np.zeros(600)
for t in range(0,600):
cnt[t] = t*0.2
vx = np.loadtxt("D:/wsf1x.csv",delimiter=",", dtype=float)
vy = np.loadtxt("D:/wsf1y.csv",delimiter=",", dtype=float)
vz = np.loadtxt("D:/wsf1z.csv",delimiter=",", dtype=float)
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
plt.xlabel('时间')
plt.ylabel('每个时间段x方向位移')
plt.xlabel('时间 单位:秒')
plt.ylabel('z坐标 单位:米')
for i in range(0,35):
xt = np.zeros(500)
for j in range(0,500):
xt = np.zeros(600)
for j in range(0,600):
if(vz[i,j]) == 0 and vz[i,j-1]!=0:
vz[i,j] = vz[i,j-1]
xt[j] = vz[i,j]
plt.plot(cnt,xt)