Spherical Zone with Manim
Category
The sphere is of radius 4 units, it is hardcoded to the parametric equations. The parametric equations are as follows:
- $x = r \cos \theta \sin \varphi$
- $y = r \cos \theta \cos \varphi$
- $z = r \cos \varphi$
If you check the code, you can see that the latitude and longitude of the sphere are reoriented. The reason is for the sphere to fit the Manim's camera settings.
The orientation of the camera was done by trial and error until I found a view that I wanted.
from manimlib.imports import *
class SphericalZone(ThreeDScene):
def construct(self):
xyz = ThreeDAxes()
SphereZone = ParametricSurface(
self.SphereZoneEq,
# One complete revolution
u_min=0,
u_max=TAU,
# Thickness of the zone
v_min=-PI/12,
v_max=PI/6,
resolution=(50,10)
).set_fill(opacity=0.8)
self.set_camera_orientation(phi=60 * DEGREES)
self.begin_ambient_camera_rotation(rate=0.2)
self.play(ShowCreation(xyz), run_time=1.5)
# Render method= Write
self.play(Write(SphereZone), run_time=3)
self.wait(8)
def SphereZoneEq(self, u, v):
return [
4*np.cos(v)*np.cos(u),
4*np.cos(v)*np.sin(u),
4*np.sin(v)
]
Output video: