MathGroup Archive 2008

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

Search the Archive

Re: locator snap

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88483] Re: locator snap
  • From: "Maarten van der Burgt" <maarten.vanderburgt at icos.be>
  • Date: Tue, 6 May 2008 06:42:44 -0400 (EDT)

Dear all,

Thank you very much for your help with the locator snap. Your various
answers gave me a bit more insight in what is possible with dynamic and
dynamic module.
I also found a solution with manipulate, which not only gives a 'snapped
result' as the solution below, but which also snaps the  locator in the
graphics:

 Manipulate[Column@{Graphics
[{Disk[Round[p,0.1],0.05]},Axes->True,PlotRange->1],Round[p,0.1]},
{{p,{0,0}},Locator,Appearance->" "}]

I do not show the locator, but replace it with a graphics object at the
rounded position of the locator.

Thanks for your replies.

Maarten

PS:  the solution below is not jerking on my pc (6.0.2, windows xp)






|--------+----------------------->
|        |          "Kevin J.    |
|        |          McCann"      |
|        |          <Kevin.McCann|
|        |          @umbc.edu>   |
|        |                       |
|        |          30/04/2008   |
|        |          13:03        |
|        |                       |
|--------+----------------------->
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                                                  |
  |       To:     mathgroup at smc.vnet.net                                                                                                             |
  |       cc:                                                                                                                                        |
  |       Subject:     [mg88291] Re: locator snap                                                                                                    |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|




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: Re: Problem/bug with ends of thick lines in graphics
  • Next by Date: Matrix of big dimensions
  • Previous by thread: Re: locator snap
  • Next by thread: Problem: is not a list of numbers with dimensions