# Drawing circular patches around arbitrary points on a sphere

I am trying to draw circular patches of given angular radii around arbitrary points on a sphere. I am able to use, for example,

SphericalPlot3D[1, {θ, 0, Pi/3}, {ϕ, 0, 2 Pi}, PlotStyle -> {Black, Opacity[0.7]},
Mesh -> None]


and

SphericalPlot3D[1, {θ, (2 Pi)/3, Pi}, {ϕ, 0, 2 Pi}, PlotStyle -> {Black, Opacity[0.7]},
Mesh -> None]


to create angular patches of (angular) radius Pi/3 around the north and south poles of the sphere, respectively, but what if I want to create two patches around two arbitrary points on the surface of the sphere and then draw in the rest of the sphere in some other background color? Thank you!

-

Show[
SphericalPlot3D[1, {θ, 0, Pi}, {ϕ, 0, 2 Pi}, Mesh -> None,  RegionFunction ->
Function[{x, y, z, θ, ϕ, r}, Norm[{x, y, z} - {1, 1, 0}] > 1], PlotStyle -> Red],
SphericalPlot3D[1, {θ, 0, Pi}, {ϕ, 0, 2 Pi}, Mesh -> None, RegionFunction ->
Function[{x, y, z, θ, ϕ, r}, Norm[{x, y, z} - {1, 1, 0}] < 1], PlotStyle -> Blue]]


-
Thank you very much! I'm still digging into the specifics of RegionFunction and its implementation in your answer, but it seems as though I can control the radius of the circular patch by changing the inequality threshold value and the point about which the patch is centered by changing the constant vector ({1,1,0} in your example). – PhysicsCodingEnthusiast Feb 23 at 0:26
@PhysicsCodingEnthusiast yep, that's it :) – Dr. belisarius Feb 23 at 0:37
Just for future reference (this can be added into the answer above), Norm[{x,y,z}-{x1,y1,z1}] < c defines a ball of radius c centered at (x1,y1,z1). It is, to me, easier to define the center of the ball to be on the surface of the sphere, so (x1,y1,z1) = R(sin\theta cos\phi, sin\theta sin\phi, cos\theta). Then, to get a circular patch with angular radius \gamma centered at (\theta, \phi) (or, equivalently, (x1,y1,z1)), the radius of the ball (with center (x1,y1,z1)) should be c = R \sqrt{ 2(1 - cos\gamma) }. – PhysicsCodingEnthusiast Feb 23 at 4:00

Here's a way using MeshFunctions and MeshShading that generalized to any number of points.

pts = Normalize /@ RandomReal[{-1, 1}, {2, 3}];
angles = Table[{Pi/3}, Length@pts];
SphericalPlot3D[1, {θ, 0, Pi}, {ϕ, 0, 2 Pi},
MeshFunctions ->
Table[With[{v0 = v0},
Function[{x, y, z, θ, ϕ},
VectorAngle[{x, y, z}, v0]]], {v0, pts}],
Mesh -> angles,
MeshShading -> {{Black, Black}, {Black, Automatic}},
BoundaryStyle -> None]


More random points, random angles:

SeedRandom[7];
pts = Normalize /@ RandomReal[{-1, 1}, {3, 3}];
angles = RandomReal[0.66, {Length@pts, 1}];
ConstantArray[Black, Table[2, Length@pts]],
Table[-1, Length@pts] -> Automatic];
SphericalPlot3D[1, {θ, 0, Pi}, {ϕ, 0, 2 Pi},
PlotPoints -> 50,
MeshFunctions ->
Table[With[{v0 = v0},
Function[{x, y, z, θ, ϕ},
VectorAngle[{x, y, z}, v0]]], {v0, pts}],
Mesh -> angles,