In lecture, we learned that the 2D motion of a projectile subject to gravity and air drag can be modeled using the following system of ODEs:
m ̈x=μ(u− ̇x)√(u− ̇x)2+ (v− ̇y)2,
m ̈y=μ(v− ̇y)√(u− ̇x)2+ (v− ̇y)2−mg, (6)
where (x(t),y(t)) is the position of the projectile, m is the mass of the projectile, g is the acceleration due to gravity (positive downward), μ is a constant that determines the strength of the drag force, and (u(t,x,y),v(t,x,y)) are the x−and y−components of the wind velocity (expressed as a vector field).
For this project option, we will simulate the motion of a baseball after being struck by a bat. In particular, for a given exit velocity v0, we wish to determine the launch angle θ0 that maximizes the horizontal distance traveled when the ball hits the ground. We will use the following parameters (taken from typical Major League Baseball regulations and statistics):
m= 0.15 kg,
g= 9.81 m/s,
v0= 51.4 m/s,
And D= 7.5 cm, where D is the diameter of the baseball.
The constant μ is given by μ=12ρAcD, (7)
Where ρ= 1.225 kg/m3is the density of the air, A is the cross-sectional area of the baseball, and cD is the drag coefficient2. Typical values of cD range from 0.30 to 0.45 for a major league baseball, but we will vary this parameter for the project. The Computational tasks for this option are as follows: (a) Write a MATLAB program that computes the optimal launch angle θ0, which maxi-mizes the horizontal distance traveled, for any drag coefficient and wind velocity. Your Program should also calculate the flight time of the baseball (i.e., the time elapsed between the initial launch and the impact with the ground). You may neglect the vertical displacement from the ground as the ball is hit (that is, assume the initial position of the ball is x(0)=y(0)=0, and the ground is located at y= 0).(b) Validate your numerical solution by solving for the optimal angle in the limitcD= 0(i.e., in a hypothetical vacuum), and comparing it with the analytical solution for this case.(c) Assuming zero wind speed, compute the horizontal distance traveled by the baseball,when launched at the optimal angle, as the drag coefficient varies from cD=0 to cD=0.5.