MathGroup Archive 2011

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

Search the Archive

Re: problems plotting curvature

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118345] Re: problems plotting curvature
  • From: CoolGenie <cgenie at gmail.com>
  • Date: Sat, 23 Apr 2011 07:50:44 -0400 (EDT)
  • References: <iorif6$o57$1@smc.vnet.net>

On 22 Kwi, 11:40, Heike Gramberg <heike.gramb... at gmail.com> wrote:
> It looks like the dummy variables x, y in X1, X2, LL, MM, and NN are interfering with
> x, y in the definition of your ColorFunction in the third plot. I'm not entirely sure why the
> second plot didn't cause any problems, though. The easy way around this would be to
> replace x and y in your ColorFunction definition to s and t, say. A safer option would be
> to use a Block structure for your derivatives, e.g.
>
> X1[u_, v_] := Block[{x}, D[vf[x, v], x] /. {x -> u}];
>
> etc.
>
> Heike.
>
> On 21 Apr 2011, at 08:09, CoolGenie wrote:
>
>
>
>
>
>
>
> > Hello,
> > I'm trying to write a program for computing and plotting Gaussian
> > curvature. Basically what I want is to set different colors on the
> > surface depending on the curvature. My code is as follows
>
> > Clear[vf, u, v, x, y, X1, X2, EE, FF, GG, n, nn, LL, MM, NN, KG];
> > vf[u_, v_] :=
> >  vf[u, v] = {(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u], Sin[v]};
> > (* wektory styczne *)
> > X1[u_, v_] := D[vf[x, y], x] /. {x -> u, y -> v};
> > X2[u_, v_] := D[vf[x, y], y] /. {x -> u, y -> v};
> > (* wspolczynniki pierwszej formy podstawowej *)
> > (* symbol E jest zajety wiec uzywamy EE, FF, GG *)
> > EE[u_, v_] := Dot[X1[u, v], X1[u, v]];
> > FF[u_, v_] := Dot[X1[u, v], X2[u, v]];
> > GG[u_, v_] := Dot[X2[u, v], X2[u, v]];
> > (* wektor normalny do powierzchni *)
> > nn[u_, v_] := Cross[X1[u, v], X2[u, v]];
> > n[u_, v_] := Normalize[nn[u, v]];
> > (* wspolczynniki drugiej formy podstawowej *)
> > LL[u_, v_] := Dot[D[vf[x, y], x, x], n[x, y]] /. {x -> u, y -> v};
> > MM[u_, v_] := Dot[D[vf[x, y], x, y], n[x, y]] /. {x -> u, y -> v};
> > NN[u_, v_] := Dot[D[vf[x, y], y, y], n[x, y]] /. {x -> u, y -> v};
> > (* krzywizna Gaussa *)
> > KG[u_, v_] :=
> >  KG[u, v] = (LL[u, v]*NN[u, v] -
> >      MM[u, v]*MM[u, v])/(EE[u, v]*GG[u, v] - FF[u, v]*FF[u, v] +
> >      10^-10);
> > (*min =First[FindMinimum[{KG[u,v], 0<=u<=2Pi,0<=v<=2Pi},u,v]]
> > max=First[FindMaximum[{KG[u,v], 0<=u<=2Pi,0<=v<=2Pi},u,v]]*)
>
> > ParametricPlot3D[vf[u, v], {u, 0, 2 Pi}, {v, 0, 2 Pi},
> > ColorFunction -> Function[{x, y, z, u, v}, Hue[u]],
> > ColorFunctionScaling -> False]
>
> > ParametricPlot3D[{u, v, KG[u, v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi},
> > ColorFunction ->
> >  Function[{x, y, z, u, v}, Hue[(KG[u, v] - min)/(max - min)]],
> > ColorFunctionScaling -> False]
>
> > ParametricPlot3D[vf[u, v], {u, 0, 2 Pi}, {v, 0, 2 Pi},
> > ColorFunction -> Function[{x, y, z, u, v}, Hue[KG[u, v]]],
> > ColorFunctionScaling -> False]
>
> > This produces 3 plots: the first one gives out a torus, colored
> > according to u and the picture is ok. The second one gives Gaussian
> > curvature plotted as a surface above the axes of u and v, colored
> > according to the value of this curvature. Again the plot is ok. The
> > problem is with the third plot where I try to color the torus with KG.
> > When calling this function, I get the errors:
>
> > General::ivar: 2.3258915732471794` is not a valid variable. >>
>
> > and so on and the torus is not colored in full: some areas are white.
> > I can upload a picture or you could run your code and see that it's
> > not ok.
> > Does anyone have a solution for this problem?
> > Regards,
> > Przemek

This helped, thank you!

P.


  • Prev by Date: Re: How to roll up multiple Line calls into a loop
  • Next by Date: .NET/LINK Users Guide
  • Previous by thread: Re: problems plotting curvature
  • Next by thread: Printing "full version" or "publication version" of same notebook?