Формат файлов .xyz следующий:< /p>
Код: Выделить всё
0.0199995 0.02 0.0199999
0.0397943 0.02 0.0199997
0.059875 0.02 0.0199997
0.0799158 0.0199993 0.02
0.0999472 0.02 0.0199997
0.119963 0.0199992 0.02
0.139975 0.02 0.0199996
0.159982 0.02 0.0199996
0.179987 0.02 0.0199996
0.19999 0.0199992 0.02
0.219993 0.0199992 0.02
0.239994 0.0199992 0.02
Код: Выделить всё
for i in range(num_of_frames):
# Reading the data from ./sph_sim_output/frame_%d.xyz, where %d is the frame number
data_x, data_y, data_z = get_pt_data("./sph_sim_output/frame_000000.xyz", i)
data.append((data_x, data_y, data_z)) #data_x, data_y, data_z are numpy vectors
fig = plt.figure()
ax = fig.add_subplot(projection="3d")
x, y, z = get_pt_data("./sph_sim_output/frame_000000.xyz", 0)
scatters = ax.plot(x,z,y) # I also tried this with ax.scatter
def update_pts(frame, data,scatters):
x = data[frame][0]
y = data[frame][1]
z = data[frame][2]
scatters._offset3d = (x, z, y)
return scatters
anim = animation.FuncAnimation(fig, update_pts, num_of_frames, fargs=(data,scatters), interval=60, blit=False)
output_filename = "waterdrop.mp4"
anim.save(output_filename, fps=60, bitrate=5000, writer=video_writer, extra_args=video_extra_args)
plt.close(fig)
Подробнее здесь: https://stackoverflow.com/questions/790 ... peat-of-th