Advertisement
Matthen

Weird Wheels & Roads

Jun 4th, 2011
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. Wheel[road_, x_, xmax_] :=
  2.  
  3. NDSolve[{\[Theta]'[x] == -1/func, \[Theta][0] == -Pi/
  4. 2}, \[Theta], {x, 0, xmax}];
  5. PolygonRoad[x_, sides_] :=
  6. Module[{\[Alpha] = ArcSinh[Tan[Pi/sides]]},
  7. -Cosh[If[x >= 0,
  8. NestWhile[# - 2 \[Alpha] &, x, Abs[#] >= \[Alpha] &],
  9. NestWhile[# + 2 \[Alpha] &, x, Abs[#] >= \[Alpha] &]]]
  10. ];
  11. frame[xt_] := Module[{soln},
  12. func = PolygonRoad[x + xt, 6];
  13. (*func=Cos[x+xt]-Sqrt[17];*)
  14. xmax = 3 Pi;
  15. soln = Wheel[func, x, xmax];
  16. Show[
  17. ParametricPlot[-func First[{Cos[\[Theta][x]],
  18. Sin[\[Theta][x]]} /. soln], {x, 0, xmax}, Axes -> None,
  19. PlotRange -> {{-xmax/3, xmax/3}, {-2, 2}}],
  20. Plot[func, {x, -xmax/3, xmax/3}, Axes -> None]
  21. ]];
  22. Manipulate[frame[xt], {xt, 0, Pi/2}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement