简体   繁体   English

Manim 中的多重线性/非线性变换

[英]Multiple linear/non linear transformations in Manim

I'm writing a script in manim to perform some transformations.我正在编写一个脚本来执行一些转换。 And I want to apply multiple linear/non linear transformations in a sequence to a graph.我想将多个线性/非线性变换按顺序应用于图形。 And I tried it but failed.我试过但失败了。 Here is my code这是我的代码

from manim import *
import numpy as np

class transformation(LinearTransformationScene):
    def construct(self):
        # Linear transformation
        self.apply_matrix([[1, 0], [1, 1]])              # <============

        # Non-linear transformation
        self.apply_nonlinear_transformation(self.func)   # <============

        self.wait()

    def func(self, dot):
        return np.array((max(dot[0], 0), max(dot[1], 0), dot[2]))

And there is a strange behavior which I'm unable to understand is that if I run only one of the highlighted lines.还有一个我无法理解的奇怪行为是,如果我只运行突出显示的行之一。 Then that transformation works fine.然后这种转换工作正常。 But if I run both lines at the same time then it doesn't works which is weird.但是,如果我同时运行两条线,那么它不起作用,这很奇怪。

So what I'm missing?那么我缺少什么?

Add self.wait() between the transformations.在转换之间添加self.wait()

from manim import *
import numpy as np

class transformation(LinearTransformationScene):
    def construct(self):
        # Linear transformation
        self.apply_matrix([[1, 0], [1, 1]])              # <============

         self.wait() #just add this

        # Non-linear transformation
        self.apply_nonlinear_transformation(self.func)   # <============

        self.wait()

    def func(self, dot):
        return np.array((max(dot[0], 0), max(dot[1], 0), dot[2]))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM