MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Projectile motion

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79892] Re: Projectile motion
  • From: ben <benjamin.friedrich at gmail.com>
  • Date: Wed, 8 Aug 2007 04:49:31 -0400 (EDT)
  • References: <f9912q$c4n$1@smc.vnet.net>

Dear Mike

I haven't worked through your example in detail,
but maybe this snippet of code already gets you going

sol = NDSolve[{x'[t] == 1, x[0] == 0}, x[t], {t, 0, 2},
        StoppingTest :> {x[t] > 1}][[1]];
tmax = (x[t] /. sol)[[0, 1, 1, 2]]

Bye
Ben

On 7 Aug., 07:48, Mike <mj... at comcast.net> 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}]




  • Prev by Date: Re: How show Locator point and its image under a function?
  • Next by Date: Re: problems with delayed write: tag list
  • Previous by thread: Projectile motion
  • Next by thread: Re: Projectile motion