Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- poly[n_, e_] := Table[
- {2 e + e Cos[2.0 Pi (i + 0.5) / n]/2, Sin[2.0 Pi (i + 0.5) /n]/2}
- , {i, n + 1}];
- lengths[n_, e_] := With[{p = poly[n, e]},
- Map[
- Norm[First[#] - Last[#]] &,
- Transpose[{p[[2 ;;]], p[[;; -2]]}]
- ]
- ];
- length[n_, e_] := Total[lengths[n, e]];
- Manipulate[
- Module[{p, acc},
- p = poly[n, e];
- acc = Join[{0}, Accumulate[lengths[n, e]]];
- Show[{
- Graphics[{
- {
- Table[
- {GrayLevel[0.7], Line[{{0, y}, {2, y}}],
- Black,
- Text[Style[y, FontSize -> Medium], {-0.1, y}]
- }
- , {y, {0.5, 1, 1.5, 2.0, 2.5, 3.0, Pi}}]
- },
- Point[{2 e, 0}],
- Point[{2 e, length[n, e]}],
- Table[
- {
- PointSize[Large],
- Thick,
- ColorData["DarkRainbow"][i/n],
- Line[{{2 e, acc[[i]]}, {2 e, acc[[i + 1]]}}],
- Point[{2 e, acc[[i]]}],
- Point[p[[i]]],
- Line[{p[[i]], p[[i + 1]]}]
- },
- {i, Length[acc] - 1}
- ]
- }, PlotRange -> {{-0.4, 2.6}, {-0.6, 3.2}}],
- Plot[{
- length[n, et/2]
- }, {et, 0, 2}, PlotRange -> All]
- }]
- ],
- {n, 3, 20, 1},
- {{e, 1}, 0.01, 1}
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement