MathGroup Archive 2011

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

Search the Archive

problems plotting curvature

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118299] problems plotting curvature
  • From: CoolGenie <cgenie at gmail.com>
  • Date: Thu, 21 Apr 2011 03:09:14 -0400 (EDT)

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


  • Prev by Date: Re: solution
  • Next by Date: Re: Function Option Names
  • Previous by thread: Re: Converting list of subscripted variables into an array
  • Next by thread: Re: problems plotting curvature