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


Groups > comp.soft-sys.math.mathematica > #1828 > unrolled thread

Re: problems plotting curvature

Started byHeike Gramberg <heike.gramberg@gmail.com>
First post2011-04-22 09:40 +0000
Last post2011-04-23 11:50 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: problems plotting curvature Heike Gramberg <heike.gramberg@gmail.com> - 2011-04-22 09:40 +0000
    Re: problems plotting curvature CoolGenie <cgenie@gmail.com> - 2011-04-23 11:50 +0000

#1828 — Re: problems plotting curvature

FromHeike Gramberg <heike.gramberg@gmail.com>
Date2011-04-22 09:40 +0000
SubjectRe: problems plotting curvature
Message-ID<iorif6$o57$1@smc.vnet.net>
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
>

[toc] | [next] | [standalone]


#1848

FromCoolGenie <cgenie@gmail.com>
Date2011-04-23 11:50 +0000
Message-ID<iouef2$6ib$1@smc.vnet.net>
In reply to#1828
On 22 Kwi, 11:40, Heike Gramberg <heike.gramb...@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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web