Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

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));

Plug in your parameters:

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

enter image description here

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]

enter image description here

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]

enter image description here

share|improve this answer

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]}]

enter image description here

give what you need?

share|improve this answer
    
Thank you very much! –  dimitris Jul 8 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

enter image description here

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

Add Evaluate in colfun, so now:

?colfun

enter image description here

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]}]

enter image description here

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

enter image description here

share|improve this answer
    
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 at 15:51
    
Thank you very much for your replies! –  dimitris Jul 7 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 at 17:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.