1
$\begingroup$

I can't seem to graph x^2 + y^2 + (z - 3)^2 = 9 in SphericalPlot3D, because all I can set is the radius being equal to 3, but can't compensate for the z - 3 part. How do I move my sphere up the z axis 3!!

$\endgroup$
1
  • $\begingroup$ It is easy with ContourPlot3D: ContourPlot3D[ x^2 + y^2 + (z - 3)^2 == 9, {x, -3, 3}, {y, -3, 3}, {z, 0, 6}] $\endgroup$
    – Bob Hanlon
    Commented Nov 20, 2019 at 0:23

1 Answer 1

3
$\begingroup$

Write the equation for the sphere in spherical coordinates and solve for $r$

ClearAll[r, θ, ϕ]
eqn = r^2 Sin[θ]^2 Cos[ϕ]^2 + 
      r^2 Sin[θ]^2 Sin[ϕ]^2 + 
       (r Cos[θ] - 3)^2 == 9;

r = r /. Last@Solve[eqn, r]

(*   6 Cos[θ]   *)

Plot the result

SphericalPlot3D[r, {θ, 0, π}, {ϕ, 0, 2 π}, AxesLabel -> {X, Y, Z}]

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.