概要
wslでmanimやってみた。
練習問題やってみた。
練習問題
3dグラフを書け。
成果物
サンプルコード
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)
以上。