Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- g = 9.80 #the Constant acceleration of an object close to the surface of the earth.
- v0 = 700 #Initial velocity in meters per second.
- x=[0]
- y=[0]#the string keeping track of the position along the y axis starting with 0.
- t=[0] # the string keeping track of the times measured in each time step starting with 0.
- a=[g] #the string containing the different velocities in each step,velocity in the situation stays the same.
- dt = 0.10 #the change in time between each value in the above strings
- for i in range(0,5,5):
- angle=((i)+30)*(np.pi/180)
- vx=[v0*np.cos(angle)]
- vy=[v0*np.sin(angle)] #the string keeping track of the velocity.
- #the following loops statement appends values to all of the
- #following strings using the Euler method while the current y position is greater than or equal to 0.
- while y[-1] >= 0:
- x.append(x[-1]+vx[-1]*dt)
- vx.append(vx[-1])
- y.append(y[-1]+vy[-1]*dt)
- vy.append(vy[-1]-g*dt)
- t.append(t[-1]+dt)
- a.append(g)
- while i <= 25:
- plt.plot(x,y)
- x=[0]
- y=[0]#the string keeping track of the position along the y axis starting with 0.
- t=[0] # the string keeping track of the times measured in each time step starting with 0.
- a=[g] #the string containing the different velocities in each step,velocity in the situation stays the same.
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment