SuperMonkey

ARE Final Vr(x,y)

Apr 29th, 2014
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. from tkinter import *
  2. from math import *
  3.  
  4. def plot(x,y,coul="red") :
  5.     global can
  6.     can.create_line(x,y,x+1,y,fill=coul)
  7.  
  8. def rgb(r,g,b) :
  9.     return '#%02x%02x%02x' % (int(r), int(g), int(b))
  10.    
  11. def L(x,y):
  12.     return 1.5707963267948966 - atan(y/x)
  13.    
  14. def VR(X,Y):
  15.     l = L(X,Y)
  16.     r = sqrt(X**2+(Y-Ro)**2)
  17.     return Vo*(Ro/r - 1)*(sin(l))
  18.  
  19. # constantes de la fenetre 
  20. W = 600
  21. H = 600
  22.  
  23. # constantes physiques
  24. Vo = 220000
  25. Ro = 262282594 * 10**12
  26.  
  27. # fenetre de dessin
  28. win = Tk()
  29. win.title("Vitesse radiale en fonction des coordonnées")
  30.  
  31. can = Canvas(win, width = W, height = H)
  32. can.pack()
  33.  
  34. scale = W / Ro
  35.  
  36. print(VR(Ro/2, Ro/2))
  37.  
  38.  
  39. min = -1
  40. max = Vo
  41. for x in range(1,W) :
  42.     for y in range(1,H) :
  43.         X,Y = x/scale, y/scale
  44.         Vr = VR(X,Y)
  45.        
  46.         if Vr < min or min == -1:
  47.             min = Vr
  48.            
  49. print("max", max, "min", min)          
  50.  
  51.  
  52. for x in range(1,W) :
  53.     for y in range(1,H) :
  54.         X,Y = x/scale, y/scale
  55.         Vr = VR(X,Y)
  56.        
  57.         if Vr > max:
  58.             coeff = 1
  59.         else :
  60.             coeff = (Vr-min)/(max-min)
  61.         plot(x,y,rgb(coeff*255, 0, (1-coeff)*255))
  62.  
  63. mainloop()
Advertisement
Add Comment
Please, Sign In to add comment