CALCUL DE LA FORCE EN NEWTON DE L'INTERACTION GRAVITATIONELLE

cs_Thomas46 Messages postés 123 Date d'inscription samedi 29 novembre 2003 Statut Membre Dernière intervention 11 mars 2007 - 29 mai 2005 à 21:31
tipro75 Messages postés 26 Date d'inscription lundi 22 août 2005 Statut Membre Dernière intervention 22 décembre 2005 - 16 déc. 2005 à 19:07
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/30807-calcul-de-la-force-en-newton-de-l-interaction-gravitationelle

tipro75 Messages postés 26 Date d'inscription lundi 22 août 2005 Statut Membre Dernière intervention 22 décembre 2005 1
16 déc. 2005 à 19:07
c'est ce programe qui est sur 'aprendre a programer avec python" de plus je trouve celui qui est ci-des
ous plus sipas car y a une interface graphique donc 6.5/10

from Tkinter import *
from math import sqrt

def distance(x1, y1, x2, y2):
d = sqrt((x2-x1)**2 + (y2-y1)**2)
return d

def forceG(m1, m2, di):
return m1*m2*6.67e-11/di**2

def avance(n, gd, hb):
global x, y, step
x[n], y[n] = x[n] +gd, y[n] +hb
can.coords(astre[n], x[n]-10, y[n]-10, x[n]+10, y[n]+10)
di = distance(x[0], y[0], x[1], y[1])
diA = di*1e9
f = forceG(m1, m2, diA)
valDis.configure(text="Distance = " +str(diA) +" m")
valFor.configure(text="Force = " +str(f) +" N")
step = di/10

def gauche1():
avance(0, -step, 0)

def droite1():
avance(0, step, 0)

def haut1():
avance(0, 0, -step)

def bas1():
avance(0, 0, step)

def gauche2():
avance(1, -step, 0)

def droite2():
avance (1, step, 0)

def haut2():
avance(1, 0, -step)

def bas2():
avance(1, 0, step)


m1 = 6e24
m2 = 6e24
astre = [0]*2
x =[50., 350.]
y =[100., 100.]
step =10

fen = Tk()
fen.title(' Gravitation universelle suivant Newton')

valM1 = Label(fen, text="M1 = " +str(m1) +" kg")
valM1.grid(row =1, column =0)
valM2 = Label(fen, text="M2 = " +str(m2) +" kg")
valM2.grid(row =1, column =1)
valDis = Label(fen, text="Distance")
valDis.grid(row =3, column =0)
valFor = Label(fen, text="Force")
valFor.grid(row =3, column =1)

can Canvas(fen, bg"black", width =400, height =200)
can.grid(row =2, column =0, columnspan =2)
astre[0] = can.create_oval(x[0]-10, y[0]-10, x[0]+10, y[0]+10,fill ="red", width =1)
astre[1] = can.create_oval(x[1]-10, y[1]-10, x[1]+10, y[1]+10,fill ="blue", width =1)

fra1 = Frame(fen)
fra1.grid(row =4, column =0, sticky =W, padx =10)
Button(fra1, text="<-", fg ='red',command =gauche1).pack(side =LEFT)
Button(fra1, text="->", fg ='red', command =droite1).pack(side =LEFT)
Button(fra1, text="^", fg ='red', command =haut1).pack(side =LEFT)
Button(fra1, text="v", fg ='red', command =bas1).pack(side =LEFT)
fra2 = Frame(fen)
fra2.grid(row =4, column =1, sticky =E, padx =10)
Button(fra2, text="<-", fg ='blue', command =gauche2).pack(side =LEFT)
Button(fra2, text="->", fg ='blue', command =droite2).pack(side =LEFT)
Button(fra2, text="^", fg ='blue', command =haut2).pack(side =LEFT)
Button(fra2, text="v", fg ='blue', command =bas2).pack(side =LEFT)
fen.mainloop()
tinux Messages postés 244 Date d'inscription mercredi 13 avril 2005 Statut Membre Dernière intervention 21 octobre 2013
7 sept. 2005 à 21:49
Cette source n'existe pas ds le tuto de Swinnen, j'ai appris Tkinter grace a Swinnen mai le prog est ma création. Il faut savoir observer une source !
Alexou69 Messages postés 1 Date d'inscription mercredi 17 août 2005 Statut Membre Dernière intervention 29 août 2005
29 août 2005 à 12:59
c'est sympa de recopier ce qu'on lit dans les bouquin !!!
(Cf. 'Apprendre à programmer avec Python' par G.Swinnen)
C'est une question de respect que de siter ces sources !!!
cs_Thomas46 Messages postés 123 Date d'inscription samedi 29 novembre 2003 Statut Membre Dernière intervention 11 mars 2007
29 mai 2005 à 21:31
Bon prog ;-)
Je note 9/10 car rien n'est parfait
Rejoignez-nous