MathGroup Archive 2008

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

Search the Archive

Re: locator snap

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88291] Re: locator snap
  • From: "Kevin J. McCann" <Kevin.McCann at umbc.edu>
  • Date: Wed, 30 Apr 2008 07:03:57 -0400 (EDT)
  • Organization: University System of Maryland
  • References: <fv6ukg$rmt$1@smc.vnet.net> <4817399A.1030901@gmail.com> <fv9afm$mso$1@smc.vnet.net>

Hey Szabolcs,

This works fine, but I notice that the graph jerks around a lot when you
move the locator. I assume that Mathematica is redrawing everything on each move
or ...? Anyway, does anyone know why?

Kevin

Szabolcs Horv=E1t wrote:
> Szabolcs Horv=E1t wrote:
>> Maarten van der Burgt wrote:
>>> Dear all,
>>>
>>> In the example below the locator can be moved to any position in the
>>> graphic.
>>> Can the locator be made to snap to multiples of say 0.1?
>>>
>>>  Manipulate[Column@{Graphics[{}, Axes -> True], p}, {{p, {0, 0}},
>>> Locator}]
>>>
>> Hi Maarten,
>>
>> I am not aware of any way to do this directly with Manipulate. (Of
>> course this does not mean that there doesn't exist a way!)
>>
>> Here is an example of doing it directly with Dynamic:
>>
>> Graphics[
>>  Locator[Dynamic[{x, y}, ({x, y} = Round[#, 0.1]) &]],
>>  PlotRange -> 1, Frame -> True,
>>  GridLines -> {#, #} & @
>>   Table[{x, If[Mod[x, 1/2] == 0, Black, Gray]}, {x, -1, 1, 1/10}]
>>  ]
>>
>
> Sorry, I forgot to mention that x and y must be initialized before this=

> will work:
>
> {x, y} = {0, 0}
>
> Also, the x in the Table is an unfortunate choice for a local variable
> name---it has nothing to do with the x in the Dynamic.
>

--

Kevin J. McCann
Research Associate Professor
JCET/Physics
Physics Building
University of Maryland, Baltimore County
1000 Hilltop Circle
Baltimore, MD 21250


  • Prev by Date: Assigning multiple variables within a Block[] statement (e.g. {a,b} = {c,d})
  • Previous by thread: Re: locator snap
  • Next by thread: Bug in the front end's parser ( lst[[ ;; , 1 ]] syntax)