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

MathGroup Archive 2010

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

Search the Archive

Re: Locator Manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113282] Re: Locator Manipulate
  • From: Fred Klingener <gigabitbucket at BrockEng.com>
  • Date: Thu, 21 Oct 2010 07:05:28 -0400 (EDT)
  • References: <i9jq3k$ohm$1@smc.vnet.net>

On Oct 19, 5:58 am, roby <roby.no... at gmail.com> wrote:
> Dear all !
>
> I am trying (hard) to use an individual Locator inside Manipulate.
>
> While the plain version works:
>
> Manipulate[Graphics[Circle[{0, 0}, 10]],
> {{p, {0, 0}}, Locator}]
>
> The individual version restricts the movement to {{0,0},{1,1}}, any
> hints ?
>
> Manipulate[Graphics[Circle[{0, 0}, 10]],
> {{p1, {0, 0}}, Locator[#] &, ControlType -> Locator}]
>
> Regards Robert

(* This sets Locator limits to the graphics extent: *)

Manipulate[
 Column[{
   Dynamic[p1]
   , Graphics[Circle[{0, 0}, 10]]
   }]
 , {{p1, {0, 0}}
  , {-10, -10}
  , {+10, +10}
  , Locator[#] &
  , ControlType -> Locator}
 ]

(* This is a way to constrain the Locator inside the Circle
(after you get it running, you probably want to turn off the
original Locator graphic with an Appearance->None) *)

Manipulate[
 DynamicModule[{p2 = If[Norm[p1] > 10, 10 p1/Norm[p1], p1]}
  , Column[{
    Dynamic[p1]
    , Dynamic[p2]
    , Graphics[{
      Circle[{0, 0}, 10]
      , Red
      , Disk[p2, 0.5]
      }]
    }]
  ]
 , {{p1, {10, 0}}
  , {-10, -10}
  , {+10, +10}

  , ControlType -> Locator}
 ]

(* and this is a way to constrain the Locator to run on the Circle
itself. *)

Manipulate[
 DynamicModule[{p2 = 10 p1/Norm[p1]}
  , Column[{
    Dynamic[p1]
    , Dynamic[p2]
    , Graphics[{
      Circle[{0, 0}, 10]
      , Red
      , Disk[p2, 0.5]
      }]
    }]
  ]
 , {{p1, {10, 0}}
  , {-10, -10}
  , {+10, +10}

  , ControlType -> Locator}
 ]

Hth,
Fred Klingener


  • Prev by Date: Re: := vs = in some function definitions
  • Next by Date: Re: Table of tables
  • Previous by thread: Locator Manipulate
  • Next by thread: Re: Locator Manipulate