def sympletic_integrator_step(dt: float, bodies: list, pairs: list, ax: Axes3D, *args, **kwargs): """A sympletic integrator to update the positions of bodies in our system of bodies. Reference --------- [1]: Sympletic Integrator on Wikipedia https://en.wikipedia.org/wiki/Symplectic_integrator """ for (([x1, y1, z1], v1, m1), ([x2, y2, z2], v2, m2)) in pairs: dx = x1 - x2 dy = y1 - y2 dz = z1 - z2 mag = dt * ((dx * dx + dy * dy + dz * dz)**(-1.5)) b1m = m1 * mag b2m = m2 * mag v1[0] -= dx * b2m v1[1] -= dy * b2m v1[2] -= dz * b2m v2[0] += dx * b1m v2[1] += dy * b1m v2[2] += dz * b1m for (r, [vx, vy, vz], m) in bodies: r[0] += dt * vx r[1] += dt * vy r[2] += dt * vz ax.clear() ax.axis("off") ax.set_xlim(-20., 20.) ax.set_ylim(-20., 20.) ax.set_zlim(-20., 20.) for ii in range(360): ax.view_init(elev=90., azim=ii) for name, body in BODIES.items(): pos, _, mass = body sc = ax.scatter(*pos, s=20 * (mass**0.3), label=name) ax.legend() return sc
edgecolors='black', zorder=10) plt.title("Vue du dessus du terrain de la trajectoire du coup sans aléas") plt.savefig("image/vue_dessus" + num + ".SVG") #Plot 3D plt.figure(figsize=(8, 8)) ax = plt.axes(projection="3d") ax.plot3D(x[:stop], y[:stop], z[:stop], '#000000', zorder=10) ax.plot3D(x[stop - 1:], y[stop - 1:], z[stop - 1:], '--', color='#000000', zorder=10) ax.axis('off') ax.margins(-0.49, -0.49, 0) ax.view_init(elev=20, azim=-65) ax.dist = 6 plottenniscourt3D() plt.title("Plot 3D de la trajectoire du coup sans aléas") plotnet3D() plt.savefig("image/vue_plot_3D" + num + ".SVG") #Plot aléas with open(file_path_alea, newline='') as csvfile: reader = csv.DictReader(csvfile) x = [] y = [] z = [] i = 1