You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.6 KiB
48 lines
1.6 KiB
import manim
|
|
from manim import *
|
|
|
|
class SinAndCosFunctionPlot(Scene):
|
|
def construct(self):
|
|
axes = Axes(
|
|
x_range=[-10, 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()
|
|
sin_graph = axes.plot(lambda x: np.sin(x), color=BLUE)
|
|
cos_graph = axes.plot(lambda x: np.cos(x), color=RED)
|
|
|
|
sin_label = axes.get_graph_label(
|
|
sin_graph, "\\sin(x)", x_val=-10, direction=UP / 2
|
|
)
|
|
cos_label = axes.get_graph_label(cos_graph, label="\\cos(x)")
|
|
|
|
vert_line = axes.get_vertical_line(
|
|
axes.i2gp(TAU, cos_graph), color=YELLOW, line_func=Line
|
|
)
|
|
line_label = axes.get_graph_label(
|
|
cos_graph, r"x=2\pi", x_val=TAU, direction=UR, color=WHITE
|
|
)
|
|
|
|
plot = VGroup(axes, sin_graph, cos_graph, vert_line)
|
|
labels = VGroup(axes_labels, sin_label, cos_label, line_label)
|
|
self.add(plot, labels)
|
|
|
|
if __name__ == '__main__':
|
|
config = {
|
|
"quality": "medium_quality",
|
|
"preview": True,
|
|
"media_dir": "./logo_output",
|
|
"pixel_height": 1080,
|
|
"pixel_width": 1920
|
|
}
|
|
|
|
with manim.tempconfig(config):
|
|
scene = SinAndCosFunctionPlot()
|
|
scene.render() |