# ball_trajectory.py
# This function predicts a balls hypothetical projectory
# where x is the horizontal position, and default horizontal
# speed is 0.99 meters per second and initial vertical speed
# is 9.9 meters per second
# by Scott Gordon
importmatplotlib.pyplotaspltdefball_trajectory(x):location=10*x-5*(x**2)returnlocation# Plot the hypothetical ball trajectory between moment it is
# thrown (x = 0) and when it hits ground (x = 2)
xs=[x/100forxinlist(range(201))]ys=[ball_trajectory(x)forxinxs]plt.plot(xs,ys)plt.title('The Trajectory of a Thrown Ball')plt.xlabel('Horizontal Position of Ball')plt.ylabel('Vertical Position of Ball')plt.axhline(y=0)plt.show()
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)