三角函数原创
from manim import *
class SinAndCosFunctionPlot(Scene):
def construct(self):
ax = Axes().add_coordinates()
axes = Axes(
x_range=[-10.3, 10.3, 1],
y_range=[-1.5, 1.5, 1],
x_length=10,
axis_config={"color": GREEN},
x_axis_config={
"numbers_to_include": np.arange(-10, 10.01, 2),
"numbers_with_elongated_ticks": np.arange(-10, 10.01, 2),
},
tips=False,
)
axes_labels = axes.get_axis_labels(Tex("x").scale(0.7), Text("y").scale(0.45))
self.add(ax,axes_labels)
self.play(Create(ax),run_time=2)
self.wait(1.5)
sin_graph = axes.plot(lambda x: np.sin(x), color=BLUE)
sin_label = axes.get_graph_label(
sin_graph, "\\sin(x2)", x_val=-10, direction=UP / 2
)
self.add(sin_graph)
self.play(Create(sin_graph),run_time=3)
self.wait(1.5)
self.play(Write(sin_label))
self.wait(1.5)
cos_graph = axes.plot(lambda x: np.cos(x), color=RED)
cos_label = axes.get_graph_label(cos_graph, label="\\cos(x)")
self.add(cos_graph)
self.play(Create(cos_graph),run_time=3)
self.wait(1.5)
self.play(Write(cos_label))
self.wait(1.5)
vert_line = axes.get_vertical_line(
axes.i2gp(TAU, cos_graph), color=YELLOW, line_func=Line
)
line_label = axes.get_graph_label(
cos_graph, "x=2\pi", x_val=TAU, direction=UR, color=WHITE
)
self.add(vert_line)
self.play(Create(vert_line))
self.wait(1.5)
self.play(Write(line_label))
self.wait(1.5)
上次更新: 2022/08/24, 17:50:00