How to make A simulation of 2-Dimensional Projectiles

Lets say two cannon is fired at different initial position, initial angle and initial speed.

let say initial speed,angle and position for

projectile 1= v0=18; theta=49 Degree; position={0,0} projectile 2= v0=15; theta=56 Degree; position={95,100}

How to write a code that can simulate this event.

How to calculate these two projectiles distances as a function of time say from t=0 to t=10 seconds.

Between both fired canon ball what is their distances? at lets say t=7.9 seconds.

this is my code so far

x0 = 0; y0 = 0; g = -9.81;
vx0 := v0*Sin[theta]; vy0 := v0*Cos[theta];

x[t_] := x0 + v0*Cos[theta]*t;
y[t_] := y0 + v0*Sin[theta]*t + 0.5 g*t^2;

v0 = 18.0; theta = 49 Degree;
T = -2 (y0 + v0*Sin[theta])/g;
pp1 = ParametricPlot[{x[t], y[t]}, {t, 0, 1 T}, PlotRange -> All,
PlotStyle -> Blue];

v0 = 15.0; theta = 56 Degree;
T = -2 (y0 + v0*Sin[theta])/g;
pp2 = ParametricPlot[{x[t], y[t]}, {t, 0, 1 T}, PlotRange -> All,
PlotStyle -> Red];
Show[{pp1, pp2}] All Help is Really Appreciated

You can make a function for the trajectory of a projectile, which takes the initial position, velocity, angle, and time as arguments.

projTrajectory[{x0_, y0_}, v0_, theta_, t_] :=
Module[{T = -(v0 Sin[theta] + Sqrt[-2 g y0 + v0^2 Sin[theta]^2])/g},
{x0, y0} + If[t < T, {v0*Cos[theta]*t,
v0*Sin[theta]*t + 0.5 g*t^2},
{v0*Cos[theta]*T,
v0*Sin[theta]*T + 0.5 g*T^2}
]
]

It looks a bit complicated with the Module, but the point is to make sure the projectile stays put when it hits the ground, so we calculate that time beforehand. You could modify it to let it roll afterwards if you like.

ParametricPlot[{
projTrajectory[{0, 2}, 18.0, 49 Degree, t],
projTrajectory[{0, 0}, 15.0, 56 Degree, t]
}, {t, 0, 3}, AspectRatio -> .5] And you can plot the distance between the projectiles as a function of time,

Plot[Norm[projTrajectory[{0, 2}, 18.0, 49 Degree, t] -
projTrajectory[{0, 0}, 15.0, 56 Degree, t]], {t, 0, 10}] And then you could make it interactive,

Manipulate[
Row[
{ParametricPlot[{
projTrajectory[{0, 2}, 18.0, 49 Degree, t],
projTrajectory[{0, 0}, 15.0, 56 Degree, t]
}, {t, 0, Tmax}, AspectRatio -> .5, ImageSize -> 400,
PlotRange -> {{0, 40}, {0, 14}},
PlotLabel -> Style["Trajectories", 18]],
Plot[Norm[projTrajectory[{0, 2}, 18.0, 49 Degree, t] -
projTrajectory[{0, 0}, 15.0, 56 Degree, t]], {t, 0, Tmax},
AspectRatio -> .5, ImageSize -> 400,
PlotRange -> {{0, 5}, {0, 14}},
PlotLabel -> Style["Separation", 18]]}
], {{Tmax, 0.01}, 0.01, 5, .1}] • Hi, +1, g needs to be defined. – bobbym Mar 18 '16 at 19:15
x0 = 0; y0 = 0; g = -9.81;
r = {x0 + v0 t Cos@\[Theta], y0 + v0 t Sin@\[Theta] + g t^2/2};
path[t_] = {Block[{v0 = 18, \[Theta] = 49 Degree}, r],
Block[{v0 = 15, \[Theta] = 56 Degree}, r]};
Animate[
Show[
ParametricPlot[Evaluate@path@t0, {t0, 0, t},
PlotRange -> {{0, 33}, {0, 12}}],
Graphics[{{Gray, Line@path@t}, {Red, PointSize[0.02],
Point@path@t}, {Text[ToString[Norm@Flatten@Differences@path@t],
First@path@t + {-4, 1}]}}]
],
{t, 10^-4, 3}, AnimationRate -> 0.4]