Advertisement
Guest User

Generation of animations for Physics.SE question 466367

a guest
Mar 15th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. (* Author: Ruslan Kabatsayev. I place this code in public domain. *)
  2. wave[x_] = Piecewise[{{Cos[x], x < 0},
  3. {Cos[x/Sqrt[2]]^2, x < Pi/Sqrt[2]}},
  4. 0]
  5. show[t_, reflectedAmplitude_] := With[{circleRadius = 0.2}, Show[
  6. Graphics[{
  7. {If[reflectedAmplitude != 1, Lighter[Gray], Transparent],
  8. Rectangle[{0, -(1 + reflectedAmplitude) - 2*circleRadius},
  9. {4*circleRadius, (1 + reflectedAmplitude) + 2*circleRadius}]},
  10. {Thick, Darker[Gray], Line[{{0, -(1 + reflectedAmplitude) - 2*circleRadius},
  11. {0, (1 + reflectedAmplitude) + 2*circleRadius}}]},
  12. Circle[{0, (1 + reflectedAmplitude)*wave[-t]}, circleRadius]
  13. }],
  14. Plot[{wave[x - t] + reflectedAmplitude*wave[-t - x]}, {x, -25, -circleRadius},
  15. PlotRange -> All, Exclusions -> None, PlotStyle -> Directive[Thick, Brown]],
  16. PlotRange -> All, ImageSize -> 700, AspectRatio -> Automatic, Axes -> False]
  17. ]
  18. Monitor[tab=Table[show[t,1],{t,-27,50,0.2}];,t]
  19.  
  20. Monitor[Do[
  21. Export["/tmp/full-refl-frame-" <> ToString[1000 + n] <> ".bmp",
  22. tab[[n]]], {n, Length@tab}], {n, Length@tab}]
  23.  
  24. Monitor[tabPartialReflection = Table[show[t, 0.3], {t, -27, 50, 0.2}];, t]
  25.  
  26. Monitor[Do[
  27. Export["/tmp/partial-refl-frame-" <> ToString[1000 + n] <> ".bmp",
  28. tabPartialReflection[[n]]], {n, Length@tabPartialReflection}], {n,
  29. Length@tabPartialReflection}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement