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
Replies: 6   Last Post: Apr 13, 2013 8:36 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bob Hanlon

Posts: 906
Registered: 10/29/11
Re: Arranging disks (or any object for that matter) be
Posted: Apr 13, 2013 8:36 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


turtle[pos_: {0, 0}, scale_: 1] :=
Module[
{x = pos[[1]], y = pos[[2]]},
{Thickness[scale/16],
Circle[{x - scale, y + .7 scale}, .5 scale, {8 Pi/6, 3 Pi/2}],
EdgeForm[Directive[Thick, White]],
Disk[{x + scale, y}, .5 scale, {0, Pi}],
Disk[{x, y}, scale, {0, Pi}],
Disk[{x - .5 scale, y}, .25 scale, {Pi, 2 Pi}],
Disk[{x + .5 scale, y}, .25 scale, {Pi, 2 Pi}],
White,
Disk[{x + 1.2 scale, y + .3 scale}, .04 scale]}]
Manipulate[Module[{a, pos, scale},
Graphics[
Table[
a = -((Pi*(-2 + n + 2*r))/n);
pos = {Cos[a], Sin[a]};
scale = 2.5/Max[8, n];
{Darker[Green],
shape[pos, scale],
Text[Style[r, Orange, "Label",
Floor[2 (313 - 9*n)/19]],
pos + If[shape == turtle, {0, .5 scale}, 0]]},
{r, 1, n}],
ImageSize -> {350, 350}]],
{{shape, turtle, "Shape"},
{Disk -> "Disk", turtle -> "Turtle"},
ControlType -> SetterBar},
{{n, 1, "Number \nof Disks"}, 1, 20, 1,
Appearance -> "Labeled"}]



Bob Hanlon




On Sat, Apr 13, 2013 at 2:02 AM, Clif McInnis <c_mcinnis@hotmail.com> wrote:

> Bob,
>
> Thank you, that works very well. I am wondering if it is possible to put
> an object in the place of the disk. I have a little turtle shape (the code
> below)that I had tried to substitute for the line " Disk[{Cos[a], Sin[a]},
> 3/Max[8, n]]" which did not work out too well. My guess is that it would
> work if I would assign the {x,y} values of the semi disk that makes the
> shell to Cos[a],Sin[a] and then related the other parts of the shape to
> those coordinates, however before I undertook that endeavor I thought that
> I would just ask you to give me a yes/no answer as to whether it would even
> be a possibility. Again Thank You for your help.
>
> Sincerely -- Clifton McInnis
>
>
> Graphics[{
> Darker[Green], Thickness[1/32],
> Circle[{-1, .7}, .5, {8 Pi/6, 3 Pi/2}],
> EdgeForm[Directive[Thick, White]], Disk[{1, 0}, .5, {0, Pi}],
> Disk[{0, 0}, 1, {0, Pi}], Disk[{-.5, 0}, .25, {Pi, 2 Pi}],
> Disk[{.5, 0}, .25, {Pi, 2 Pi}], White, Disk[{1.2, .3}, .04]}]
>
>





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.