Create Spherical Zone With Manim

Submitted by Jhun Vert on Mon, 11/02/2020 - 20:07

Radius of sphere = 4
Render method= Write

from manimlib.imports import *

class SphericalZone(ThreeDScene):
    def construct(self):
        xyz = ThreeDAxes()
        SphereZone = ParametricSurface(
            self.SphereZoneEq,
            u_min=0,
            u_max=TAU,
            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)
        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:

Category