0
0

wslでmanim その5

Posted at

概要

wslでmanimやってみた。
manim見つけたので、やってみた。

参考にしたページ

サンプルコード

from manim import *

class RiemanIntegral(Scene):
	def construct(self):
		axes = Axes(x_range = [-0.5, 5], x_length = 8, y_range = [-0.5, 10], y_length = 7).add_coordinates()
		axes_labels = axes.get_axis_labels(MathTex("t").scale(1), MathTex("v").scale(1))
		graph = axes.plot(lambda x: 0.4 * (x - 1) * (x - 3) * (x - 4) + 6, x_range = [-0.5, 5], color = YELLOW)
		graph_label = axes.get_graph_label(graph = graph, label = MathTex("v(t)"))
		self.add(axes, graph, axes_labels, graph_label)
		dx_list = [4, 1, 0.5, 0.3, 0.1, 0.05, 0.01]
		rectangles = VGroup(*[axes.get_riemann_rectangles(graph = graph, x_range = [0, 4], dx = dx, stroke_width = 0.1, stroke_color = WHITE, ) for dx in dx_list])
		first_area = rectangles[0]
		for k in range(1, len(dx_list)):
			new_area = rectangles[k]
			self.play(Transform(first_area, new_area), run_time = 2)
			self.wait(0.5)
		self.wait()

成果物

RiemanIntegral_ManimCE_v0.18.1.gif

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0