3
$\begingroup$

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.

$\endgroup$

3 Answers 3

3
$\begingroup$

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?

$\endgroup$
0
1
$\begingroup$
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

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$
    – Verbeia
    Jul 7, 2014 at 15:51
  • $\begingroup$ Thank you very much for your replies! $\endgroup$
    – Dimitris
    Jul 7, 2014 at 17:05
  • $\begingroup$ 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}}]] $\endgroup$
    – Dimitris
    Jul 7, 2014 at 17:06
1
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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