Advertisement
Guest User

python prog

a guest
Jun 15th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import math;
  3.  
  4. g = 9.8
  5. angle_in_rads = math.radians(45);
  6.  
  7. def solve_quadratic_equation(a, b, c):
  8.     return (-b-math.sqrt(b*b-4*a*c)) / 2*a;
  9.  
  10. def xfrange(start, stop, step):
  11.     while start < stop:
  12.         yield start
  13.         start += step
  14.  
  15. def Sy(t, V0, angle):
  16.     sin_alpha = math.sin(math.radians(angle));
  17.     return V0*sin_alpha*t - (g * t * t) / 2;
  18.  
  19. def Sx(t, V0, angle):
  20.     cos_alpha = math.cos(math.radians(angle));
  21.     return V0*cos_alpha*t;
  22.  
  23. def V0FromSx(Sx_value, t):
  24.     return Sx_value / math.cos(math.radians(45)) * t;
  25.  
  26.  
  27. max_distance = 100;
  28. V0 = (max_distance * g ) / ( 2 * math.sin(angle_in_rads) );
  29.  
  30.  
  31. pointslist_x = []
  32. pointslist_y = []
  33. for time in xfrange(0, 10, 0.1):
  34.     print(time);
  35.     pointslist_x.append(Sx(time, V0, 45));
  36.     pointslist_y.append(Sy(time, V0, 45));
  37.  
  38. plt.plot(pointslist_x, pointslist_y)
  39. plt.ylabel('some numbers')
  40. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement