4
$\begingroup$

I want to plot and find out the section of a sphere remaining after putting constraints in terms of cartesian planes. How it can be done?

For example, if I have a sphere of $r = 1$, and I put the constraint $z > 0$ on it, simple imagination would suggest that it leaves half the sphere as defined by limits $\theta\in [0, \pi/2]$ and $\phi\in [0, 2\pi]$. Adding the constraint $x > 0$ leaves a quarter of the sphere with $\theta\in [0, \pi/2]$ and $\phi,\in [0, \pi]$, and so on.

I want to achieve the same using Mathematica. I want find the $(\phi, \theta)$ limits for more complex Cartesian constraints applied simultaneously, such as $x > y \land z > y$.

Will appreciate any suggestions.

$\endgroup$

3 Answers 3

6
$\begingroup$

ClipPlanes does exactly what you need:

You can use ClipPlanes in two different ways:

(1) As an option to clip all the 3D primitives:

Graphics3D[{Green, Sphere[{0, 0, 0}, 1/4], Blue, Sphere[{0, 0, 0}, 2/3], Red, Sphere[]}, 
    ClipPlanes -> {{0, 1, -1, 0}}, 
    ClipPlanesStyle -> Opacity[.25, Gray]]

enter image description here

(2) As a directive that applies to individual 3D primitives:

Graphics3D[{Green, Sphere[{0, 0, 0}, 1/4], 
  ClipPlanes -> {{0, 1, -1, 0}}, Blue, Sphere[{0, 0, 0}, 2/3], 
  ClipPlanes -> {{0, 0, 1, 0}, {0, 1, 0, 0}}, Red, Sphere[]}]

enter image description here

$\endgroup$
3
$\begingroup$
{x, y, z} = {Sin[θ] Cos[φ], Sin[θ] Sin[φ], Cos[θ]};

Reduce[0 <= θ <= π && 0 <= φ < 2π && z > 0, {θ, φ}]

0 <= θ < π/2 && 0 <= φ < 2π

Reduce[0 <= θ <= π && 0 <= φ < 2π && z > 0 && x > 0, {θ, φ}]

0 < θ < π/2 && (0 <= φ < π/2 || 3π/2 < φ < 2π)

Reduce[0 <= θ <= π && 0 <= φ < 2π && z > y, {θ, φ}] // FullSimplify

(θ >= 0 && 4θ < π && 0 <= φ < 2π) || (4θ == π && ((φ >= 0 && 2φ < π) || π/2 < φ < 2π)) || (π/4 < θ < π/2 && (0 <= φ < ArcSin[Cot[θ]] || (φ + ArcSin[Cot[θ]] > π && φ < 2π))) || (π/2 <= θ < 3π/4 && φ + ArcSin[Cot[θ]] > π && φ < 2π + ArcSin[Cot[θ]])

For a graphical solution (to get a quick idea) you can do

RegionPlot[x > y && z > y, {φ, 0, 2π}, {θ, 0, π},
  AspectRatio -> Automatic, FrameLabel -> {φ, θ}]

enter image description here

$\endgroup$
2
  • $\begingroup$ In this case, you don't even need to specify the variables in Reduce[]. Using the OP's example: Reduce[And @@ Join[{0 < θ < 2 π, 0 < φ < π}, Thread[{x, y, z} == {Sin[φ] Cos[θ], Sin[φ] Sin[θ], Cos[φ]}], {x > y, z > y}]] // FullSimplify $\endgroup$ Aug 30, 2019 at 8:06
  • $\begingroup$ @J.M. yes. However, the use of Reduce and Solve with omitted list of variables is undocumented, as far as I know. $\endgroup$
    – Roman
    Aug 30, 2019 at 8:08
2
$\begingroup$
SphericalPlot3D[{1, 2, 3}, 
{θ, 0, π}, 
{φ, 0, 3 π/2}]

or

Manipulate[
 SphericalPlot3D[1,
  {θ, 0, θf},
  {φ, 0, φf},
  PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}],
 {{θf, π/2}, 0, π},
 {{φf, π}, 0, 2 π}
 ]
$\endgroup$
1
  • $\begingroup$ thanks for the help, the code you suggested can plot the section of sphere for given (phi, theta) range. Though my problem has another part, how to find the range of (phi, theta) when the sphere is sliced by certain plain by condition like x > 0. Thanks $\endgroup$
    – user49535
    Mar 2, 2019 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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