Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dx = 0.05;
- xmax = Pi;
- colorscheme = "BlueGreenYellow";
- (*t, (y, \[Theta])*)
- points = {
- {0, {2.5, 0}},
- {1, {0.5, 0}},
- {2, {2.5, 0}},
- {3, {2.5, 0.448}},
- {4, {0.5, 0.448}},
- {5, {2.5, 0.448}},
- {6, {2.5, 0.5}},
- {7, {0.5, 0.5}},
- {8, {2.5, 0.5}},
- {9, {2.5, 1}}
- };
- f = Interpolation[points, InterpolationOrder -> 1];
- \[Tau][t_] := Sum[0.5 + 0.5 Tanh[6 (t - i - 0.5)], {i, 0, 9}];
- frame[t_] :=
- With[{y = f[\[Tau][t]][[1]], \[Theta] = f[\[Tau][t]][[2]]},
- Graphics[{
- (*wave 2*){
- EdgeForm[Black],
- Table[{
- FaceForm[ColorData[colorscheme][0.5 + 0.5 Sin[2 Pi x]]],
- Rectangle[{x,
- Max[y , 1 + 0.5 Sin[2 Pi (x - \[Theta])]]}, {x + dx,
- Max[y , 1 + 0.5 Sin[2 Pi (x - \[Theta])]] +
- 1 + 0.5 Sin[2 Pi x]}]
- }
- , {x, 0, xmax, dx}]
- },
- (*wave 1*){
- EdgeForm[Black],
- Table[{
- FaceForm[
- ColorData[colorscheme][0.5 + 0.5 Sin[2 Pi (x - \[Theta])]]],
- Rectangle[{x, 0}, {x + dx,
- 1 + 0.5 Sin[2 Pi ( x - \[Theta])]}]
- }
- , {x, 0, xmax, dx}]
- }
- }, PlotRange -> {{0, xmax}, {0, 4}}, AspectRatio -> 0.6]
- ];
- Manipulate[frame[t], {t, 0, 9}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement