Advertisement
Aveneid

Untitled

Nov 21st, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. building human rock target i oof sa wczesniej zadeklarowane jako obrazki
  2.  
  3.  
  4. building = Graphics[{Inset[Image[building, ImageSize -> {300, 300}], {0, 4}]}];
  5. human = Graphics[{Inset[Image[human, ImageSize -> {30, 100}], {-0.5, 9.55}]}];
  6. rock = Graphics[{Inset[Image[rock, ImageSize -> {20, 20}]]}];
  7. target = Graphics[{Inset[ Image[target, ImageSize -> {60, 20}], {10, 0}, {0, 0}, {5, 5}]}];
  8. oof = Graphics[{Inset[ Image[oof, ImageSize -> {60, 20}], {10.5, -1}, {0, 0}, {5, 5}]}];
  9.  
  10. Manipulate[Module[
  11. (*Maths*)
  12. {g = 10., x, y},
  13.  
  14. velocityMax = 10.;
  15. alpha = (Pi/2) - (deg*Pi/180);
  16. heightMax = 10;
  17. y = H + Tan[alpha] x - g/(2 v0^2 Cos[alpha]^2) x^2;
  18. xRange =
  19. v0 Cos[alpha] (v0 Sin[alpha] + Sqrt[v0^2 Sin[alpha]^2 + 2 g H ])/g;
  20. xMax = velocityMax/g Sqrt[velocityMax^2 + 2 heightMax g];
  21. yMax = heightMax + (velocityMax^2) /(2 g);
  22. optimalAlpha = (180/Pi)*ArcSin[Sqrt[v0^2/(2 (v0^2 + H g))]];
  23. ar = yMax/xMax;
  24.  
  25. (* OBJECTS *)
  26.  
  27. Cliff = Graphics[{Black, Rectangle[{-1, -1}, {0, H}]}];
  28. yaxis =
  29. Graphics[{Black, dottedLine, Line[{{0, H}, {0, H + 5}}],
  30. Line[{{0, H}, {ar *8*Cos[alpha], H + 8 Sin[alpha]}}]}];
  31. anglelabel = Graphics[{Black,
  32. Circle[{0, H}, 4, {alpha + .05, Pi/2}],
  33. Text[Style["alpha",
  34. FontSize -> 14], {ar*3*Cos[1/2 (alpha + Pi/2)],
  35. H + ar*3* Sin[1/2 (alpha + Pi/2)]}]}];
  36. Ground =
  37. Graphics[{Lighter[Brown], Rectangle[{-2, -2}, {xMax, 0.2}]}];
  38.  
  39. velocityVector =
  40. Graphics[{Thick, RGBColor[1, .47, 0],
  41. Arrow[{{0, H}, {v0/3 ar Cos[alpha], H + v0/3 Sin[alpha]}}]}];
  42. dottedLine = Graphics[{Red, Disk[{0, H}, 0.1]}];
  43. ball = ListPlot[{{time,
  44. H + Tan[alpha] time - g/(2 v0^2 Cos[alpha]^2) time^2}},
  45. PlotStyle -> {RGBColor[.5, .5, .5], PointSize[.01]}];
  46.  
  47. humanShow =
  48. Graphics[{Inset[
  49. Image[human, ImageSize -> {30, 40}], {-0.6, H - 0.32}]}];
  50. rockShow =
  51. Graphics[{Inset[
  52. Image[rock, ImageSize -> {20, 20}], {time,
  53. H + Tan[alpha] time - g/(2 v0^2 Cos[alpha]^2) time^2}]}];
  54. buildingShow =
  55. Graphics[{Inset[
  56. Image[building, ImageSize -> {300, 300}], {0, H - 5.95}]}];
  57.  
  58. (*Drawing STUFF *)
  59. Show[Plot[y, {x, 0.000, xMax},
  60. PlotRange -> {{-2, xMax}, {-1, yMax}}, Frame -> True,
  61. FrameLabel -> {Row[{Style["dist", Italic], " (m)"}],
  62. Row[{Style["height", Italic], " (m)"}]},
  63. ImageSize -> 800], buildingShow, Ground, yaxis, anglelabel,
  64. velocityVector, target,
  65. If[H + Tan[alpha] time - g/(2 v0^2 Cos[alpha]^2) time^2 < 2 &&
  66. H + Tan[alpha] time - g/(2 v0^2 Cos[alpha]^2) time^2 > -1, oof,
  67. rockShow], humanShow]],
  68. {{deg, 90 - optimalAlpha, "Kat rzutu"}, 3, 90, .1,
  69. Appearance -> "Labeled"},
  70. {{v0, velocityMax, "Predkosc poczatkowa"}, 1/1000, velocityMax, .1,
  71. Appearance -> "Labeled"},
  72. {{H, heightMax, "Wysokosc budynku"}, 0, heightMax, .1,
  73. Appearance -> "Labeled"},
  74. {{time, .01, "Czas"}, 0, 20, .1, Appearance -> "Labeled"},
  75. TrackedSymbols :> Manipulate]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement