Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import matplotlib.pyplot as plt
- g = 9.8
- class bounceBall(object):
- def __init__ (self):
- self.Height = []
- self.Distance = []
- self.D_cumil = 0
- self.H_peak = 1
- def traceBounce(self, H0, velocity, CoR, angleThetha, timedelta):
- thetha = angleThetha * math.pi/180 #converting to radians
- vel_y = velocity * math.sin(thetha)
- vel_x = velocity * math.cos(thetha)
- self.Height.append(H0)
- self.Distance.append(0)
- while self.H_peak > 0.01:
- self.Height.append(self.Height[-1] + vel_y*timedelta + 0.5*g*timedelta**2)
- vel_y = vel_y - (g * timedelta)
- self.D_cumil += vel_x*timedelta
- self.Distance.append(self.D_cumil)
- if self.Height[-1] < 0.0001:
- vel_y = abs(vel_y*CoR)
- self.H_peak = vel_y / (2*g)
- print(round(vel_y, 4), ",", round(self.Height[-1],4),",", round(self.H_peak,4))
- ball1 = bounceBall()
- ball1.traceBounce(0, 5, 0.8, 45, .001)
- plt.plot(ball1.Distance,ball1.Height)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement