Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5233 > unrolled thread
| Started by | Tom De Vries <tidetabletom@gmail.com> |
|---|---|
| First post | 2011-09-27 00:06 +0000 |
| Last post | 2011-09-27 10:24 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Constrain locator Tom De Vries <tidetabletom@gmail.com> - 2011-09-27 00:06 +0000
Re: Constrain locator Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-09-27 22:53 +0000
Re: Constrain locator Peter Breitfeld <phbrf@t-online.de> - 2011-09-28 06:46 +0000
Re: Constrain locator Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-09-27 10:24 +0000
| From | Tom De Vries <tidetabletom@gmail.com> |
|---|---|
| Date | 2011-09-27 00:06 +0000 |
| Subject | Constrain locator |
| Message-ID | <j5r42k$iac$1@smc.vnet.net> |
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
[toc] | [next] | [standalone]
| From | Armand Tamzarian <mike.honeychurch@gmail.com> |
|---|---|
| Date | 2011-09-27 22:53 +0000 |
| Message-ID | <j5tk5i$3c2$1@smc.vnet.net> |
| In reply to | #5233 |
On Sep 27, 10:06 am, Tom De Vries <tidetable...@gmail.com> wrote:
> 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
A. which part would you like to understand? The Locator?
It isn't entirely clear to me what the difference is between B and C
but here are two examples:
DynamicModule[{loc, f0, p = {1, 1}, point},
f0[x_] := x^2;
point = Graphics[{Red, Table[Circle[{0, 0}, i], {i, 3}]},
ImageSize -> 20];
loc = Locator[Dynamic[p, (p = {#1[[1]], f0[#1[[1]]]}) &], point];
Column[{
Show[{Plot[f0[x], {x, -10, 10}], Graphics[{loc}]},
PlotRange -> {{-4, 4}, {-1, 10}}, AspectRatio -> 1],
Row[{"The points are: ", Dynamic[p]}]
}]
]
and
DynamicModule[{loc, f0, p = {1, 1}, point},
f0[x_] := x^2;
point = Graphics[{Text[
Dynamic@Style[NumberForm[#, {2, 2}] & /@ p, Bold], Dynamic[p]]},
ImageSize -> 70];
loc = Locator[Dynamic[p, (p = {#1[[1]], f0[#1[[1]]]}) &], point];
Column[{
Show[{Plot[f0[x], {x, -10, 10}], Graphics[{loc}]},
PlotRange -> {{-4, 4}, {-1, 10}}, AspectRatio -> 1],
Row[{"The points are: ", Dynamic[p]}]
}]
]
You'll want to add some additional styling to either of these and
maybe offset the text in the second one.
Mike
[toc] | [prev] | [next] | [standalone]
| From | Peter Breitfeld <phbrf@t-online.de> |
|---|---|
| Date | 2011-09-28 06:46 +0000 |
| Message-ID | <j5ufri$7ip$1@smc.vnet.net> |
| In reply to | #5233 |
You my use LocatorPane, which takes a locator and a background, which can
be any graphic. Then a possibility might be:
f0[x_] := x^2
DynamicModule[{p = {1, 1}},
LocatorPane[Dynamic[p, (p = {#[[1]], f0[#[[1]]]}) &],
Plot[f0[x], {x, -10, 10},
PlotRange -> {{-4, 4}, {-1, 10}},
AspectRatio -> 1,
Epilog ->
Inset[
Graphics@Text[
Style[NumberForm[#, {4, 2}] & /@ Dynamic[p], Larger], {0,0}],
{1.5, 9}]]]
]
Tom De Vries wrote:
> 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
>
--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
[toc] | [prev] | [next] | [standalone]
| From | Armand Tamzarian <mike.honeychurch@gmail.com> |
|---|---|
| Date | 2011-09-27 10:24 +0000 |
| Message-ID | <j5s89b$pf7$1@smc.vnet.net> |
| In reply to | #5233 |
On Sep 27, 10:06 am, Tom De Vries <tidetable...@gmail.com> wrote:
> 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
A. which part would you like to understand? The Locator?
It isn't entirely clear to me what the difference is between B and C
but here are two examples:
DynamicModule[{loc, f0, p = {1, 1}, point},
f0[x_] := x^2;
point = Graphics[{Red, Table[Circle[{0, 0}, i], {i, 3}]},
ImageSize -> 20];
loc = Locator[Dynamic[p, (p = {#1[[1]], f0[#1[[1]]]}) &], point];
Column[{
Show[{Plot[f0[x], {x, -10, 10}], Graphics[{loc}]},
PlotRange -> {{-4, 4}, {-1, 10}}, AspectRatio -> 1],
Row[{"The points are: ", Dynamic[p]}]
}]
]
and
DynamicModule[{loc, f0, p = {1, 1}, point},
f0[x_] := x^2;
point = Graphics[{Text[
Dynamic@Style[NumberForm[#, {2, 2}] & /@ p, Bold], Dynamic[p]]},
ImageSize -> 70];
loc = Locator[Dynamic[p, (p = {#1[[1]], f0[#1[[1]]]}) &], point];
Column[{
Show[{Plot[f0[x], {x, -10, 10}], Graphics[{loc}]},
PlotRange -> {{-4, 4}, {-1, 10}}, AspectRatio -> 1],
Row[{"The points are: ", Dynamic[p]}]
}]
]
You'll want to add some additional styling to either of these and
maybe offset the text in the second one.
Mike
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web