MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: drawing polygon diagonals

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123961] Re: drawing polygon diagonals
  • From: Ralph Dratman <ralph.dratman at gmail.com>
  • Date: Mon, 2 Jan 2012 02:47:59 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <i6755n$873$1@smc.vnet.net>

How about

CompleteGraph[6]

Would that serve your purpose?


Ralph



On Sun, Jan 1, 2012 at 2:30 AM, Chris Young <cy56 at comcast.net> wrote:
> On 2010-09-08 04:58:31 +0000, MH said:
>
>> Hi,
>>
>> This seems basic but it has me stumped.  I'm trying to illustrate the
>> idea of the "handshake problem", where small circles represent people
>> and the lines between the circles represent handshakes.  With the code
>> below, I'm able to show (and manipulate) any number of circles, and
>> I'm also able to show the lines between adjacent circles.  This just
>> generates a polygon whose vertices are all connected, as it should.
>> But how can I update my code to show the diagonals, too, and not just
>> the sides of the polygon?  I'm not sure what to add.
>
> To get some practice with GraphicsComplex, I spent some time figuring
> out how to distinguish the diagonals from the other line segments.
> Thanks very much to the others who explained GraphicsComplex. It looks
> like a big time-saver. It must also help when figuring out shared
> borders of polygons, since the indices are just integers, rather than
> the real numbers you'd need to match up vertices.
>
> There's a screen shot at
> http://home.comcast.net/~cy56/DiagonalsOfPolygon.png
> and a notebook at
> http://home.comcast.net/~cy56/DiagonalsOfPolygon.nb
>
> I use short horizontal lines, via the keyboard shortcut esc-hline-esc
> (where "esc" stands for the Escape key) to distinguish any names I use
> starting with a capital letter from Mathematica's functions. I use two
> of them in a row to separate words in a Boolean flag, such as
> "show_border", since we can't use the underscore character, which is
> reserved for pattern matching. Apparently, Mathematica will allow a lot
> of these special characters in names, which is very handy.
>
>
> Manipulate[
>  Module[
>  {P = \[HorizontalLine]CrcPts[n]},
>  Graphics[
>   GraphicsComplex[
>    P,
>    {
>     PointSize[Large],
>
>     If[show\[HorizontalLine]\[HorizontalLine]points,
>      Table[{Hue[(k - 1)/n], Point[k], Black,
>        Text[k, P[[k]], -2.5*P[[k]]]}, {k, 1, n}]
>      ],
>
>     If[show\[HorizontalLine]\[HorizontalLine]border,
>      {Thick, Line[Range[1, n]~Append~1]}
>      ],
>
>     If[show\[HorizontalLine]\[HorizontalLine]diagonals,
>      {Thin, Dashed,
>       Line[Select[
>         Subsets[Range[1, n], {2}], #[[2]] - #[[1]] > 1 &]]}
>      ]
>     }
>    ]]],
>  {{show\[HorizontalLine]\[HorizontalLine]points, True}, {True, False}},
>  {{show\[HorizontalLine]\[HorizontalLine]border, True}, {True, False}},
>  {{show\[HorizontalLine]\[HorizontalLine]diagonals, True}, {True,
>   False}},
>
>  {{n, 6}, 2, 12, 1}
>  ]
>
>



  • Prev by Date: Re: How can I rasterize the selection in a notebook, preserving In/Out labels when appropriate?
  • Next by Date: Re: Erf funcion
  • Previous by thread: Re: drawing polygon diagonals
  • Next by thread: Re: drawing polygon diagonals