I have to animate a FunctionGraph
in manim
with respect to a parameter $a$. Now, this is not a parametric function and ParametricFunction
will not work for me. I am looking for something similar to the variable slider feature on Desmos.
The function that I am looking to plot is
$$y = x ** 2 / 3 + (3.3 – x ** 2) ** 1 / 2 * sin(a * pi * x)$$
where I woul like to vary $a$ to create the animation.
A very rudimentary approach I can imagine is to simply use a for
loop and range()
as shown below,
def construct(self):
for a in range (7, 15, 0.1):
heart = Function Graph(
lambda x: x ** 2 / 3 + (3.3 - x ** 2) ** 1 / 2 * sin(a * pi * x),
x_range = [-1.8, 1.8],
)
self.add(heart)
self.wait(1/3)
self.remove(heart)
But I am hoping for something better designed and better interpolated than my 30 frames per second animation. Is there a better way of dealing with this, and are there any in-built functions for handling this?
Shirsak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.