4
$\begingroup$

In the link, ParametricPlot3D, consider the example(Variation on the Spheres) given in the Neat Examples section.

enter image description here

Can someone please explain how RegionFunction and MeshFunctions are working out there?

$\endgroup$
1
  • $\begingroup$ The index i is the Table[] index. Each element there is a function. $\endgroup$ Jul 12 '13 at 19:46
6
$\begingroup$

Maybe it can be found in documentation but I do not consider it basic since it involves couple of options.

From Details of RegionFunction and MeshFunctions You can see that in case of ParametricPlot3D it can accept 5 arguments: x, y, z, u, v where u and v are in fact ϕ and θ.

First example is quite easy.

RegionFunction -> Function[{x, y, z, ϕ, θ}, Sin[6 ϕ] Sin[6 θ] >= 1/4]

force Mathematica to plot only a region of surface which fulfils condition above.

Second example: MeshFunctions is an option for specifying functions Mathematica will be reffering to while creating Mesh. You can see that this function is the same as used in inequality inside RegionFunction.

MeshFunctions -> {Function[{x, y, z, ϕ, θ}, Sin[6 ϕ] Sin[6 θ]]}

From Mesh Details You can learn that You can set Mesh divisions for explicit values, absolute or reffered to our MeshFunctions.

Our MeshFunctions is f: [0, 2Pi]x[0, Pi] -> [-1, 1].

So if We set Mesh -> {{1/4}} there will be only two regions on a surface, those for which

  • -1 < f[ϕ, θ] < 1/4 and
  • 1/4 < f[ϕ, θ] < 1

With MeshShading -> {Opacity[0.5], Green} You can set those regions styling. Notice that first one Opacity[.5] is indeed White but looks bluish because of default Lighting (check Lighting->"Neutral").

So for 3 division values there are going to be 4 regions:

ParametricPlot3D[{Cos[ϕ] Sin[θ], Sin[ϕ] Sin[θ], Cos[θ]}, {ϕ, 0, 2 π}, {θ, 0, π},
                 MeshFunctions -> Function[{x, y, z, ϕ, θ}, Sin[6 ϕ] Sin[6 θ]], 
                 Mesh -> {{-.9, 0, 1/4}}, PlotPoints -> 75, 
                 MeshShading -> {Yellow, Blue, Green, Red}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Great. Thank You Kuba $\endgroup$
    – Mambo
    Jul 12 '13 at 20:56

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.