是否可以在 manim 中的图形对象上使用 ReplacementTransform?

问题描述

我对 manim 还很陌生

我希望能够绘制折线图,​​并在绘制线之后,围绕其截距旋转它。但是现在,转换没有发生:我的代码显示了相同的 graph0 不变线,并且没有执行 ReplacementTransform。

我也尝试过枢轴,它有效,但是将线绕其中心枢转,即使我可以让它绕其截距枢转,我也不知道如何将其精确到我想要的每个枢轴的等式。

有没有办法让这条线转向我用 graph0、graph1 和 graph2 指定的不同方程?

这是我的代码

class LinePivot(GraphScene):
CONfig = {
    "y_max": 40,"y_min": 0,"x_max": 14,"x_min": 0,"y_tick_frequency": 5,"x_tick_frequency": 1,"axes_color": BLACK,"y_label_direction": LEFT,"x_label_direction": DOWN,"label_nums_color": BLACK,"camera_config": {
        "background_color": WHITE,},}

def construct(self):
    self.setup_axes()

    graph0 = self.get_graph(lambda x: 5 + 2 * x,color=BLACK)
    graph1 = self.get_graph(lambda x: 5 + 3 * x,color=BLACK)
    graph2 = self.get_graph(lambda x: 5 + 4 * x,color=BLACK)

    self.play(ShowCreation(graph0))
    self.wait()
    ReplacementTransform(graph0,graph1,run_time=1)
    self.wait()
    ReplacementTransform(graph1,graph2,run_time=1)
    self.wait()

解决方法

ReplacementTransform(graph0,graph1,run_time=1)

仅创建转换,但不将其添加到场景或渲染它。你想改用

self.play(ReplacementTransform(graph0,graph1),run_time=1)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...