Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2274

Re: Can't use Table with Dynamic variables?

From "Christopher O. Young" <cy56@comcast.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Can't use Table with Dynamic variables?
Date 2011-05-10 12:53 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iqbcfu$k2o$1@smc.vnet.net> (permalink)
References <iq8jnc$72i$1@smc.vnet.net>

Show all headers | View raw


On 5/9/11 7:38 AM, in article iq8jnc$72i$1@smc.vnet.net, "E. Martin-Serrano"
<eMartinSerrano@telefonica.net> wrote:

> Try applying the Dynamic[] wrapper to each element in the table (inside the
> table construct not outside). I experienced the same problem in several
> occasions and solved  it in this form. Anyway the movement of the dragged
> objects is sluggish, just in the border of which could be considered as
> acceptable despite that just four or the five locators in the involved
> construct does not seem to be a heavy demand.

After hours of work, I finally got a pretty fast version of the 2D vs. 3D
curve-plotter.

The only trouble now is that I can't seem to have both the function
definition f[x] at the top and also have DynamicModule save my point
variables. They get reset each time the graph is plotted.


DynamicModule[
 {
  P = {{-4, 0}, {2, 1}, {3, 2}, {4, 3}},
  f
  },

 f[x_] := InterpolatingPolynomial[Table[P[[k]], {k, 1, Length[P]}], x];

 GraphicsGrid[
  {
   {"Z-coordinate",
    "Radius"},
   {Slider[Dynamic[h], {5, -5, -1}, Appearance -> "Labeled"],
    Slider[Dynamic[r], {0, 1, 0.01}, Appearance -> "Labeled"]},
   {
    Dynamic[
     Deploy[    (*
      Use Deploy to eliminate accidental movements of the graphics \
frame. *)
      Show[
       Graphics[
        {
         Table[
          With[{k = k}, Locator[Dynamic[P[[k]]]]], {k, 1, Length[P]}
          ],
         (*
         Plot the B=E9zier curve with these points as its control \
points, and also the accompanying "control polygon": *)
        
         BezierCurve[Table[P[[k]], {k, 1, Length[P]}]],
         {Thick, Dotted, Line[Table[P[[k]], {k, 1, Length[P]}]]}
         }
        ],  (* Graphics *)
      
       (*
       Plot the interpolation curve from the point furthest to the \
left to the point furthest to the right: *)
      
       Plot[f[x], {x, -5, 5}],
      
       PlotRange -> 5,
       Frame -> None,
       Axes -> True
       ]     (* Show *)
      ]     (* Deploy *)
     ], (*
    Dynamic *)
   
    Dynamic[
     Show[
      Graphics3D[
       {
        Table[Sphere[{P[[k, 1]], P[[k, 2]], h}, r], {k, 1, Length[P]}],
        Tube[
         BezierCurve[
          Table[{P[[k, 1]], P[[k, 2]], h}, {k, 1, Length[P]}]]],
        {Thick, Dotted,
         Line[Table[{P[[k, 1]], P[[k, 2]], h}, {k, 1, Length[P]}]]}
        },
       PlotRange -> 5,
       Axes -> True,
       AxesLabel -> {"x", "y", "z"}
       ],  (* Graphics3D *)
     
      ParametricPlot3D[{t, f[t], h}, {t, -5, 5}] /.
      
       Line[pts_, rest___] :> Tube[pts, 0.1, rest]
      ]   (* Show *)
     ] (* Dynamic *)
    }
   },
  Frame -> None,
  ItemAspectRatio -> {0.1, 0.1, 1},
  Dividers -> {All, {True, False, True, True}},
  Spacings -> {50, 20}
  ]  (* GraphicsGrid *)
 ](* DynamicModule *)

Back to comp.soft-sys.math.mathematica | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Can't use Table with Dynamic variables? "E. Martin-Serrano" <eMartinSerrano@telefonica.net> - 2011-05-09 11:38 +0000
  Re: Can't use Table with Dynamic variables? "Christopher O. Young" <cy56@comcast.net> - 2011-05-10 12:53 +0000

csiph-web