Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("nTo calculate the components of a projectile fired at an angle")
- print("We need the angle(degrees), the initial velocity(ms-1), and")
- print("The gravity constant (9.81 on earth)n")
- angle_0 = float(input("Please enter the angle you want it to be fired at: "))
- angle_0 = (angle_0)/180.0*np.pi
- height = float(input("nPlease enter the starting height for the projectile: "))
- speed = float(input("nPlease enter the initial velocity you want it to be fired atn In metres per second: "))
- g=9.81
- plt.figure()
- time_max = ((2 * speed) * np.sin(angle_0)) / g
- time = time_max*np.linspace(0,1,100)[:,None]
- x_values = ((speed * time) * np.cos(angle_0))
- y_values = ((speed * time) * np.sin(angle_0)) - ((0.5 * g) * (time ** 2))
- distance_x = (speed * np.cos(angle_0))*time_max
- plt.plot(x_values,[i+(height) for i in y_values], linewidth = 1.5)
- plt.ylim([0,1000])
- plt.xlim([0,1000])
- plt.show()
- print("")
- print ("The Range of this projectile will be, "+str(distance_x))
- print ("")
- for x, y in zip(y_values, x_values):
- if x == 0 or y == 0:
- print(x, y)
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement