1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| from math import *
from tkinter import *
#u=float(input("o="))
#o=float((u*pi)/180)
# Choix du canon :
def canon1():
global k
global v
global m
v=500
m=5.4
k=0.19333
return(v, m, k)
def canon2():
global k
global v
global m
v=1100
m=10.4
k=0.53584
return(v, m, k)
def canon3():
global k
global v
global m
v=333
m=800
k=5.252
return(v, m, k)
#Equation de la trajectoire :
#On obtient la hauteur y en fonction de l'abcisse x (et de la vitesse et de l'angle.)
def y(x):
o=float((45*pi)/180)
v=500
m=5.4
k=0.19333
h=k/m
return((9.81/(h*v*cos(o))+tan(o))*x+9.81/(h*h)*log(1-h*x/(v*cos(o))))
def xmax():
x=50
while y(x)>20:
x=x+1
return("Portée :", x,"m")
def ymax():
x=1
while y(x)<y(x+1):
x=x+1
return("la hauteur maximal se trouve à ",x,"m et est de ",y(x),"m")
def tki():
coordx=[0]
coordy=[0]
x=1
while x<5000:
coordx.append(x)
coordy.append(y(x))
repere.create_line(coordx[x-1],coordy[x-1],coordx[x],coordy[x])
x=x+1
#Tkinter
fen=Tk()
repere=Canvas(fen,width=600,height=500)
repere.pack()
b=Button(text="Test",command=tki)
b.pack()
fen.mainloop() |
Partager