如何编辑我的代码,使我的Manim代码中的图形与函数cos(1/x)的实际图形相似?
实际图表:

from manim import *
from numpy import cos, sqrt
class CreateGraph(GraphScene):
def __init__(self, **kwargs):
GraphScene.__init__(
self,
x_min=-5,
x_max=5,
y_min=-5,
y_max=5,
graph_origin=ORIGIN,
axes_color=GREEN)
def construct(self):
# Create Graph
self.setup_axes(animate=True)
f1 = self.get_graph(lambda x: cos(1/x) , x_min=-4, x_max=4)
# Construct the Figures
self.play(ShowCreation(f1))
self.wait(1)来自Manim的图表:

发布于 2021-05-28 15:04:59
由于0中并没有真正定义cos(1/x),因此可以尝试这样做:
f1 = self.get_graph(lambda x: cos(1/x), discontinuities=[inverse_interpolate(self.x_min, self.x_max, 0)])
根据您的喜好进行编辑。它主要是告诉manim不要在x=0上为cos(1/x)呈现图形。
https://stackoverflow.com/questions/67651123
复制相似问题