Re: drawing polygon diagonals
- To: mathgroup at smc.vnet.net
- Subject: [mg112376] Re: drawing polygon diagonals
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sat, 11 Sep 2010 05:45:27 -0400 (EDT)
Manipulate[Module[ {pts, allPts = {Cos[#], Sin[#]} & /@ (2 Pi* Range[0, max - 1]/max)}, pts = func[allPts, Min[n, max]]; Graphics[{Blue, Line /@ Subsets[pts, {2}], AbsolutePointSize[8], Red, Point[pts]}, PlotRange -> 1.05 {{-1, 1}, {-1, 1}}]], {{max, 12}, Range[8, 20]}, {func, {Take, RandomSample}}, {n, 1, max, 1, Appearance -> "Labeled"}] Manipulate[Module[ {pts, allPts = {Cos[#], Sin[#]} & /@ (2 Pi* Range[0, max - 1]/max)}, pts = Take[allPts, Min[n, max]]; Graphics[{Magenta, Line /@ Subsets[pts, {2}], Black, AbsoluteThickness[1.25], Line /@ Subsets[Most[pts], {2}], AbsolutePointSize[8], Red, Point[pts]}, PlotRange -> 1.05 {{-1, 1}, {-1, 1}}]], {{max, 12}, Range[8, 20]}, {n, 1, max, 1, Appearance -> "Labeled"}] Bob Hanlon ---- MH <matthewhoek at gmail.com> wrote: ============= Thanks for your help, Dan & Sjoerd! I have one more question because as I was working with this, I thought of a small improvement. For now, I'll assume my biggest n-value is 12, so the current Manipulate statement finishes with a dodecagon. The current code generates a triangle, then a square with its diagonals, then a pentagon with its diagonals, then a hexagon, and so on, up to a dodecagon with all its diagonals. Each step shows a regular polygon with all its diagonals. It'd be nice, though, if as n increased (with the slider) the vertices of the dodecagon appeared one at a time in the correct place, and the lines between them also appeared. For example, when n is 5 (and not yet all the way to 12), there'd be five red circles but they would NOT form a regular pentagon. Instead, they'd be in the correct position to be vertices of a regular dodecagon. This would be cool because a large collection of lines would not change from one n-value to the next. Your eye would be drawn only to the new lines when you add each circle. And if the new lines could appear in a separate color -- oh wow, that'd be great. (For my purposes, those are the new handshakes when you add each person.) I hope this makes sense. I'll do some more looking in the DocCenter. Thanks! I appreciate your help and guidance. MH