Projectile motion

Trajectory from Newton’s second law of motion

Force

F={0,-m g};

Initial conditions

r0={x0,y0};
v0 ={w Cos[ϕ],w Sin[ϕ]};

Solution of Newton’s second law

rt=DSolve[{
m D[x[t],t,t]==F[[1]],
m D[y[t],t,t]==F[[2]],
x[0]==r0[[1]],y[0]==r0[[2]],
x'[0]==v0[[1]],y'[0]==v0[[2]]
},
{x[t],y[t]},t
]

fixedValues={g->10, x0->0,y0->0};
envelope=y0+w^2/(2 g)+g w^2(x^2-2x0 x)/(2(wg^2 x0^2-w^4));
{xx1,yy1}={2,1};
Animate[
Show[
ParametricPlot[{x[t],y[t]}/.rt/.fixedValues/.{ϕ->phi*π/180,w->ww},{t,0,10},PlotRange->{{-5,10},{-5,5}}],
Plot[envelope/.fixedValues/.{ϕ->phi*π/180,w->ww},{x,-5,10},PlotStyle->Red],ListPlot[{{xx1,yy1}},PlotStyle->Black],
PlotLabel->Row[{"ϕ =", phi, ", w = ",ww}]],
{{phi,30,"Angle in degrees"},0,180,1},
{{ww,8,"Speed in m/s"},0.1,10,0.1},
AnimationRunning->False
]

Trajectory as a function y = f(x)

traj=Simplify[Solve[
X==(x[t]/.rt[[1,1]]) &&Y==(y[t]/.rt[[1,2]]),
 {t,Y}]]

Determining the angle to hit an object at (x1,y1)

Mathematica solution

Insert the point (x1 , y1) into the trajectory equation and solve it for ϕ

eqx=(y1-(Y/.traj[[1,2]])/.{X->x1})
eqd=Simplify[Cos[ϕ]^2 eqx/.{x1->x0+d Cos[α],y1->y0+d Sin[α]}]

sol=Simplify[Assuming[w>0&&g>0 && d>0&& α>0&&α<π/2,Solve[eqd==0,ϕ]]]

Only solutions number 2 and 4 give reasonable results

angle1=Normal[ϕ/.sol[[4,1]]/.{(C[1])->0}]
angle2=Normal[ϕ/.sol[[2,1]]/.{(C[1])->0}]

Numerically for a given large enough speed we get two angles

ww=8;
{xx1,yy1}={2,1};
N[{angle1/π*180,angle2/π*180}/.fixedValues/.{w->ww,α->ArcTan[yy1/xx1],d->Sqrt[xx1^2+yy1^2]}]

Solution by hand

By substituting for Sin as a function of Cos in
((d g ((Cos[α])^2))/(w^2))+2 ((Cos[ϕ])^2) Sin[α]-2 Cos[α] Cos[ϕ] Sin[ϕ]= 0
and squaring it we get a quadratic equation for Cos[ϕ]^2 with the following coefficients and the discriminant Δ

β=g d/w^2;
a=1;b=(β Sin[α]-1)Cos[α]^2; c=β^2 Cos[α]^4/4;
Δ=b^2-4a c
myAngle1=ArcCos[Sqrt[(-b+Sqrt[Δ])/2a]]
myAngle2=ArcCos[Sqrt[(-b-Sqrt[Δ])/2a]]

Numerically we get the same result as above

ww=8;
{xx1,yy1}={2,1};
N[{Δ,myAngle1/π*180,myAngle2/π*180}/.fixedValues/.{w->ww,α->ArcTan[yy1/xx1],d->Sqrt[xx1^2+yy1^2]}]

Minimal speed to reach the given point

The minimal speed can be determined from condition Δ = 0.
Here only one of four solutions has a physical meaning

minw=Simplify[Assuming[g>0 && d>0&& α>0&&α<π/2,Solve[Δ==0,w]]]
{xx1,yy1}={2,1};
N[minw/.fixedValues/.{α->ArcTan[yy1/xx1],d->Sqrt[xx1^2+yy1^2]}]