MathGroup Archive 2013

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

Search the Archive

Re: Arranging disks (or any object for that matter) be arranged in a

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130455] Re: Arranging disks (or any object for that matter) be arranged in a
  • From: "djmpark" <djmpark at comcast.net>
  • Date: Fri, 12 Apr 2013 02:17:05 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <12818976.190.1365668273916.JavaMail.root@m06>

That Manipulate has a minor problem in that a Slider is not the most
appropriate method for selecting a small positive integer. A SetterBar might
be better. It has a major problem in that it fails to provide a fixed
background. Every dynamic presentation requires a fixed background. In this
case the size of the circles and display should be fixed but here the entire
display changes when there is only one disk. Another minor problem is that
Orange characters on a Green background is not as readable as we might wish.

The following is a custom dynamic display constructed with the Presentations
Application. It contains a number of "convenience routines" that I believe
make it fairly easy to construct custom dynamic displays.

<< Presentations` 

First we write a specification for the labeled disks. In this case it is
convenient to define positions as numbers in the complex plane. So
ComplexText centers text at the complex location z. ComplexCirclePoint draws
an outlined colored disk of a given point size at z. I decided to go with
Black characters on regular Green disks.

ComplexLabeledDisk[z_, n_] := {ComplexCirclePoint[z, 20, Black, Green],
Black, 
  ComplexText[Style[n, 24], z]} 

The following is the specification for the dynamic presentation, which I
hope is rather intuitive. The constructions pagelet and phrase are basically
shortcuts for Column and Row constructions without the braces.
The second argument in Dynamic allows us to calculate the angle in the
complex plane each time the number of disks is reset. I decided to allow
zero disks as one choice. Draw2D is basically the same as Graphics but with
its own set of Options. The background for the display is invariant and the
first disk, when present, always appears in the same place.

DynamicModule[{numDisks = 0, angle = 0},
 pagelet[
  phrase["Number of Disks:", Spacer[10], 
   SetterBar[
    Dynamic[numDisks, (numDisks = #; 
       angle = 2 \[Pi]/Max[1, numDisks]) &], Range[0, 5]]],
  Draw2D[
   {Dynamic@
     Table[
      ComplexLabeledDisk[Exp[I (nn - 1) angle], nn], {nn, 1,  numDisks}]},
   PlotRange -> 1.7,
   Background -> LightBrown,
   ImageSize -> 300]
  ]
 ]


David Park
djmpark at comcast.net 
http://home.comcast.net/~djmpark/index.html 




From: Clif McInnis [mailto:c_mcinnis at hotmail.com] 

I am looking for a way that I might be able to make the disks (or any object
for that matter) be arranged in a circular or pentagonal arrangement as
opposed to rows. I tried looking at the "Sum of Empty Skies for a Set of
Planets" to see how the "planets" were arranged, but I could not figure out
how the code worked. I am thinking that there might be a function that I
have not considered, and would appreciate if someone could point me in the
right direction.

Manipulate[Pane[Row[Table[Graphics[{
      Darker[Green],
      Disk[{0, 0}, .5],
      Text[Style[numerals[[ r]], Orange, "Label", 24], {0, 0}]}], {r,
     1, n}]], {325, 300},
  BaseStyle -> {LinebreakAdjustments -> {1., 10, 0, 0, 10}}], {{n, 1,
   "Number \nof Disks"}, 1, 5, 1}, Initialization :> (
   numerals = {"1", "2", "3", "4", "5"};)]




  • Prev by Date: Re: "Programming With Mathematica" Exercise help
  • Next by Date: Re: "Programming With Mathematica" Exercise help
  • Previous by thread: Re: Arranging disks (or any object for that matter) be
  • Next by thread: computation SeriesCoefficient