# RegionPlot3D does not plot "thin" regions?

Basically, I ultimately want to make something like this:

However, I am unsure of how to do this in Mathematica. I'm trying to do this via RegionPlot3D, and for starters, I was trying to draw a little disk in a sphere. But RegionPlot3d does not draws a sphere. For example:

RegionPlot3D[
x^2 + y^2 + z^2 <= 1  &&
z > 0 &&
(x - Cos[π/4] Cos[π/3])^2 + (y -
Cos[π/4] Sin[π/3])^2 + (z - Sin[π/4])^2 <= 1/2,
{x, -1.5, 1.5}, {y, -1.5, 1.5}, {z, -1.5, 1.5}]


only makes a little blob. If I change this $1/2$ to, say, $1/10$, then it completely vanishes. Also, if I use x^2+y^2+z^2 == 1 instead of x^2+y^2+z^2 <= 1, nothing is drawn. I tried to cheat and use x^2+y^2+z^2 <= 1 && x^2+y^2+z^2 => 1, but it didn't worked. I don't know what to do.

• Are you using V9 or V10? (The tools available are different.) Mar 1, 2015 at 20:00
• I am using version 9. Mar 1, 2015 at 20:01

Is this what you would like?

SphericalPlot3D[1, {θ, 0, Pi/2}, {ϕ, 0, 2 Pi},
RegionFunction ->
Function[{x, y, z, θ, ϕ, r},
z > 0 &&
(x - Cos[π/4] Cos[π/3])^2 + (y - Cos[π/4] Sin[π/3])^2 + (z - Sin[π/4])^2 <= 1/10],
PlotRange -> 1.5]


Response to comment:

plot = SphericalPlot3D[1, {θ, 0, Pi}, {ϕ, 0, 2 Pi},
MeshFunctions -> {Function[{x, y, z, θ, ϕ, r},
(x - Cos[π/4] Cos[π/3])^2 + (y - Cos[π/4] Sin[π/3])^2 + (z - Sin[π/4])^2]},
Mesh -> {{1/10}}, MeshShading -> {Red, Yellow},
BoundaryStyle -> None, PlotPoints -> 50, PlotRange -> 1.5]


The apparent "seam" is the meeting of the boundaries ϕ == 0 and ϕ == 2 π. Since it's a sphere centered at the origin, there is a relatively easy fix. It isn't always so easy.

plot /. GraphicsComplex[pts_, stuff__] :> (GraphicsComplex[pts, stuff] /.
(VertexNormals -> _) :> (VertexNormals -> pts))


One can also specify the normals adding the option NormalsFunction.

SphericalPlot3D[..., NormalsFunction -> Function[{x, y, z, θ, ϕ, r}, {x, y, z}]]

• Yes, that's pretty much it. I hadn't thought about using SphericalPlot3D, in fact I know very little about the program, I'm still learning, thanks. However, if I wanted to make a plot of the whole sphere, stressing this little disk, what you'd think it would be better? Do everything separated and then using Show, or trying to figure out how RegionFunction works? Mar 1, 2015 at 20:24
• I found out that Plot3D[Sqrt[1 - x^2 - y^2], {x, -1, 1}, {y, -1, 1}, RegionFunction -> Function[{x, y, z}, (x - Cos[\[Pi]/4] Cos[\[Pi]/3])^2 + (y - Cos[\[Pi]/4] Sin[\[Pi]/3])^2 + (z - Sin[\[Pi]/4])^2 <= 1/2]] works nice, too. Mar 1, 2015 at 20:38
• @IvoTerek You could also sometimes use ParametricPlot3D, which is suitable for surfaces that aren't graphs of an f(x,y), and allows you to specify the region in terms of parameters or the coordinates. Mar 1, 2015 at 20:41
• I understood. Thank you very much for taking the time to explain :) Mar 1, 2015 at 20:46
• @IvoTerek Region functions are boolean (true/false values) and mesh functions are numeric. So in your example, you should have had MeshFunctions -> {Function[{x, y, z, u, v}, (x - Cos[\[Pi]/4] Cos[\[Pi]/3])^2 + (y - Cos[\[Pi]/4] Sin[\[Pi]/3])^2 + (z - Sin[\[Pi]/4])^2]}, Mesh -> {{1/20}}. You might want to look at the doc page of each plot function; under "Options" you'll find examples that will show how to create nice illustrations. Mar 1, 2015 at 21:07