6
$\begingroup$

Give the definition of parameter x as x[theta_] := (1 + Cos[theta])/2; , how can I plot the following region on a unit ball:

region[theta_, r_] := r < 1 && (x[theta] < -(Sqrt[r] - 1)^(-1) || 
     x[theta] > 1/(Sqrt[r] + 1)); 

I understand the first step should be to define the unit sphere

points = Table[{Sin[theta]*Cos[phi], Sin[theta]*Sin[phi], Cos[theta]}, 
{theta, 0, Pi, Pi/50}, {phi, 0, 2*Pi, Pi/50}]; 

How can I now highlight the above region on this sphere?

EDIT: Here $r$ is not the radius of the ball (whose radius is fixed to be 1 unit) but just a parameter. I should have used some different symbol for it. Apologies for the confusion.

$\endgroup$
6
  • 3
    $\begingroup$ Your question is slightly confusing. You are talking about unit sphere, but then your region contains r < 1. Do you mean unit ball? $\endgroup$ Commented Apr 3, 2025 at 12:28
  • 2
    $\begingroup$ This question is similar to: RegionPlot3D in cylindrical or spherical coordinates?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. $\endgroup$ Commented Apr 3, 2025 at 12:32
  • $\begingroup$ @Domen, thanks. Yes, you are right, it is actually a unit "ball". $\endgroup$ Commented Apr 3, 2025 at 13:52
  • 1
    $\begingroup$ It seems like as r->1 the first condition in the "or" states that x[theta] < Infinity, which would cover the entire surface sphere and perhaps interfere with the visualization? $\endgroup$ Commented Apr 3, 2025 at 14:02
  • $\begingroup$ What are the meaning of the parameter in region[theta_, r_], r is phi $\endgroup$ Commented Apr 3, 2025 at 23:49

2 Answers 2

3
$\begingroup$

I substituted x[theta] into the region. Your region is the whole unit ball.

ru = Thread[{r, theta, phi} -> ToSphericalCoordinates[{x, y, z}]];

RegionPlot3D[
 0 < r < 1 && 
   0 < theta < 
    Pi && ((1 + Cos[theta])/
       2 < -(Sqrt[r] - 1)^(-1) || (1 + Cos[theta])/2 > 
      1/(Sqrt[r] + 1)) /. ru, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
 PlotPoints -> 50]

enter image description here

But if we change direction of inequalities (< to > and > to <) we get a different region that is just a portion of unit ball.

RegionPlot3D[
 0 < r < 1 && 
   0 < theta < 
    Pi && ((1 + Cos[theta])/
       2 > -(Sqrt[r] - 1)^(-1) || (1 + Cos[theta])/2 < 
      1/(Sqrt[r] + 1)) /. ru, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
 PlotPoints -> 50]

enter image description here

$\endgroup$
3
$\begingroup$

Edited as per comments below

Perhaps you can experiment with the following where I use sphericalRegionPlot3D cited above with spherical coordinates $\{r,\theta,\phi\}$ and since you don't specify $\phi$ I plot the range $0<\phi<2\pi$, and use only part of your region since first inequality on $r$ covers the whole ball: $$ \frac{1+\cos{\theta}}{2}>\frac{1}{\sqrt{r}+1} $$

In the plots below, the inequality is the upper half-ball with a protruding tip shown in the first plot below then superimposed onto the unit ball in the second plot.

 sphericalRegionPlot3D[
   ineq_, {r_, rmin_ : 0, rmax_ : 1}, {th_, thmin_ : 0, thmax_}, {ph_,
     phmin_, phmax_}, opts___] := 
  RegionPlot3D[
   With[{r = Sqrt[x^2 + y^2 + z^2], 
     th = ArcCos[z/Sqrt[x^2 + y^2 + z^2]], ph = ArcTan[x, y] + Pi}, 
    ineq && rmin <= r <= rmax && thmin <= th <= thmax && 
     phmin <= ph <= phmax], {x, -rmax, rmax}, {y, -rmax, 
    rmax}, {z, -rmax, rmax}, 
   MeshFunctions -> {Sqrt[#1^2 + #2^2 + #3^2] &, ArcTan[#1, #2] &, 
     ArcCos[#3/Sqrt[#1^2 + #2^2 + #3^2]] &}, opts];


x[theta_] := (1 + Cos[theta])/2;
f[r_] := 1/(Sqrt[r] + 1)

unitBallP = 
  RegionPlot3D[
   x^2 + y^2 + z^2 < 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
   PlotStyle -> {Red, Opacity[0.3]}];

ballRegionP = 
  sphericalRegionPlot3D[
   x[theta] > f[rho], {rho, 0, 1}, {theta, 1/100, Pi}, {phi, 0, 2 Pi},
    PlotPoints -> 50, PlotStyle -> {Blue, Opacity[0.2]}];
Show[{ballRegionP, unitBallP}]

enter image description here

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks @josh. In my case $r$ is not the radius of the ball, but just a parameter. $\endgroup$ Commented Apr 3, 2025 at 17:27
  • 1
    $\begingroup$ You have an error, {rho, 1/2, 1} should be {rho, 0, 1}. OP does not have restriction that r>1/2. Also theta is in range (0, Pi) not (0, 2 PI). $\endgroup$ Commented Apr 3, 2025 at 18:13
  • $\begingroup$ @azerbajdzan: Ok thanks. I edited my post to reflect those changes. $\endgroup$ Commented Apr 3, 2025 at 20:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.