Re: Projectile motion
- To: mathgroup at smc.vnet.net
- Subject: [mg79882] Re: Projectile motion
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 8 Aug 2007 04:44:18 -0400 (EDT)
- Organization: Uni Leipzig
- References: <f9912q$c4n$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi, a) it is not wise to solve the ode every time even when the analytical solution can be found and the time where the ball hit the ground is known to be 2 v Sin[Theta]/g b) Manipulate[ Module[{eqns, soln, x, y, t}, eqns = {x'[t] == v Cos[Theta], x[0] == 0, y'[t] == -g t + v Sin[Theta], y[0] == 0}; soln = Flatten[NDSolve[eqns, {x, y}, {t, 0, 2 v Sin[Theta]/g}]]; With[{d = x[p] /. soln, h = y[p] /. soln}, Graphics[{Blue, Disk[{d, h}, .2]}, PlotRange -> {{-.5, 12}, {-.5, 6}}, Frame -> True, PlotLabel -> TableForm[{"Theta =" <> ToString[NumberForm[Theta 180/Pi, {2, 0}]], "vx =" <> ToString[NumberForm[Chop[N[v Cos[Theta]]], {2, 1}]], "vy =" <> ToString[NumberForm[Chop[N[v Sin[Theta]]], {2, 1}]], "xmax =" <> ToString[NumberForm[N[(v2 Sin[2 Theta])/g], {3, 2}]], "ymax =" <> ToString[ NumberForm[N[(v Sin[Theta]) 2/(2 g)], {3, 2}]]}]]]], {{v, 5, "Initial Velocity"}, 1, 10}, {{g, 9.8, "Gravitational Constant"}, 0, 30}, {{Theta, Pi/4, "Theta"}, 0, Pi/2}, {{p, 0, "Animate"}, 0, 2 v Sin[Theta]/g, ControlType -> Trigger}] will do that. Regards Jens Mike wrote: > All: > > I'd like to be able to stop the "disk" when it arrives at xmax. Can anyone give me a hint? > > Thx, > > Mike > > > Manipulate[ > Module[{eqns, soln, x, y, t}, > eqns = {x'[t] == v Cos[Theta], x[0] == 0, > y'[t] == -g t + v Sin[Theta], y[0] == 0}; > soln = Flatten[NDSolve[eqns, {x, y}, {t, 0, p}]]; > With[{d = x[p] /. soln, h = y[p] /. soln}, > Graphics[{Blue, Disk[{d, h}, .2]}, > PlotRange -> {{-.5, 12}, {-.5, 6}}, Frame -> True, > PlotLabel -> > TableForm[{"Theta =" <> > ToString[NumberForm[Theta 180/Pi , {2, 0}]], > "vx =" <> > ToString[NumberForm[Chop[N[v Cos[Theta]]] , {2, 1}]], > "vy =" <> > ToString[NumberForm[Chop[N[v Sin[Theta]]] , {2, 1}]], > "xmax =" <> > ToString[NumberForm[N[(v^2 Sin[2 Theta])/g] , {3, 2}]], > "ymax =" <> > ToString[ > NumberForm[N[(v Sin[Theta])^2/(2 g)] , {3, 2}]]}]]]], {{v, > 5, "Initial Velocity"}, 1, > 10}, {{g, 9.8, "Gravitational Constant"}, 0, > 30}, {{Theta, Pi/4 , "Theta"}, 0, Pi/ > 2}, {{p, 0, "Animate"}, 0, 2, ControlType -> Trigger}] >