Manim方程转换

发布于 2025-01-22 15:04:43 字数 1076 浏览 3 评论 0原文

Manim社区v0.15.1

class Equation_Transformation_Bug(Scene):
    def construct(self):
        equation_1 = MathTex("w", "\\times","v", "=", "1")
        equation_1.shift(UP*2).scale(2)
        equation_2 = MathTex("v", "=", "w^{-1}")
        equation_2.scale(2)
        equation_3 = MathTex("w", "\\times","w^{-1}", "=", "1")
        equation_3.shift(UP*2).scale(2)

        self.play(Write(equation_1), Write(equation_2))
        self.wait(2)
        self.play(FadeOut(equation_1[2]))

        self.play(*[
            Transform(
                equation_2.get_part_by_tex("w^{-1}"),
                equation_3.get_part_by_tex("w^{-1}")                
            )
        ] + [
            Transform(
                equation_1.get_part_by_tex(tex),
                equation_3.get_part_by_tex(tex)
            )
            for tex in ("w", "\\times","=", "1")
        ])
        self.wait(1)

我试图从等式_2获取W^{ - 1}以飞向以前由equation_1占用的斑点,并转换为公式_3。 相反,来自公式的“ 1”,从等式_3转换为w^{ - 1}。 我不是要进行替换变换。

如何将方程式_1转换为公式_3并将w^{ - 1}移动到公式_1的“ v”的位置?

Manim Community v0.15.1

class Equation_Transformation_Bug(Scene):
    def construct(self):
        equation_1 = MathTex("w", "\\times","v", "=", "1")
        equation_1.shift(UP*2).scale(2)
        equation_2 = MathTex("v", "=", "w^{-1}")
        equation_2.scale(2)
        equation_3 = MathTex("w", "\\times","w^{-1}", "=", "1")
        equation_3.shift(UP*2).scale(2)

        self.play(Write(equation_1), Write(equation_2))
        self.wait(2)
        self.play(FadeOut(equation_1[2]))

        self.play(*[
            Transform(
                equation_2.get_part_by_tex("w^{-1}"),
                equation_3.get_part_by_tex("w^{-1}")                
            )
        ] + [
            Transform(
                equation_1.get_part_by_tex(tex),
                equation_3.get_part_by_tex(tex)
            )
            for tex in ("w", "\\times","=", "1")
        ])
        self.wait(1)

I'm trying to get the w^{-1} from equation_2 to fly into the spot formerly occupied by v of equation_1 and transform into equation_3.
The "1" from equation_1, instead, transforms into the w^{-1} from equation_3.
I'm not trying to do a replacement transform.

How do I transform equation_1 into equation_3 and move the w^{-1} in the spot occupied by "v" of equation_1?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你是暖光i 2025-01-29 15:04:43

在这种特殊情况下,使用transform -matchingshapes效果很好的方法:

class Eq(Scene):
    def construct(self):
        equation_1 = MathTex("w", "\\times","v", "=", "1")
        equation_1.shift(UP*2).scale(2)
        equation_2 = MathTex("v", "=", "w^{-1}")
        equation_2.scale(2)
        equation_3 = MathTex("w", "\\times","w^{-1}", "=", "1")
        equation_3.shift(UP*2).scale(2)

        self.play(Write(equation_1), Write(equation_2))
        self.wait(2)
        self.play(FadeOut(equation_1[2]))

        self.play(
            TransformMatchingShapes(
                VGroup(equation_1[0:2], equation_1[3:], equation_2[2].copy()),
                equation_3,
            )
        )

如果形状与不唯一匹配的形状,请查看transform -matchingshapes的实现,有一种方法来调整到底变成了什么。

An approach using TransformMatchingShapes works reasonably well in this particular case:

class Eq(Scene):
    def construct(self):
        equation_1 = MathTex("w", "\\times","v", "=", "1")
        equation_1.shift(UP*2).scale(2)
        equation_2 = MathTex("v", "=", "w^{-1}")
        equation_2.scale(2)
        equation_3 = MathTex("w", "\\times","w^{-1}", "=", "1")
        equation_3.shift(UP*2).scale(2)

        self.play(Write(equation_1), Write(equation_2))
        self.wait(2)
        self.play(FadeOut(equation_1[2]))

        self.play(
            TransformMatchingShapes(
                VGroup(equation_1[0:2], equation_1[3:], equation_2[2].copy()),
                equation_3,
            )
        )

If you have shapes that would not match uniquely, take a look at the implementation of TransformMatchingShapes, there is a way to tweak what exactly gets transformed into what.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文