-
from manim import *
class demo(Scene):
def construct(self):
axe = Axes(
x_range=(-5, 5),
y_range=(-2, 2),
x_length=10,
y_length=5,
axis_config={
"include_numbers": True,
"tip_shape": StealthTip
}
)
w = ValueTracker(1)
p = ValueTracker(0)
def sin(x):
return np.sin(w.get_value*x + p.get_value)
graph = axe.plot(sin, x_range=(-5, 5), color=RED)
self.add(axe, graph) The above is the code. I originally intended to use the updater to achieve real-time changes in the function image with linear growth of two parameters. I know this can be achieved, but I cannot achieve it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Can you please come over to Discord? It's our preferred way to help people. Also: what editor are you using for your code? Because you have a mismatch in indentation levels which should have been picked up easily by any modern editor for python code. next error of yours: Fixing these problems we get class demo(Scene):
def construct(self):
axe = Axes(
x_range=(-5, 5),
y_range=(-2, 2),
x_length=10,
y_length=5,
axis_config={
"include_numbers": True,
"tip_shape": StealthTip
}
)
w = ValueTracker(1)
p = ValueTracker(0)
def sin(x):
return np.sin(w.get_value()*x + p.get_value())
graph = axe.plot(sin, x_range=(-5, 5), color=RED)
self.add(axe, graph) But in order to animate things you need to
For (1) we will put the class demo(Scene):
def construct(self):
axe = Axes(
x_range=(-5, 5),
y_range=(-2, 2),
x_length=10,
y_length=5,
axis_config={
"include_numbers": True,
"tip_shape": StealthTip
}
)
w = ValueTracker(1)
p = ValueTracker(0)
def sin(x):
return np.sin(w.get_value()*x + p.get_value())
graph = always_redraw(lambda:
axe.plot(sin, x_range=(-5, 5), color=RED)
)
self.add(axe, graph)
self.wait()
self.play(w.animate.set_value(2))
self.wait()
self.play(p.animate.set_value(-180*DEGREES))
self.wait() demo.mp4 |
Beta Was this translation helpful? Give feedback.
Can you please come over to Discord? It's our preferred way to help people.
Also: what editor are you using for your code? Because you have a mismatch in indentation levels which should have been picked up easily by any modern editor for python code.
next error of yours:
.get_value()
is a function without arguments/parameters, yet it still needs a pair of parentheses.Fixing these problems we get