Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: custom label/display for a Manipulate slider?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129259] Re: custom label/display for a Manipulate slider?
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Thu, 27 Dec 2012 05:07:08 -0500 (EST)
  • 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: <20121225070029.96EEF683F@smc.vnet.net>

First, you do not need a Show for a single Graphics. To display exact
values use a full range of values rather than a subset of specific
values. All of your specified values are multiples of Pi/12.

And @@ (MemberQ[
     Range[0, 2 Pi, Pi/12], #] & /@ ({0, 1/6, 1/4, 1/3, 1/2, 2/3, 3/4, 5/6, 1,
       7/6, 5/4, 4/3, 3/2, 5/3, 7/4, 11/6, 2} Pi))

True

Manipulate[
 Graphics[{
   {Gray,
    Circle[{0, 0}, 1]},
   {Darker[Green, 0.2], Thick,
    Circle[{0, 0}, 1, {0, theta}]},
   {Darker[Gray],
    Line[{
      {0, 0},
      {Cos[theta], Sin[theta]}}]},
   {Darker[Blue, 0.1], Thickness[0.006],
    Line[{
      {Cos[theta], 0},
      {Cos[theta], Sin[theta]}}]},
   {Darker[Red, 0.1], Thickness[0.006],
    Line[{
      {0, 0},
      {Cos[theta], 0}}]}},
  PlotRange -> 2,
  ImageSize -> 300,
  Axes -> True,
  Ticks -> {{-1, 1}, {-1, 1}}],
 {{theta, 0, \[Theta]}, 0, 2 Pi, Pi/12,
  Appearance -> "Labeled"}]


Bob Hanlon


On Tue, Dec 25, 2012 at 2:00 AM, David <dkehlenbeck at gmail.com> wrote:
> Hi,
>
> So I'm trying to make a somewhat simple unit-circle, and have a slider control within Manipulate that lets the user change theta at the usual steps from 0 to 2Pi. When I use Appearance ->"Labeled" for the slider, it shows the value of theta but in decimals - is there any way to make it show the exact values? I'm assuming I'd have to type out that list somewhere in the code, but as I move the slider, I want it to display Pi/6, 4Pi/3, etc. Is there an easy way to do this?
>
> Thanks!
> David
>
> Manipulate[
>  Show[
>   Graphics[{
>     {Gray, Circle[{0, 0}, 1]},
>     {Darker[Green, 0.2], Thick, Circle[{0, 0}, 1, {0, theta}]},
>     {Darker[Gray], Line[{{0, 0}, {Cos[theta], Sin[theta]}}]},
>     {Darker[Blue, 0.1], Thickness[0.006],
>      Line[{{Cos[theta], 0}, {Cos[theta], Sin[theta]}}]},
>     {Darker[Red, 0.1], Thickness[0.006],
>      Line[{{0, 0}, {Cos[theta], 0}}]},
>     {}
>     }],
>   PlotRange -> 2, ImageSize -> 300, Axes -> True,
>   Ticks -> {{-1, 1}, {-1, 1}}
>   ],
>  {theta, {0, \[Pi]/6, \[Pi]/4, \[Pi]/3, \[Pi]/2, 2 \[Pi]/3, 3 \[Pi]/4,
>     5 \[Pi]/6, \[Pi], 7 \[Pi]/6, 5 \[Pi]/4, 4 \[Pi]/3, 3 \[Pi]/2,
>    5 \[Pi]/3, 7 \[Pi]/4, 11 \[Pi]/6, 2 \[Pi]}, ControlType -> Slider,
>   Appearance -> "Labeled"
>   }]
>



  • Prev by Date: Re: Modeling of NFL game results
  • Next by Date: Slow Refresh of Dynamic Tooltip with ListDensityPlot
  • Previous by thread: custom label/display for a Manipulate slider?
  • Next by thread: Re: custom label/display for a Manipulate slider?