概要
manimの作法、調べてみた。
complex_to_R3使ってみた。
サンプルコード
from manimlib.imports 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 = ParametricSurface(lambda u, v: v * complex_to_R3(np.exp(1j * w * u)), u_min = 0, u_max = TAU, v_min = 1, v_max = 3, checkerboard_colors = None, fill_color = BLUE_B, fill_opacity = 0.8, stroke_color = BLUE_A, resolution = (60, 10))
self.play(ShowCreation(surface_01))
self.wait()
self.remove(surface_01)
surface_02 = ParametricSurface(lambda u, v: v * complex_to_R3(np.exp(1j * w * u)) + OUT * u / PI * 2, u_min = 0, u_max = TAU, v_min = 1, v_max = 3, checkerboard_colors = None, fill_color = BLUE_D, fill_opacity = 0.8, stroke_color = BLUE_A, resolution = (60, 10))
self.play(ShowCreation(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_min = 0, t_max = TAU * 1.5, color = RED, stroke_width = 8)
self.play(ShowCreation(circle))
self.wait()
self.remove(circle)
spiral_line = ParametricFunction(lambda t: r * complex_to_R3(np.exp(1j * w * t)) + OUT * t, t_min = 0, t_max = TAU * 1.5, color = PINK, stroke_width = 8)
self.play(ShowCreation(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 = ParametricSurface(surface_func_02, u_min = 0, u_max = TAU, v_min = -2, v_max = 2, checkerboard_colors = None, fill_color = BLUE, fill_opacity = 0.8, stroke_color = WHITE, stroke_width = 2.5)
self.play(ShowCreation(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 = ParametricSurface(surface_func, u_min = 0, u_max = TAU, v_min = -2, v_max = 2,)
self.play(ShowCreation(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 = ParametricSurface(surface_func, u_min = 0, u_max = TAU, v_min = -2, v_max = 2,)
self.play(ShowCreation(surface_c))
self.wait()
self.remove(surface_c)
生成した動画
以上。