Using a complicated function as color function

I have an ellipsoid with parametric equations

lst = {10*Cos[u]*Sin[v], 3*Sin[u]*Sin[v], 2*Cos[v]};


I define a function

dam = Sqrt[(1296*Cos[u]^4*
Sin[v]^4)/(900*Cos[v]^2 + 36*Cos[u]^2*Sin[v]^2 +
400*Sin[u]^2*Sin[v]^2)^2 +
(3600*Cos[u]^2*
Sin[v]^2*(9*Cos[v]^2 + 4*Sin[u]^2*Sin[v]^2))/(900*Cos[v]^2 +
4*(9*Cos[u]^2 + 100*Sin[u]^2)*Sin[v]^2)^2];


and a color function as

colFun = Function[{u, v}, Hue[Rescale[dam, {0, 1}]]];


My ultimate goal is coloring the ellipsoid according to the values of

Rescale[dam, {0, 1}]


So, my question is why there is a big mismatch in the color rendering in the following plots

h = ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False,
ColorFunction -> colFun, ColorFunctionScaling -> False,
ImageSize -> 800];
g = Plot3D[Rescale[dam, {0, 1}], {u, 0, 2*Pi}, {v, 0, Pi},
Mesh -> False, ColorFunction -> colFun,
ColorFunctionScaling -> False, PlotRange -> All];
Row[{Show[h], Show[g, ImageSize -> 400]}]


From g we see that the edges of the ellipsoid should be colored with purple color since for the respective angles {u, v}, dam takes the highest values.

-

Does the following:

h = ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False,
ColorFunction -> (Function[{x, y, z, u, v}, Hue[Rescale[dam, {0, 1}]]]),
ColorFunctionScaling -> False, ImageSize -> 800];
g = Plot3D[Rescale[dam, {0, 1}], {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False,
ColorFunction -> (Function[{u, v, z}, Hue[Rescale[dam, {0, 1}]]]),
ColorFunctionScaling -> False, PlotRange -> All];
Row[{h, Show[g, ImageSize -> 400]}]


give what you need?

-
Thank you very much! – dimitris Jul 8 '14 at 8:13
lst = {10*Cos[u]*Sin[v], 3*Sin[u]*Sin[v], 2*Cos[v]};
dam = FullSimplify@
Sqrt[(1296*Cos[u]^4*
Sin[v]^4)/(900*Cos[v]^2 + 36*Cos[u]^2*Sin[v]^2 +
400*Sin[u]^2*Sin[v]^2)^2 + (3600*Cos[u]^2*
Sin[v]^2*(9*Cos[v]^2 + 4*Sin[u]^2*Sin[v]^2))/(900*Cos[v]^2 +
4*(9*Cos[u]^2 + 100*Sin[u]^2)*Sin[v]^2)^2];


Add FullSimplify in dam, so now:

?dam


colFun = Function[{u, v}, Evaluate@Hue[Rescale[dam, {0, 1}]]];


Add Evaluate in colfun, so now:

?colfun


h = ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False,
ColorFunction -> (colFun[#4, #5] &), ColorFunctionScaling -> False,ImageSize -> 300];


Change ColorFunction -> colFun to ColorFunction -> (colFun[#4, #5] &).Since ColorFunction will receive x,y,z,u,v in ParametricPlot3D, and your colFun just need u,v.

g = Plot3D[Rescale[dam, {0, 1}], {u, 0, 2*Pi}, {v, 0, Pi},
Mesh -> False, ColorFunction -> colFun,
ColorFunctionScaling -> False, PlotRange -> All];
Row[{Show[h], Show[g, ImageSize -> 200]}]


For example,ColorFunction will receive x,y,z in Plot3D,so:

-
It isn't clear to me how this answers the question. Please help the OP by explaining how changing ImageSize makes a difference. Posting the output graphics might help. – Verbeia Jul 7 '14 at 15:51
Thank you very much for your replies! – dimitris Jul 7 '14 at 17:05
I do know if I should ask a new thread. Why the following (referring to the same situation) does not produce a bar legend? Legended[g, BarLegend[{colFun, {0, 1}}]] – dimitris Jul 7 '14 at 17:06

As an alternative you could also color your ellipsoid f.e. by its mean curvature:

 mcur = (a b c (3 (a^2 + b^2) + 2 c^2 + (a^2 + b^2 - 2 c^2) Cos[2 v] +
2 (-a^2 + b^2) Cos[2 u] Sin[v]^2))/( 8 (a^2 b^2 Cos[v]^2 +
c^2 (b^2 Cos[u]^2 + a^2 Sin[u]^2) Sin[v]^2)^(3/2));


dam = mcur /. {a -> 10, b -> 3, c -> 2} // FullSimplify


ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi},
Mesh -> False,
ColorFunction -> (Function[{x, y, z, u, v}, Hue[Rescale[dam, {0, 1}]]]),
ColorFunctionScaling -> False,
PlotPoints -> 200,
ImageSize -> 800]


Or use one of the inbuilt color tables:

ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi},
Mesh -> False,
ColorFunction -> Function[{x, y, z, u, v}, ColorData["TemperatureMap"][dam]],
ColorFunctionScaling -> False,
PlotPoints -> 200,
ImageSize -> 800]


-