diff --git a/plots/3Danimation.mp4 b/plots/3Danimation.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..487a88e008e2a0e62fe05241cf1bd5711d5165b4 Binary files /dev/null and b/plots/3Danimation.mp4 differ diff --git a/plots/3Danimation.py b/plots/3Danimation.py new file mode 100644 index 0000000000000000000000000000000000000000..025a1c60653aff9291311ac9fc42cc3ddfcdce4f --- /dev/null +++ b/plots/3Danimation.py @@ -0,0 +1,38 @@ +import numpy as np +from matplotlib import pyplot as plt +import matplotlib.animation as animation + +data = np.loadtxt("../out/positions.dat") +print(data.shape) +skip = data[0,1] +N = int(data[0,0]/skip) +nSteps = int(data.shape[0]/N) +print(nSteps) +dim = data.shape[1] + +x = data[1:, 0] +y = data[1:, 1] +z = data[1:, 2] + +fig = plt.figure() +ax = plt.axes(projection="3d") + +def animate(i): + xi = x[i*N:(i+1)*N] + yi = y[i*N:(i+1)*N] + zi = z[i*N:(i+1)*N] + ax.cla() + ax.scatter3D(xi, yi, s=0.05) + ax.set_xlim(-1, 1) + ax.set_ylim(-1, 1) + ax.set_zlim(-1, 1) + ax.set_xlabel("x") + ax.set_ylabel("y") + ax.set_zlabel("z") + ax.equal_aspect = True + +anim = animation.FuncAnimation(fig, animate, frames=nSteps) +mp4writer = animation.FFMpegWriter(fps=24) +anim.save("3Danimation.mp4", writer=mp4writer, dpi=300) + +plt.show() \ No newline at end of file