2
$\begingroup$

I would liked to plot a piece of the unit sphere surface within the region defined by

$$x \geq y \geq z \geq 0$$

Plotting the region (RegionPlot3D) and the sphere (Graphics3D) is no problem, but I would like to restrict the plot domain to the area specified by the inequality, i.e. I want the intersection between the volume and the sphere surface. Is that possible?

$\endgroup$
  • 2
    $\begingroup$ RegionPlot3D[ 0 < z <= y <= x && x^2 + y^2 + z^2 <= 1, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, PlotPoints -> 100, Mesh -> None]? $\endgroup$ – kglr Jan 30 '18 at 19:09
  • $\begingroup$ what have you tried? $\endgroup$ – José Antonio Díaz Navas Jan 30 '18 at 19:19
  • $\begingroup$ @kglr That'll do it for the moment, thanks. Any way to plot the surface only? $\endgroup$ – Jersey Jan 30 '18 at 19:43
  • $\begingroup$ @José Antonio Díaz Navas As I said, plotting the region and my sphere's surface independently is not the problem, I'm just looking for a built-in method to restrict any existing plot to any arbitrary region, when these two items can be plotted separately. There's not much I can try but to inquire about features unknown to me. $\endgroup$ – Jersey Jan 30 '18 at 19:47
2
$\begingroup$

With region = 0 <= z <= y <= x you can use

RegionPlot3D[region && x^2 + y^2 + z^2 <= 1, 
  {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, PlotPoints -> 100, Mesh -> None]

enter image description here

Any way to plot the surface only?

You can use ParametricPlot3D or ContourPlot3D to get the surface of a sphere:

ParametricPlot3D[{Cos[v] Sin[u], Sin[v] Sin[u], Cos[u]}, {u, 0, Pi}, {v, 0, 2 Pi}, 
 Mesh -> None, BoundaryStyle -> None,      MaxRecursion -> 5, PlotPoints -> 100,
 RegionFunction -> Function[{x, y, z, u, v}, region]]

enter image description here

ContourPlot3D[x^2 + y^2 + z^2 == 1, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, 
 RegionFunction -> Function[{x, y, z, u, v}, region], 
 MaxRecursion -> 5, PlotPoints -> 100, Mesh -> None, 
 BoundaryStyle -> None]

enter image description here

Alternatively,

ParametricPlot3D[ConditionalExpression[{Cos[v] Sin[u], Sin[v] Sin[u], Cos[u]}, 
  0 < Cos[u] <= Sin[v] Sin[u] <= Cos[v] Sin[u]], 
 {u, 0, Pi}, {v, 0, 2 Pi}, 
 Mesh -> None, BoundaryStyle -> None,  MaxRecursion -> 5, PlotPoints -> 100]

enter image description here

$\endgroup$
  • $\begingroup$ RegionFunction, that's it! Thank you. $\endgroup$ – Jersey Jan 30 '18 at 20:10
  • $\begingroup$ @kglr no need to use ParametricPlot3D to get the surface, just ContourPlot3D don't you? $\endgroup$ – José Antonio Díaz Navas Jan 30 '18 at 20:13
  • $\begingroup$ @JoséAntonioDíazNavas, you are right; just added that alternative. $\endgroup$ – kglr Jan 30 '18 at 20:14

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.