• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Interference

Matthen Feb 14th, 2015 755 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. dx = 0.05;
2. xmax = Pi;
3. colorscheme = "BlueGreenYellow";
4. (*t, (y, \[Theta])*)
5. points = {
6.    {0, {2.5, 0}},
7.    {1, {0.5, 0}},
8.    {2, {2.5, 0}},
9.    {3, {2.5, 0.448}},
10.    {4, {0.5, 0.448}},
11.    {5, {2.5, 0.448}},
12.    {6, {2.5, 0.5}},
13.    {7, {0.5, 0.5}},
14.    {8, {2.5, 0.5}},
15.    {9, {2.5, 1}}
16.    };
17. f = Interpolation[points, InterpolationOrder -> 1];
18. \[Tau][t_] := Sum[0.5 + 0.5 Tanh[6 (t - i - 0.5)], {i, 0, 9}];
19. frame[t_] :=
20.
21.   With[{y = f[\[Tau][t]][[1]], \[Theta] = f[\[Tau][t]][[2]]},
22.    Graphics[{
23.      (*wave 2*){
24.       EdgeForm[Black],
25.       Table[{
26.         FaceForm[ColorData[colorscheme][0.5 + 0.5 Sin[2 Pi x]]],
27.         Rectangle[{x,
28.           Max[y , 1 + 0.5 Sin[2 Pi (x - \[Theta])]]}, {x + dx,
29.           Max[y , 1 + 0.5 Sin[2 Pi (x - \[Theta])]] +
30.            1 + 0.5 Sin[2 Pi x]}]
31.         }
32.        , {x, 0, xmax, dx}]
33.       },
34.      (*wave 1*){
35.       EdgeForm[Black],
36.       Table[{
37.         FaceForm[
38.          ColorData[colorscheme][0.5 + 0.5 Sin[2 Pi (x - \[Theta])]]],
39.         Rectangle[{x, 0}, {x + dx,
40.           1 + 0.5 Sin[2 Pi ( x - \[Theta])]}]
41.         }
42.        , {x, 0, xmax, dx}]
43.       }
44.      }, PlotRange -> {{0, xmax}, {0, 4}}, AspectRatio -> 0.6]
45.    ];
46. Manipulate[frame[t], {t, 0, 9}]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top