I have the following problem: I want to dynamically plot a function
(tangential plane to a 3D Plot) One part is that I have to compute the
gradient of the function. I could not manage this (dynamically). I
have stripped of any unnessesary code to descripe the problem, so look
at this:
This makes a slider to select a point (works well, of course)
{Slider2D[Dynamic[aufpunkt], {{-2, -2}, {2, 2}}], Dynamic[aufpunkt]}
This should do a computation with "aufpunkt" (does not work)
DynamicModule[{x, y, a, b},
x = Dynamic[aufpunkt[[1]]]; y = Dynamic[aufpunkt[[2]]];
y^2
]
The output is not evaluated, I get, for instance, (0.5)^2, instead of
0.25. How can I manage to get the formula (y^2 in this case)
evaluatet?
Greetings
Mike
Module[
{(* Primary dynamic variable *)
aufpunkt = {0, 0},
(* Dependent variables *)
x, y,
(* Routine to calculate dependent variables *)
calcAll},
calcAll[p_] := {x, y} = p;
(* Initialize dependent variables *)
calcAll[aufpunkt];
Column[
{Slider2D[
Dynamic[aufpunkt, (aufpunkt = #; calcAll[aufpunkt]) &], {{-2, -2}, {2,
2}}],
Dynamic[Row[{("y")^2, Spacer[5], , y^2}]]
}]
]
--
David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/
"m.g." <m...@michaelgamer.de> wrote in message
news:gd9lh6$egl$1...@smc.vnet.net...
David, your calcAll[] seems a nice idea. But, what if we had several levels
of dependent dynamic variables (some of them involving circular dependency),
Let us say, primary dynamic variables, first level dependent variables
(which depend on those in the primary level), and in general, nth-level
dependent variables which depend on those in the previous n -1 levels. I
have been thinking of proposing (to WRI) to provide a tool to extract or
construct the data dependency graph of Mathematica programs. It seems to me
that it would be a must; to let users write clean, fast and no messed
dynamic pieces of code. The data dependency graph is part of the
intermediate data structures generated by the parser to interpret the code
in the notebooks. So, it should be already available although hidden. And
ease for WRI to provide it.
Just a suggestion for WRI to think about it.
Regards.
Column[
{Slider2D[
Dynamic[aufpunkt, (aufpunkt = #; calcAll[aufpunkt]) &], {{-2, -2}, {2,
2}}],
Dynamic[Row[{("y")^2, Spacer[5], , y^2}]]
}]
]
--
David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/
"m.g." <m...@michaelgamer.de> wrote in message
news:gd9lh6$egl$1...@smc.vnet.net...