# Sphere animation

I need to make an animation to visualize spherical coordinates. So,what I need is, when I increase r, it traces a radius r. Just to make it easier, it traces in z-axis. Then, when we increase angle phi from 0 to pi,it traces a semicircle. And at end if we increase angle theta from 0 to 2 pi, the semicircle makes one complete revolution to make a sphere. I tried few things with RevolutionPlot3D but it is not helping.

We need to RevolutionPlot3D the three curves and add another two surfaces.

With[{r0 = 1, φ0 = π/3},
Show[ParametricPlot[{0, r}, {r, 0, r0}, PlotStyle -> Red],
ParametricPlot[{r0*Cos[π/2 - φ],
r0*Sin[π/2 - φ]}, {φ, 0.01, φ0},
PlotStyle -> Green],
ParametricPlot[{r*Cos[π/2 - φ0],
r*Sin[π/2 - φ0]}, {r, 0.01, r0}, PlotStyle -> Blue]
, PlotRange -> All]]


Manipulate[
Show[RevolutionPlot3D[{0, r}, {r, 0, r0}, {θ,
0, φ0},
PlotRange -> 1.2, PerformanceGoal -> "Quality"],
RevolutionPlot3D[{0, r}, {r, 0, r0}, {θ, 0, φ0},
RevolutionAxis ->
PlotRange -> 1.2, PerformanceGoal -> "Quality"],
RevolutionPlot3D[{r0*Cos[π/2 - φ],
r0*Sin[π/2 - φ]}, {φ,
0, φ0}, {θ, 0.02, θ0},
RevolutionAxis -> {0, 0, 1}, PerformanceGoal -> "Quality",
PlotStyle -> Green, Mesh -> None],
RevolutionPlot3D[{r*Cos[π/2 - φ0],
r*Sin[π/2 - φ0]}, {r, 0, r0}, {θ,
0.02, θ0}, RevolutionAxis -> {0, 0, 1},
PerformanceGoal -> "Quality", PlotStyle -> Blue]], {{r0, 0.02},
0.02, 1}, {{φ0, 0.02}, .01, π}, {{θ0, 0.01},
0.01, 2 π}]


• (+1) for this excellent solution. Out of curiosity, how can you create an animation from mathematica by using Manipulate and not Animate. Do you have a link or a quick answer?
– bmf
Commented Apr 4, 2022 at 2:01
• @bmf Thanks! I am using ScreenToGif here. Althought we can Export the Animate or Manipulate to gif, but is always too large to send to the forum. Commented Apr 4, 2022 at 2:08
• @cvgmt Thank you very much for this wonderful animation. This is exactly I was looking for. Commented Apr 4, 2022 at 2:12
• @cvgmt many thanks for the tip. I'll keep it in mind :-)
– bmf
Commented Apr 4, 2022 at 2:15

Something like the following?

1. Using spherical coordinates

Solve the equation for the sphere

eqn = r^2 Sin[θ]^2 Cos[φ]^2 +
r^2 Sin[θ]^2 Sin[φ]^2 + (r Cos[θ])^2 == xx;
r = r /. Last@Solve[eqn, r]


and then plot using and SphericalPlot3D with a Manipulate

Manipulate[
SphericalPlot3D[r /. xx -> xx2, {θ, 0, yy2}, {φ, 0, zz2},
PlotRange -> All, AxesLabel -> {"X", "Y", "Z"}], {xx2, 0, 1}, {yy2,
Pi/10, Pi}, {zz2, Pi/10, 2 Pi}]


1. Using cartesian coordinates

We can use RegionPlot3D

Manipulate[
RegionPlot3D[
x^2 + y^2 + z^2 ≤ 1, {x, -1, xx2}, {y, -1, yy2}, {z, -1, zz2},
PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}], {xx2, 0, 1}, {yy2, 0,
1}, {zz2, 0, 1}]