public
Last active

Simple plotting in mathematica to demontrate wheel barrel effect

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
(*
Alex Beutel
July 23, 2009
Simple script to show wagon-wheel effect / stroboscopic effect
for a propeller in terms of the y coordinate vs. time and
radians vs. time. Graphs both with varying "frame-rates."
*)
f1[x_] := Cos[x];
f2[x_] := Cos[x + 2 \[Pi]/3];
f3[x_] := Cos[x + 4 \[Pi]/3];
g1[x_] := Mod[x - .00001, 2 \[Pi]];
g2[x_] := Mod[x - .00001 + 2 \[Pi]/3, 2 \[Pi]];
g3[x_] := Mod[x - .00001 + 4 \[Pi]/3, 2 \[Pi]];
draw[o_] :=
(l1 = Line[{{0, 1.5}, {0 \[Pi], -1.5}}];
l2 = Line[{{4 \[Pi] - o, 1.5}, {4 \[Pi] - o, -1.5}}];
l3 = Line[{{8 \[Pi] - 2 o, 1.5}, {8 \[Pi] - 2 o, -1.5}}];
l4 = Line[{{12 \[Pi] - 3 o, 1.5}, {12 \[Pi] - 3 o, -1.5}}];
p1 = Point[{0 \[Pi], 1}];
p2 = Point[{4 \[Pi] - o,
Max[f1[4 \[Pi] - o], f2[4 \[Pi] - o], f3[4 \[Pi] - o]]}];
p3 = Point[{8 \[Pi] - 2 o,
Max[f1[8 \[Pi] - 2 o], f2[8 \[Pi] - 2 o], f3[8 \[Pi] - 2 o]]}];
p4 = Point[{12 \[Pi] - 3 o,
Max[f1[12 \[Pi] - 3 o], f2[12 \[Pi] - 3 o],
f3[12 \[Pi] - 3 o]]}];
l1a = Line[{{0 \[Pi], 0}, {0 \[Pi], 2 \[Pi]}}];
l2a = Line[{{4 \[Pi] - o, 0}, {4 \[Pi] - o, 2 \[Pi]}}];
l3a = Line[{{8 \[Pi] - 2 o, 0}, {8 \[Pi] - 2 o, 2 \[Pi]}}];
l4a = Line[{{12 \[Pi] - 3 o, 0}, {12 \[Pi] - 3 o, 2 \[Pi]}}];
p1a = Point[{0 \[Pi], Max[g1[0 \[Pi]], g2[0 \[Pi]], g3[0 \[Pi]]]}];
p2a = Point[{4 \[Pi] - o,
Max[g1[4 \[Pi] - o], g2[4 \[Pi] - o], g3[4 \[Pi] - o]]}];
p3a = Point[{8 \[Pi] - 2 o,
Max[g1[8 \[Pi] - 2 o], g2[8 \[Pi] - 2 o], g3[8 \[Pi] - 2 o]]}];
p4a = Point[{12 \[Pi] - 3 o,
Max[g1[12 \[Pi] - 3 o], g2[12 \[Pi] - 3 o],
g3[12 \[Pi] - 3 o]]}];
Show[Plot[{f1[x], f2[x], f3[x]}, {x, 0 \[Pi], 13 \[Pi]},
ImageSize -> Scaled[.6],
AxesLabel -> {"time", "y"}], {Graphics[{Thick, Red, l1}],
Graphics[{Thick, Red, l2}], Graphics[{Thick, Red, l3}],
Graphics[{Thick, Red, l4}],
Graphics[{PointSize[Large], Red, p1}],
Graphics[{PointSize[Large], Red, p2}],
Graphics[{PointSize[Large], Red, p3}],
Graphics[{PointSize[Large], Red, p4}]}]
Show[Plot[{g1[x], g2[x], g3[x]}, {x, 0, 13 \[Pi]},
ImageSize -> Scaled[.6],
AxesLabel -> {"time", "radians"}], {Graphics[{Thick, Red, l1a}],
Graphics[{Thick, Red, l2a}], Graphics[{Thick, Red, l3a}],
Graphics[{Thick, Red, l4a}],
Graphics[{PointSize[Large], Red, p1a}],
Graphics[{PointSize[Large], Red, p2a}],
Graphics[{PointSize[Large], Red, p3a}],
Graphics[{PointSize[Large], Red, p4a}]}])
 
 
Manipulate[draw[y], {y, 0, 2 \[Pi]/3}]
(* Enable the code below to save the above Manipulate command as a \
Flash movie *)
(*
Export["all.swf", %]
*)
Print["Standing still"]
draw[0]
Print["Going backwards"]
draw[\[Pi]/6]
Print["Flipping"]
draw[\[Pi]/3]
Print["Going forwards"]
draw[\[Pi]/2]
Print["Standing still again"]
draw[2 \[Pi]/3]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.