Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Wheel[road_, x_, xmax_] :=
- NDSolve[{\[Theta]'[x] == -1/func, \[Theta][0] == -Pi/
- 2}, \[Theta], {x, 0, xmax}];
- PolygonRoad[x_, sides_] :=
- Module[{\[Alpha] = ArcSinh[Tan[Pi/sides]]},
- -Cosh[If[x >= 0,
- NestWhile[# - 2 \[Alpha] &, x, Abs[#] >= \[Alpha] &],
- NestWhile[# + 2 \[Alpha] &, x, Abs[#] >= \[Alpha] &]]]
- ];
- frame[xt_] := Module[{soln},
- func = PolygonRoad[x + xt, 6];
- (*func=Cos[x+xt]-Sqrt[17];*)
- xmax = 3 Pi;
- soln = Wheel[func, x, xmax];
- Show[
- ParametricPlot[-func First[{Cos[\[Theta][x]],
- Sin[\[Theta][x]]} /. soln], {x, 0, xmax}, Axes -> None,
- PlotRange -> {{-xmax/3, xmax/3}, {-2, 2}}],
- Plot[func, {x, -xmax/3, xmax/3}, Axes -> None]
- ]];
- Manipulate[frame[xt], {xt, 0, Pi/2}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement