import matplotlib.pyplot as plt import math import matplotlib.pyplot as plt import numpy as np g = 9.8 h = float(input("altitude initiale")) V0 = float (input("Valeur de la vitesse initiale : ")) alpha = float(input("valeur (en °)de l'angle initial de la trajectoire :")) ax = [0] ay = [-g] vx = [V0*math.cos(alpha*math.pi/180)] vy = [V0*math.sin(alpha*math.pi/180)] x = [0] y =[h] ythéo = [h] t = [0] i = 1 Dt = 0.01 while y[i-1] >= 0 : t.append(t[i-1]+Dt) ax.append(0) ay.append(-g) vx.append(vx[i-1]+ax[i-1]*Dt) vy.append (vy[i-1]+ay[i-1]*Dt) x.append (x[i-1]+vx[i-1]*Dt) y.append (y[i-1]+vy[i-1]*Dt) ythéo.append(-0.5*g*x[i]**2/V0**2/math.cos(math.pi*alpha/180)**2+math.tan(alpha*math.pi/180)*x[i]+h) plt.plot(x,ythéo,'g-') plt.plot(x,y,'bo') plt.show() plt.pause(1) i=i+1 print (t, ax, ay,vx,vy,x,y)