Finding the range of the robot.

The robot will throw a ball which is attached to the end of an arm of length 0.25 m rotating around the origin. We want to experiment with the rotation speed of the robot to figure out what the maximum range and height of the throw are. 

Our basic setup is that while on the arm, the ball follows the path

xArm[t_] := (1/4)*Cos[k*t];
yArm[t_] := (1/4)*Sin[k*t];

and once in the air, the ball follows the path (constant speed motion in x, constant acceleration motion in y):

g = -9.8;

xAir[t_] := a*t + b;
yAir[t_] := (g/2)*t^2 + c*t + d;

At the time of release (t0), the position and velocity of these two curves are supposed to agree. We can use this information to solve for a, b, c, and d.

absol = Solve[{xArm[t0] == xAir[t0],D[xArm[t],t]== D[xAir[t],t] /. {t -> t0}},{a,b}]

cdsol =Solve[{yArm[t0] == yAir[t0],D[yArm[t],t]== D[yAir[t],t] /. {t -> t0}},{c,d}]

We now use this information to write the path in the air very concretely in terms of k and t0 as xFlight and yFlight. These functions will describe the path of the ball as a function of t0 and k.

xFlight[t_] := xAir[t] /. absol[[1]];
yFlight[t_] := yAir[t] /. cdsol[[1]];

We can see that these formulae look pretty unpleasant:

xFlight[t]
yFlight[t]

But they will still be fairly easy to work with using the computer! We want to now find the maximum height reached by the ball in terms of k and t0. This is a classic max-min problem: we want to find the maximum of yFlight on the interval [t0,infty). To do that, we need to differentiate yFlight and find the point where the derivative is zero.

yflightcriticalpt =t /. Solve[D[yFlight[t],t] == 0,t][[1]]

Now we have to be a little careful! This is the time at which the projectile reaches the maximum height IF this time is > t0. We can write down this function in Mathematica using an “If” statement:

yMax[T0_,K_] := (If[yflightcriticalpt >T0,yFlight[yflightcriticalpt],yFlight[T0]] /. {t0 -> T0,k->K}) /. {t0 -> T0,k->K};

yMax[3,10]

It is now time for some graphics, to make sure that all our formulas look like they are making sense:

ballPath[t_,T0_,K_] := If[t > T0,{xFlight[t],yFlight[t]},{xArm[t],yArm[t]}] /. {t0 -> T0,k -> K};

Launcher[r_,theta_] := {
Graphics[Rectangle[{-0.01,-1.5 r},{0.01,0.01}]],
ParametricPlot[{r*Cos[u],r*Sin[u]},{u,0,2*Pi}]
 };

We can now see the ball and the launcher and the maximum height on a single plot:

Manipulate[Show[ParametricPlot[ballPath[t,LaunchAngle/myK,myK],{t,0,maxT}],Launcher[0.22,T0],ParametricPlot[{t,-0.35},{t,-2,2}],Plot[yMax[LaunchAngle/myK,myK],{t,-2,2}],
PlotRange->{{-0.4,1.5},{-0.5,1}},AxesOrigin->{0,0}],{maxT,0.01,4},{myK,1,30},{LaunchAngle,0,2*Pi}]

Let’s get more abstract. Suppose we study the maximum value as a function of K alone. We’ll plot the maximum height for each t0 value between 0 and 2 Pi/K.

Manipulate[Plot[yMax[LaunchAngle/myK,myK],{LaunchAngle,0,2*Pi}],{myK,1,25}]

This is a really interesting function! We can see that the maximum occurs close to zero across the entire range. Now what is the region of the plane that we can target? The simplest way to answer that question is to plot all of the trajectories for a given K.

Manipulate[Show[Table[ParametricPlot[ballPath[t,LaunchAngle/myK,myK],{t,0,10}],{LaunchAngle,0,2*Pi,2*Pi/40}],Launcher[0.22,T0],ParametricPlot[{t,-0.35},{t,-3,3}],
PlotRange->{{-0.4,2},{-0.5,1}},AxesOrigin->{0,0}],{myK,1,30}]