Say I have a real valued function on the 2-sphere, $f:S^2\to \mathbb{R}$. I would like to visualize the sets $\Gamma_A=\{x\in S^2 \mid f(x) > A\}$ in 3D.

In particular I would like to do this first for functions of the form $f(x_1,x_2,x_3) = \frac{\pi abc}{\sqrt{a^2x_1^2+b^2x_2^2+c^2x_3^2}}$

Is it possible to do this using Mathematica (or any other similar program)? I am pretty new at Mathematica.

  • $\begingroup$ I would try playing around with using $f$ as a ColorFunction in ParametricPlot3D: Plot a sphere, and colour it using an $f$ of your choosing. $\endgroup$ – aardvark2012 Jul 2 '17 at 5:22

You can use ParametricPlot3D with Mesh* options:

f[x1_, x2_, x3_, a_, b_, c_] := π a b c/Sqrt[a^2 x1^2 + b^2 x2^2 + c^2 x3^2]

Manipulate[ParametricPlot3D[{Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]}, {u, 0, 2 π}, {v, 0, π},
        MeshFunctions -> {f[#1, #2, #3, a, b, c] &}, 
        PlotStyle -> Directive[Opacity[0.5], Yellow], Mesh -> {{aA}}, 
        MeshStyle -> Directive[Thick, Black], 
        MeshShading -> {Directive[Opacity[.5], Red], Automatic}, 
        PlotPoints -> 100,PerformanceGoal -> {"Speed", "Quality"}], 
       {{aA, 0.1}, 0, 1}, {{a, .1}, 0, 1}, {{b, .1}, 0, 1}, {{c, .1}, 0, 1}]

Mathematica graphics


You could try something like

f[x1_, x2_, x3_, a_, b_, c_, A_] := 
  With [{w = (\[Pi] a b c)/Sqrt[a^2 x1^2 + b^2 x2^2 + c^2 x3^2]}, 
  Piecewise[{{Red, w < A}}, Black]]

and use it as a ColorFunction in a ParametricPlot3D:

ParametricPlot3D[{Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]}, {u, 0, 2 \[Pi]}, {v, 0, \[Pi]}, 
  ColorFunction -> {f[#1, #2, #3, .5, .25, 1, 0.5] &}, PlotPoints -> 100]

(inserting your own values for a, b and c, of course) to get

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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