Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from math import *
- def plot(x,y,coul="red") :
- global can
- can.create_line(x,y,x+1,y,fill=coul)
- def rgb(r,g,b) :
- return '#%02x%02x%02x' % (int(r), int(g), int(b))
- def L(x,y):
- return 1.5707963267948966 - atan(y/x)
- def VR(X,Y):
- l = L(X,Y)
- r = sqrt(X**2+(Y-Ro)**2)
- return Vo*(Ro/r - 1)*(sin(l))
- # constantes de la fenetre
- W = 600
- H = 600
- # constantes physiques
- Vo = 220000
- Ro = 262282594 * 10**12
- # fenetre de dessin
- win = Tk()
- win.title("Vitesse radiale en fonction des coordonnées")
- can = Canvas(win, width = W, height = H)
- can.pack()
- scale = W / Ro
- print(VR(Ro/2, Ro/2))
- min = -1
- max = Vo
- for x in range(1,W) :
- for y in range(1,H) :
- X,Y = x/scale, y/scale
- Vr = VR(X,Y)
- if Vr < min or min == -1:
- min = Vr
- print("max", max, "min", min)
- for x in range(1,W) :
- for y in range(1,H) :
- X,Y = x/scale, y/scale
- Vr = VR(X,Y)
- if Vr > max:
- coeff = 1
- else :
- coeff = (Vr-min)/(max-min)
- plot(x,y,rgb(coeff*255, 0, (1-coeff)*255))
- mainloop()
Advertisement
Add Comment
Please, Sign In to add comment