from manim import *
class TorusURange(ThreeDScene):
    """2.4 限制 u_range 得到缺口环面。
    u 是绕环面中心大圈转的参数，(0, 3π/2) 只画 3/4 圈，
    所以画面上会缺掉一个 90° 的扇形。
    """
    def construct(self):
        self.set_camera_orientation(phi=65 * DEGREES, theta=-45 * DEGREES)
        title = Text("u_range=(0, 3π/2)  缺 90° 扇形", font="STLiti", font_size=32).to_edge(UP)
        self.add_fixed_in_frame_mobjects(title)
        torus = Torus(major_radius=2.5, minor_radius=0.5, resolution=(30, 30),
                      u_range=(0, 3 * PI / 2), checkerboard_colors=[PURPLE_D, PURPLE_E])
        self.play(FadeIn(title), run_time=0.6)
        self.play(FadeIn(torus), run_time=1.8)
        note = Text("u 方向只取 3/4 圈，环面缺一角；u 管大圈、v 管截面",
                    font="STLiti", font_size=22, color=YELLOW).to_edge(DOWN)
        self.add_fixed_in_frame_mobjects(note)
        self.play(FadeIn(note), run_time=0.6)
        self.wait(3.2)
