Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- building human rock target i oof sa wczesniej zadeklarowane jako obrazki
- building = Graphics[{Inset[Image[building, ImageSize -> {300, 300}], {0, 4}]}];
- human = Graphics[{Inset[Image[human, ImageSize -> {30, 100}], {-0.5, 9.55}]}];
- rock = Graphics[{Inset[Image[rock, ImageSize -> {20, 20}]]}];
- target = Graphics[{Inset[ Image[target, ImageSize -> {60, 20}], {10, 0}, {0, 0}, {5, 5}]}];
- oof = Graphics[{Inset[ Image[oof, ImageSize -> {60, 20}], {10.5, -1}, {0, 0}, {5, 5}]}];
- Manipulate[Module[
- (*Maths*)
- {g = 10., x, y},
- velocityMax = 10.;
- alpha = (Pi/2) - (deg*Pi/180);
- heightMax = 10;
- y = H + Tan[alpha] x - g/(2 v0^2 Cos[alpha]^2) x^2;
- xRange =
- v0 Cos[alpha] (v0 Sin[alpha] + Sqrt[v0^2 Sin[alpha]^2 + 2 g H ])/g;
- xMax = velocityMax/g Sqrt[velocityMax^2 + 2 heightMax g];
- yMax = heightMax + (velocityMax^2) /(2 g);
- optimalAlpha = (180/Pi)*ArcSin[Sqrt[v0^2/(2 (v0^2 + H g))]];
- ar = yMax/xMax;
- (* OBJECTS *)
- Cliff = Graphics[{Black, Rectangle[{-1, -1}, {0, H}]}];
- yaxis =
- Graphics[{Black, dottedLine, Line[{{0, H}, {0, H + 5}}],
- Line[{{0, H}, {ar *8*Cos[alpha], H + 8 Sin[alpha]}}]}];
- anglelabel = Graphics[{Black,
- Circle[{0, H}, 4, {alpha + .05, Pi/2}],
- Text[Style["alpha",
- FontSize -> 14], {ar*3*Cos[1/2 (alpha + Pi/2)],
- H + ar*3* Sin[1/2 (alpha + Pi/2)]}]}];
- Ground =
- Graphics[{Lighter[Brown], Rectangle[{-2, -2}, {xMax, 0.2}]}];
- velocityVector =
- Graphics[{Thick, RGBColor[1, .47, 0],
- Arrow[{{0, H}, {v0/3 ar Cos[alpha], H + v0/3 Sin[alpha]}}]}];
- dottedLine = Graphics[{Red, Disk[{0, H}, 0.1]}];
- ball = ListPlot[{{time,
- H + Tan[alpha] time - g/(2 v0^2 Cos[alpha]^2) time^2}},
- PlotStyle -> {RGBColor[.5, .5, .5], PointSize[.01]}];
- humanShow =
- Graphics[{Inset[
- Image[human, ImageSize -> {30, 40}], {-0.6, H - 0.32}]}];
- rockShow =
- Graphics[{Inset[
- Image[rock, ImageSize -> {20, 20}], {time,
- H + Tan[alpha] time - g/(2 v0^2 Cos[alpha]^2) time^2}]}];
- buildingShow =
- Graphics[{Inset[
- Image[building, ImageSize -> {300, 300}], {0, H - 5.95}]}];
- (*Drawing STUFF *)
- Show[Plot[y, {x, 0.000, xMax},
- PlotRange -> {{-2, xMax}, {-1, yMax}}, Frame -> True,
- FrameLabel -> {Row[{Style["dist", Italic], " (m)"}],
- Row[{Style["height", Italic], " (m)"}]},
- ImageSize -> 800], buildingShow, Ground, yaxis, anglelabel,
- velocityVector, target,
- If[H + Tan[alpha] time - g/(2 v0^2 Cos[alpha]^2) time^2 < 2 &&
- H + Tan[alpha] time - g/(2 v0^2 Cos[alpha]^2) time^2 > -1, oof,
- rockShow], humanShow]],
- {{deg, 90 - optimalAlpha, "Kat rzutu"}, 3, 90, .1,
- Appearance -> "Labeled"},
- {{v0, velocityMax, "Predkosc poczatkowa"}, 1/1000, velocityMax, .1,
- Appearance -> "Labeled"},
- {{H, heightMax, "Wysokosc budynku"}, 0, heightMax, .1,
- Appearance -> "Labeled"},
- {{time, .01, "Czas"}, 0, 20, .1, Appearance -> "Labeled"},
- TrackedSymbols :> Manipulate]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement