# Overlapping Spheres with a Shared Blank Region

We have two similar overlapped spheres in a way that the distance between their centers is smaller than the sum of their radius (2R>a). As I show here:

Also, we want to draw them in a such way that the overlapped (shared) region be blank and the each sphere has distinct color. However we drawn it by another software (as above) but we don't know how we can use of Mathematica for this aim!?

• Wait, did you want disks, or actual spheres? – J. M. is in limbo May 3 '15 at 4:41
• Actually, two spheres with the transparent colors which the internal realms can be viewed , but here I drawn their Cross Sections. Although the cross section will be desired but the preference is with spheres. – Unbelievable May 3 '15 at 4:45
• I don't have Mathematica with me, but try this: With[{c1 = {-2/3, 0, 0}, r1 = 1, c2 = {2/3, 0, 0}, r2 = 1}, Show[RegionPlot3D[Norm[{x, y, z} - c1] < r1 && Norm[{x, y, z} - c2] > r2, {x, -2, 2}, {y, -1, 1}, {z, -1, 1}, Mesh -> None, PlotStyle -> Directive[Pink, Opacity[2/3]]], RegionPlot3D[Norm[{x, y, z} - c1] > r1 && Norm[{x, y, z} - c2] < r2, {x, -2, 2}, {y, -1, 1}, {z, -1, 1}, Mesh -> None, PlotStyle -> Directive[Blue, Opacity[2/3]]], BoxRatios -> Automatic]]. – J. M. is in limbo May 3 '15 at 4:49
• Thankx I tired it but, the spheres are not so uniform and have sharp edges in some places on their environments. Also, in the touch region they are not so well connected – Unbelievable May 3 '15 at 4:54
• Then increase the setting of PlotPoints; say, PlotPoints -> 75. – J. M. is in limbo May 3 '15 at 4:55

Here is an alternative to RegionPlot that potentially produces higher quality: it's based on Tube with varying radius, as I also used in this answer:

With[
{a = 1, R = .7, n = 40, xMax = 1.5},
Manipulate[
Graphics3D[
GeometricTransformation[
{CapForm[None],
{Opacity[.5], Pink,
#, Cyan,
GeometricTransformation[#, {{-1, 0, 0}, {0, -1, 0}, {0, 0, 1}}]
} &[
Tube @@
Transpose[
Table[
{{-R Cos[θ] - a/2, 0, 0}, R Sin[θ]},
{θ, 0, #, #/n}] &[ArcCos[-a/2/R]]
]
],
{Opacity[1], Glow[White],
#,
GeometricTransformation[#, {{-1, 0, 0}, {0, -1, 0}, {0, 0, 1}}]
} &[
Tube @@
Transpose[
Table[
{{-R Cos[θ] - a/2, 0, 0}, R Sin[θ]},
{θ, #, Pi, (Pi - #)/n}] &[ArcCos[-a/2/R]]
]
]
}, RotationTransform[θ, {0, 0, 1}]],
Lighting -> "Neutral", Background -> Black,
Boxed -> False,
PlotRange -> {{-xMax, xMax}, {-xMax, xMax}, {-xMax, xMax}}],
{θ, 0, 2 Pi}]
]


To make the white region of intersection stand out, I made it solid and glowing, while the enclosing spheres are translucent.

Using Tube here seemed appropriate because the geometry has overall cylindrical symmetry, and tubes can have a variable radius that in this case is chosen to vary as the cylindrical radial distance from the x axis for each spherical shell portion.

• It is wonderful! tanxxxxx. – Unbelievable May 3 '15 at 5:37

Here's an approach using ParametricPlot3D, in which spheres are plotted and then sliced off using the option RegionFunction.

It's not clear to me how you intend to have the inner regions "blank" as they are occluded, but the options to Show let you vary the appearance.

 outerSphere[sphereCenter_: {0, 0, 0}, regionLimit_: 0.6, color_, opacity_] := Module[
{x = sphereCenter[[1]], y = sphereCenter[[2]],
z = sphereCenter[[3]]},
ParametricPlot3D[
{x + Cos[θ] Sin[ϕ], y + Cos[θ] Cos[ϕ],
z + Sin[θ]},
{θ, -π, π},
{ϕ, -π/2, π/2},
Mesh -> None,
PlotStyle -> {color, Opacity[opacity]},
RegionFunction -> (#2 < regionLimit &)]
];

innerSphere[sphereCenter_: {0, 0, 0}, regionLimit_: 0.6, color_, opacity_, boundaryOn_] := Module[
{x = sphereCenter[[1]], y = sphereCenter[[2]],
z = sphereCenter[[3]]},
ParametricPlot3D[
{x + Cos[θ] Sin[ϕ], y + Cos[θ] Cos[ϕ],
z + Sin[θ]},
{θ, -π, π},
{ϕ, -π/2, π/2},
Mesh -> None,
PlotStyle -> {color, Opacity[opacity]},
BoundaryStyle -> Directive[If[boundaryOn == False, Opacity[0]], Thick, Red],
RegionFunction -> (#2 > regionLimit &)]
];

Show[
{outerSphere[{0, 0, 0}, .7, Green, 0.1],
innerSphere[{0, 0, 0}, .7, Yellow, 0.6, True],
innerSphere[{0, 1.4, 0}, .7, Blue, 0.1, False],
outerSphere[{0, 1.4, 0}, .7, Yellow, 0.6]},
ViewPoint -> {3, .5, 1},
PlotRange -> All,
Axes -> None,
Boxed -> False]