Entrada destacada

Distancia media de dos puntos en un cuadrado unitario

martes, 5 de octubre de 2021

Movimiento de una bola bajo la acción de la gravedad

 Descargar como Notebook


Se simula el movimiento de una bola que es lanzada desde una altura h, con una velocidad horizontal y sobre la cual únicamente  actúa la gravedad.

Rebotando en el piso

g = 9.81;
tmax = 10;
rebote = ReflectionTransform[{1, 0}][{-x'[t], -y'[t]}];
Manipulate[
 solucion[x0_, y0_] := 
  NDSolveValue[{y''[t] == -g, x''[t] == 0, x'[0] == v0, y'[0] == 0, 
    x[0] == x0, y[0] == y0, 
    WhenEvent[y[t] == 0, {x'[t], y'[t]} -> Evaluate[rebote]]}, {x, 
    y}, {t, 0, tmax}];
 {xf1, yf1} = solucion[-0.9, h];
 Show[If[Trayectoria, ParametricPlot[{xf1[t], yf1[t]}, {t, 0, ttt}], 
   ParametricPlot[{0, 0}, {t, 0, 1}]], 
  Graphics[{{Thickness[0.1], Red, 
     Line[{{-1, -0.1}, {1, -0.1}}]}, {PointSize[0.03], Blue, 
     Point[{xf1[ttt], yf1[ttt]}]}}], Axes -> False, 
  Background -> Black, 
  PlotRange -> {{-1, 1}, {-0.1, 1.5}}], {{v0, 0.3, 
   "Velocidad Inicial Horizontal"}, 0, 1}, {{h, 0.8, "Altura"}, 0.2, 
  1}, {{ttt, 0.00001, "Acción"}, 0.00001, tmax, Trigger, 
  DefaultDuration -> 15}, {Trayectoria, {False, True}}]





Rebotando en una escalera

Ahora la bola es lanzada en una escalera.

g = 9.81;
tmax = 40;
rebote = ReflectionTransform[{1, 0}][{-x'[t], -y'[t]}];
graf1 = Plot[Floor[-x], {x, -10, 10}, PlotStyle -> Red, 
   PlotRange -> 10];
Manipulate[
 solucion[x0_, y0_] := 
  NDSolveValue[{y''[t] == -g, x''[t] == 0, x'[0] == v0, y'[0] == 0, 
    x[0] == x0, y[0] == y0, 
    WhenEvent[
     y[t] == Floor[-x[t]], {x'[t], y'[t]} -> Evaluate[rebote]]}, {x, 
    y}, {t, 0, tmax}];
 {xf1, yf1} = solucion[-5., h];
 Show[graf1, 
  If[Trayectoria, ParametricPlot[{xf1[t], yf1[t]}, {t, 0, ttt}], 
   graf1], Graphics[{{PointSize[0.03], Blue, 
     Point[{xf1[ttt], yf1[ttt]}]}}], Ticks -> None, Axes -> False, 
  Background -> Black], {{v0, 0.3, "Velocidad Inicial Horizontal"}, 0,
   1}, {{h, 9, "Altura"}, 5, 10}, {{ttt, 0.00001, "Acción"}, 0.00001, 
  tmax, Trigger, DefaultDuration -> 20}, {Trayectoria, {False, True}}]




Para aprender más sobre Mathematica ingrese aquí sitio de aprendizaje de Wolfram o en mi website ustamathematica.wixsite.com/basicas


No hay comentarios.:

Publicar un comentario