0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

wslでmanim その13

Posted at

概要

wslでmanimやってみた。
練習問題やってみた。

練習問題

3dグラフを書け。

成果物

test_ManimCE_v0.18.1.gif

サンプルコード



from manim import *

class test(ThreeDScene):
	def construct(self):
		self.set_camera_orientation(phi = 75 * DEGREES, theta = 30 * DEGREES)
		axes = ThreeDAxes()
		self.add(axes)
		w = 1
		surface_01 = Surface(lambda u, v: v * complex_to_R3(np.exp(1j * w * u)), u_range = [0, TAU], v_range = [1, 3], checkerboard_colors = None, fill_color = BLUE_B, fill_opacity = 0.8, stroke_color = BLUE_A, resolution = (60, 10))
		self.add(surface_01)
		self.wait()
		self.remove(surface_01)
		surface_02 = Surface(lambda u, v: v * complex_to_R3(np.exp(1j * w * u)) + OUT * u / PI * 2, u_range = [0, TAU], v_range = [1, 3], checkerboard_colors = None, fill_color = BLUE_D, fill_opacity = 0.8, stroke_color = BLUE_A, resolution = (60, 10))
		self.add(surface_02)
		self.wait()
		self.remove(surface_02)
		r = 2
		w = 4
		circle = ParametricFunction(lambda t: r * complex_to_R3(np.exp(1j * w * t)), t_range = (0, TAU * 1.5), color = RED, stroke_width = 8)
		self.add(circle)
		self.wait()
		self.remove(circle)
		spiral_line = ParametricFunction(lambda t: r * complex_to_R3(np.exp(1j * w * t)) + OUT * t, t_range = (0, TAU * 1.5), color = PINK, stroke_width = 8)
		self.add(spiral_line)
		self.wait()
		self.remove(spiral_line)
		theta = PI / 4
		curve_02 = lambda y: np.array([1, y, y * np.tan(theta)])
		w = 2
		surface_func_02 = lambda u, v: complex_to_R3(complex(*curve_02(v)[0:2]) * np.exp(1j * w * u)) + curve_02(v)[-1] * OUT
		surface_by_rotate_02 = Surface(surface_func_02, u_range = [0, TAU], v_range = [2, 2], checkerboard_colors = None, fill_color = BLUE, fill_opacity = 0.8, stroke_color = WHITE, stroke_width = 2.5)
		self.add(surface_by_rotate_02)
		self.wait()
		self.remove(surface_by_rotate_02)
		line_func = lambda y: np.array([1, y, y * np.tan(theta)])
		surface_func = lambda u, v: complex_to_R3(complex(*line_func(v)[0:2]) * np.exp(1j * u)) + line_func(v)[-1] * OUT
		surface_by_rotate = Surface(surface_func, u_range = [0, TAU], v_range = [-2, 2],)
		self.add(surface_by_rotate)
		self.wait()
		self.remove(surface_by_rotate)
		c_func = lambda y: np.array([1, y, y * np.sin(theta)])
		surface_func = lambda u, v: complex_to_R3(np.exp(1j * u)) + c_func(v)[-1] * OUT
		surface_c = Surface(surface_func, u_range = [0, TAU], v_range = [-2, 2],)
		self.add(surface_c)
		self.wait()
		self.remove(surface_c)





以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?