4
$\begingroup$

I have this code to plot contours:

ContourPlot[(Cos[θ] Cos[ϕ])^(1/4), {θ, -π/2, π/2}, {ϕ, -π/2, π/2}, AxesLabel -> Automatic]

How would I map those contours on a unit sphere (if it is even possible) where θ and ϕ are the spherical angles for the sphere (θ is the inclination calculated from the xy plane and ϕ is azimuth calculated from the x-axis)?

In a post here, I saw a different problem and the suggestion was to use MeshFunctions so I tried:

ParametricPlot3D[{Sin[ϕ] Cos[θ],Cos[ϕ] Cos[θ],Sin[θ]},
{θ, -π/2, π/2}, {ϕ, -π/2, π/2}, 
 MeshFunctions -> {
ContourPlot[(Cos[θ] Cos[ϕ])^(1/4), {θ, -π/2, π/2}, {ϕ, -π/2, π/2}, 
    AxesLabel -> Automatic]
}]

but it spits errors and I do not even know whether this approach is correct.

$\endgroup$
0

2 Answers 2

8
$\begingroup$

EDIT: Corrected slot numbers per input from Simon Wood.

Look at the documentation for MeshFunctions

ParametricPlot3D[{Sin[ϕ] Cos[θ], 
  Cos[ϕ] Cos[θ], 
  Sin[θ]}, {θ, -π/2, π/2}, {ϕ, -π/
   2, π/2}, MeshFunctions -> {(Cos[#4] Cos[#5])^(1/4) &},
 PlotPoints -> 50]

enter image description here

$\endgroup$
1
  • $\begingroup$ The parameters theta and phi are #4 and #5 in the mesh function. $\endgroup$ Jan 16, 2016 at 16:23
8
$\begingroup$

You could use SliceContourPlot3D:

expr = TransformedField["Spherical" -> "Cartesian",
 (Cos[θ - π/2] Cos[ϕ])^(1/4), {r, θ, ϕ} -> {x, y, z}];

SliceContourPlot3D[expr, "CenterSphere", {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]

enter image description here

The missing parts of the sphere are where your expression isn't real.

$\endgroup$
2
  • $\begingroup$ Note that the OP's phi is not the traditional spherical phi: phi = 0 is the xy plane for the OP. At least that's how I read it before. $\endgroup$
    – Michael E2
    Jan 16, 2016 at 17:00
  • $\begingroup$ @MichaelE2, thanks, I hadn't spotted that. $\endgroup$ Jan 16, 2016 at 17:07

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.