MathGroup Archive 2008

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

Search the Archive

Re: Re: Question about Dynamic-ly restricting Locator position

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94613] Re: [mg94581] Re: [mg94556] Question about Dynamic-ly restricting Locator position
  • From: "David Park" <djmpark at comcast.net>
  • Date: Wed, 17 Dec 2008 06:36:14 -0500 (EST)
  • References: <11470788.1229426303043.JavaMail.root@m02>

For an outlined red point that simply stops at the edge of the region and
doesn't jump:

Needs["Presentations`Master`"]

Module[
 {polarpt = ComplexPolar[.5, 0],
  pt, calcAll},
 calcAll[pp_] := pt = ToCoordinates@PolarToComplex[pp];
 calcAll[polarpt];
 
 Draw2D[
  {Circle[], Circle[{0, 0}, .3],
   Locator[
    Dynamic[pt, (polarpt = ComplexToPolar@ToComplex[#]; 
       polarpt = MapAt[Clip[#, {.3, 1.}] &, polarpt, 1]; 
       calcAll[polarpt]) &], CirclePointLocator[3, Red]]},
  PlotRange -> 2,
  ContentSelectable -> False,
  ImageSize -> 300]
 ]


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







From: John Fultz [mailto:jfultz at wolfram.com] 
On Tue, 16 Dec 2008 02:34:42 -0500 (EST), vasil michev wrote:
> How do I implement this
>
> Graphics[{Circle[], Circle[{0, 0}, .3],
> Locator[Dynamic[
> pt, (pt = If[Norm[#] > .3 && Norm[#] < 1, #, {1, 0}]) &]]},
> PlotRange -> 2]
>
> into Manipulate? Everything i tried either crashes Mathematica or
> gives no result, any help will be greatly appretiated.

Here's a quick example.

Manipulate[If[Norm[pt] <= .3 || Norm[pt] >= 1, pt = {1, 0}]; 
 Graphics[{Circle[], Circle[{0, 0}, .3]}, PlotRange -> 2, 
  PlotLabel -> pt], {{pt, {1, 0}}, Locator}]

Sincerely,
 
John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.






  • Prev by Date: NIntegrate Problem
  • Next by Date: Re: Exponent function question
  • Previous by thread: Re: Question about Dynamic-ly restricting Locator position
  • Next by thread: Re: Re: Question about Dynamic-ly restricting Locator position