Movement

声明

这一页翻译自elteoremadebeethoven的 manim_3feb_docs

Homotopy

class manimlib.animation.movement.Homotopy(homotopy, mobject, **kwargs)

Homotopy is a function from (x, y, z, t) to (x’, y’, z’)

HomotopyExample
class HomotopyExample(Scene):
    def construct(self):
        def plane_wave_homotopy(x, y, z, t):
            norm = get_norm([x, y])
            tau = interpolate(5, -5, t) + norm/FRAME_X_RADIUS
            alpha = sigmoid(tau)
            return [x, y + 0.5*np.sin(2*np.pi*alpha)-t*SMALL_BUFF/2, z]

        mobjects=VGroup(
            TextMobject("Text").scale(3),
            Square(),
        ).arrange_submobjects(RIGHT,buff=2)

        self.add(mobjects)
        self.play(
            *[Homotopy(
                plane_wave_homotopy,
                mob
            ) for mob in mobjects]
        )
        self.wait(0.3)

ComplexHomotopy

class manimlib.animation.movement.ComplexHomotopy(complex_homotopy, mobject, **kwargs)

Complex Hootopy a function Cx[0, 1] to C

PhaseFlow

class manimlib.animation.movement.PhaseFlow(function, mobject, **kwargs)
PhaseFlowExample
class PhaseFlowExample(Scene):
    def construct(self):
        def func(t):
            return t*0.5*RIGHT

        mobjects=VGroup(
            TextMobject("Text").scale(3),
            Square(),
        ).arrange_submobjects(RIGHT,buff=2)

        self.play(
            *[PhaseFlow(
                func, mob,
                run_time = 2,
            )for mob in mobjects]
        )

        self.wait()

MoveAlongPath

class manimlib.animation.movement.MoveAlongPath(mobject, path, **kwargs)
MoveAlongPathExample
class MoveAlongPathExample(Scene):
    def construct(self):
        line=Line(ORIGIN,RIGHT*FRAME_WIDTH,buff=1)
        line.move_to(ORIGIN)
        dot=Dot()
        dot.move_to(line.get_start())

        self.add(line,dot)
        self.play(
            MoveAlongPath(dot,line)
        )
        self.wait(0.3)