Skip to main content
add movement
Source Link
Nasser
  • 150.3k
  • 12
  • 161
  • 374

Update: reply to comment to display the move of the ball. Here is a quick Manipulate. You can make improvement as needed

enter image description here

Manipulate[
 tick;
 
 g = 9.82; y0 = 1; v = 0;
 h = h + v*t - g t^2/2;
 ymin = y0 Sin[w t];
 If[h - radius > ymin + thick, tick = Not[tick]; t = t + delT];
 Grid[{
   {"time", "h"},
   {t, h},
   {
    Graphics[
     {
      {Black, Disk[{0, h}, radius]},
      {Blue, Rectangle[{-1, ymin}, {1, ymin + .2}]},
      If[h - radius <= (ymin + thick),
       {Red, Style[Text["Crash!", {1.5 radius, ymin + 2 thick}], 14]}
       ]
      },
     PlotRange -> {{-1, 1}, {0, 5.5}}, AspectRatio -> Automatic, Axes -> True, 
        ImageSize -> 200], SpanFromLeft
    }
   }, Spacings -> {.1, .2}, Frame -> All, FrameStyle -> LightGray]
 ,
 Button["Run", h = 5; t = 0; ymin = 0; tick = Not[tick]],
 {{w, 1, "omega?"}, 0, 10, .1, ImageSize -> Small, Appearance -> "Labeled"},
 {{delT, 0.001, "animation speed?"}, 0.0001, 0.01, .0001, ImageSize -> Small, 
       Appearance -> "Labeled"},
 {{tick, True}, None},
 {{h, 5}, None},
 {{t, 0}, None},
 {{ymin, 0}, None},
 {{thick, 0.2}, None},
 {{radius, 0.1}, None},
 TrackedSymbols :> {tick}
 ]

Original answer

If you tell NSolve that time is positive (which it is), it can solve it

g = 9.82;
w = 0.5;
h = 5;
y0 = 1;
v = 0;

NSolve[h + v  t - (g t^2)/2 == y0 Sin[w t] && t > 0, t]

Mathematica graphics

If you tell NSolve that time is positive (which it is), it can solve it

g = 9.82;
w = 0.5;
h = 5;
y0 = 1;
v = 0;

NSolve[h + v  t - (g t^2)/2 == y0 Sin[w t] && t > 0, t]

Mathematica graphics

Update: reply to comment to display the move of the ball. Here is a quick Manipulate. You can make improvement as needed

enter image description here

Manipulate[
 tick;
 
 g = 9.82; y0 = 1; v = 0;
 h = h + v*t - g t^2/2;
 ymin = y0 Sin[w t];
 If[h - radius > ymin + thick, tick = Not[tick]; t = t + delT];
 Grid[{
   {"time", "h"},
   {t, h},
   {
    Graphics[
     {
      {Black, Disk[{0, h}, radius]},
      {Blue, Rectangle[{-1, ymin}, {1, ymin + .2}]},
      If[h - radius <= (ymin + thick),
       {Red, Style[Text["Crash!", {1.5 radius, ymin + 2 thick}], 14]}
       ]
      },
     PlotRange -> {{-1, 1}, {0, 5.5}}, AspectRatio -> Automatic, Axes -> True, 
        ImageSize -> 200], SpanFromLeft
    }
   }, Spacings -> {.1, .2}, Frame -> All, FrameStyle -> LightGray]
 ,
 Button["Run", h = 5; t = 0; ymin = 0; tick = Not[tick]],
 {{w, 1, "omega?"}, 0, 10, .1, ImageSize -> Small, Appearance -> "Labeled"},
 {{delT, 0.001, "animation speed?"}, 0.0001, 0.01, .0001, ImageSize -> Small, 
       Appearance -> "Labeled"},
 {{tick, True}, None},
 {{h, 5}, None},
 {{t, 0}, None},
 {{ymin, 0}, None},
 {{thick, 0.2}, None},
 {{radius, 0.1}, None},
 TrackedSymbols :> {tick}
 ]

Original answer

If you tell NSolve that time is positive (which it is), it can solve it

g = 9.82;
w = 0.5;
h = 5;
y0 = 1;
v = 0;

NSolve[h + v  t - (g t^2)/2 == y0 Sin[w t] && t > 0, t]

Mathematica graphics

Source Link
Nasser
  • 150.3k
  • 12
  • 161
  • 374

If you tell NSolve that time is positive (which it is), it can solve it

g = 9.82;
w = 0.5;
h = 5;
y0 = 1;
v = 0;

NSolve[h + v  t - (g t^2)/2 == y0 Sin[w t] && t > 0, t]

Mathematica graphics