0
$\begingroup$

I'm trying to plot this equation (I believe it to be a cone) in spherical coordinates: $$\theta = \pi/4$$ where $\theta$ is the zenith angle, as per the Mathematica convention, and $r$ takes on all positive real numbers.

Mathematica seems to require me to specify the $r$ values, and specify a range for $\theta$. The closest I've gotten is:

SphericalPlot3D[{R, -1, 1},{\[Theta],\[Pi]/4 - 0.1,\[Pi]/4 + 0.1}, {\[Phi], 0, 2 \[Pi]}]

which produces rings: enter image description here

The question Plot a cone in spherical co-ordinates is related, but doesn't answer my question, because my goal is to continue using spherical coordinates as I plot more complicated equations.

My ultimate goal is to plot: $$ \cos 2 \phi = \cot^2 \theta$$ with $r$ taking on all positive real values.

How can I plot the above in spherical coordinates?

$\endgroup$
2
  • $\begingroup$ The equation you relation you want to plot contains only $2$ variables aka it would produce a $2$D plot. Is there some error in your question? $\endgroup$ Commented Oct 9 at 21:27
  • $\begingroup$ @KevinDietrich I've edited to clarify; can you take a look? $\endgroup$ Commented Oct 9 at 21:32

2 Answers 2

5
$\begingroup$
$Version

(* "14.1.0 for Mac OS X ARM (64-bit) (July 16, 2024)" *)

Clear["Global`*"]

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

(* {r -> Sqrt[x^2 + y^2 + z^2], theta -> ArcTan[z, Sqrt[x^2 + y^2]], 
 phi -> ArcTan[x, y]} *)

max = 5;

ContourPlot3D[
  Evaluate[Cos[2 phi] == Cot[theta]^2 /. conv],
  {x, -max, max}, {y, -max, max}, {z, -max, max},
  AxesLabel -> (Style[#, 14] & /@ {"x", "y", "z"})] // Quiet

enter image description here

$\endgroup$
1
  • $\begingroup$ Great answer +1! Also increasing the plotpoints might remove the glitch at 0 :-) $\endgroup$
    – Hans Olo
    Commented Oct 10 at 6:26
3
$\begingroup$

Edit

Before I post this answer, I have test ContourPlot3D, but the lighting not so right. I finally found that we need to set NormalsFunction -> None.

Clear["Global`*"];
eqn = Cos[2 φ] == Cot[θ]^2;
ContourPlot3D[eqn, {r, 0, 10}, {θ, 0, π}, {φ, 0, 
  2 π}, 
 DisplayFunction -> 
  ReplaceAll[{r_Real, θ_Real, φ_Real} :> 
    Evaluate@FromSphericalCoordinates[{r, θ, φ}]], 
 PlotRange -> All, BoxRatios -> Automatic, Boxed -> False, 
 NormalsFunction -> None]

enter image description here

Clear[eqns];
eqns = {θ == π/4, φ == π/4, r == 4};
ContourPlot3D[eqns, {r, 0, 10}, {θ, 0, π}, {φ, 0,
   2 π}, 
 DisplayFunction -> 
  ReplaceAll[{r_Real, θ_Real, φ_Real} :> 
    Evaluate@FromSphericalCoordinates[{r, θ, φ}]], 
 PlotRange -> All, BoxRatios -> Automatic, Boxed -> False, 
 NormalsFunction -> None, PlotPoints -> 60, MaxRecursion -> 4]

enter image description here

Original

Clear["Global`*"];
eqn = θ == π/4;
reg = DiscretizeRegion[
   ImplicitRegion[
    eqn, {{r, 0, 10}, {θ, 0, π}, {φ, 0, 
      2 π}}], {{-10, 10}, {-10, 10}, {-10, 10}}, 
   MaxCellMeasure -> .01, AccuracyGoal -> 3];
RegionPlot3D[reg, 
 DisplayFunction -> 
  ReplaceAll[{r_Real, θ_Real, φ_Real} :> 
    Evaluate@FromSphericalCoordinates[{r, θ, φ}]], 
 PlotRange -> All, BoxRatios -> Automatic, PlotPoints -> 80, 
 MaxRecursion -> 2,Boxed -> False]

enter image description here

  • the result about eqn = φ == π/4.

enter image description here

  • the result about eqn = r == 1.

enter image description here

  • combine the three coordinates.{θ == π/4, φ == π/4, r == 1}

enter image description here

$\endgroup$

Your Answer

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

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