from manim import *
import numpy as np
def head(cn, en):
    t = Text(cn, font="STLiti", font_size=27).to_edge(UP)
    s = Text(en, font="Consolas", font_size=20, color=YELLOW).next_to(t, DOWN, buff=0.10)
    return VGroup(t, s)
def foot(cn):
    return Text(cn, font="STLiti", font_size=20, color=YELLOW).to_edge(DOWN)
class Parametric3D(ThreeDScene):
    def construct(self):
        self.set_camera_orientation(phi=78 * DEGREES, theta=-60 * DEGREES)
        self.add_fixed_in_frame_mobjects(head("三维参数曲线：螺旋线", "ParametricFunction / ThreeDAxes"))
        axes = ThreeDAxes(x_length=6, y_length=5, z_length=5)
        spiral = ParametricFunction(
            lambda u: np.array([1.2 * np.cos(u), 1.2 * np.sin(u), u * 0.16]),
            t_range=[-3 * TAU, 3 * TAU, 0.02], color=RED).set_stroke(width=5)
        self.add(axes)
        self.play(Create(spiral), run_time=3.4)
        self.begin_ambient_camera_rotation(rate=0.18)
        self.wait(2.0)
        self.stop_ambient_camera_rotation()
        self.add_fixed_in_frame_mobjects(foot("z 随参数线性增长，得到均匀上升的螺旋"))
        self.wait(1.4)
