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

MathGroup Archive 2011

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

Search the Archive

Constrain locator

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121706] Constrain locator
  • From: Tom De Vries <tidetabletom at gmail.com>
  • Date: Mon, 26 Sep 2011 20:05:30 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

Hello everyone,

I'm looking for a simple way to constrain a locator to a particular function.

I've seen a few methods given by posters to this group and others.

In programs like Sketchpad and Geogebra you can add a point to a
function and immediately constrain the point to that function.
You can then "trace" the point, displaying coordinates, etc.

I'm trying to work within Mathematica if I can,  but this is hard for
me to implement.

Working through a few examples,  I distilled things down to the
following snippet of code.
It puts a point on the function y = x^2 and allows the point to be
dragged along it.

f0[x_] := x^2;

DynamicModule[{p = {1, 1}},
 loc := Locator[Dynamic[p, (p = {#[[1]], f0[#[[1]]]}) &]];
 Show[{Plot[f0[x], {x, -10, 10}], Graphics[{loc}]},
  PlotRange -> {{-4, 4}, {-1, 10}},
  AspectRatio -> 1]
 ]

I would be grateful for a few things...

A)  a little help on exactly how this works...!
B)  changing the display of the locator to a point on the function
C)  displaying the coordinate of the point

I appreciate the input given by members of this group.

Sorry for the trivial question, but it sure would help with a lot of
things I am trying to teach at the junior/high school level.

Tom




  • Prev by Date: Re: Integration error? Integrate[1/(x^3-1)]?
  • Next by Date: Re: Fittings 2 sets of equations and 2 data sets with nonlinearmodelfit
  • Previous by thread: A while into another while
  • Next by thread: Re: Constrain locator