Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Arranging disks (or any object for that matter) be arranged in a
Replies: 1   Last Post: Apr 12, 2013 2:15 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
David Park

Posts: 1,560
Registered: 5/19/07
Re: Arranging disks (or any object for that matter) be arranged in a
Posted: Apr 12, 2013 2:15 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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@comcast.net
http://home.comcast.net/~djmpark/index.html




From: Clif McInnis [mailto:c_mcinnis@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"};)]





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.