Overlapping when trying to transform equations in Manim

58 Views Asked by At

I'm making some manim animations for a presentation but I'm having a problem. When I try to use ReplacementTransform to go from transform_paction1 to transform_paction2, it overlaps in the animation. Here's my complete code so far.

class LanMec(Scene): 
    def construct(self): 
        # Now talk about usual lagrangian mechanics 
        st1 = Text("In usual Lagrangian Mechancis, one begins with:", font_size=30)
        st1.to_corner(UP + LEFT)
        self.play(Write(st1))
        self.wait()

        # Define Action
        paction = MathTex(r"S = \int_a^b dt L(q, \dot{q}) \ \to")
        paction.shift(2*LEFT)
        self.play(Write(paction.shift(2*LEFT)))
        self.wait(2)

        # Creating curve
        plane = NumberPlane()

        curve = ParametricFunction(
            lambda t: np.array([t, np.sin(t), 0]),
            color=WHITE,
            t_range=[1, 4 * PI],
        )
        curve.next_to(paction, 5*RIGHT)


        axes = Axes(
            x_range=[0, 2 * PI, 1],
            y_range=[-1, 1, 1],
            axis_config={"color": RED_D},
        )

        axes.x_axis.shift(plane.c2p(0, 0))
        axes.y_axis.shift(plane.c2p(0, 0))
        curve.shift(plane.c2p(0, 0))

        # Curve right next to the action
        self.play(Create(plane.next_to(paction, 5*RIGHT)), Create(axes.next_to(paction, 5*RIGHT)))
        self.wait()
        self.play(Create(curve.next_to(paction, 5*RIGHT)))
        self.wait()
        self.play(FadeOut(curve), FadeOut(axes), FadeOut(plane))
        self.wait(1)

        transform_paction1 = MathTex(r"S = \int_a^b dt L(q, \dot{q})")
        self.play(Transform(paction, transform_paction1))
        self.wait()
        transform_paction2 = MathTex(r"\delta S = \int_a^b dt  \delta L(q, \dot{q}) = 0")
        transform_st1 = Text("Thus, variations in the action functional result in:", font_size=30)
        transform_st1.to_corner(UP + LEFT)
        self.play(ReplacementTransform(st1, transform_st1))
        transform_paction_group = VGroup(transform_paction1, transform_paction2)
        self.play(TransformMatchingTex(transform_paction_group[0], transform_paction_group[1]))
        self.wait()
0

There are 0 best solutions below