概要
manimの作法、調べてみた。
begin_ambient_camera_rotation使ってみた。
サンプルコード
from manimlib.imports import *
class dSurface(ParametricSurface):
def __init__(self, **kwargs):
kwargs = {
"u_min": -1.5,
"u_max": 1.5,
"v_min": -1.5,
"v_max": 1.5,
"checkerboard_colors": [GREEN, BLUE],
"checkerboard_opacity": 0.5
}
ParametricSurface.__init__(self, self.func, **kwargs)
def func(self, x, y):
return np.array([x, y, x**2 + y**2])
class test(ThreeDScene):
def construct(self):
self.set_camera_orientation(phi = 75 * DEGREES, theta = 30 * DEGREES)
axes = ThreeDAxes()
self.add(axes)
surface = dSurface()
self.play(ShowCreation(surface))
self.move_camera(phi = 45 * DEGREES, theta = 30 * DEGREES)
self.wait()
self.begin_ambient_camera_rotation()
self.wait()
self.remove(surface)
sphere = ParametricSurface(lambda u, v: np.array([1.5 * np.cos(u) * np.cos(v), 1.5 * np.cos(u) * np.sin(v), 1.5 * np.sin(u)]), v_min = 0, v_max = TAU, u_min = -PI / 2, u_max = PI / 2, checkerboard_colors = [RED_D, RED_E], resolution = (15, 32))
self.play(ShowCreation(sphere))
self.wait()
self.remove(sphere)
cylinder = ParametricSurface(lambda u, v: np.array([np.cos(TAU * v), np.sin(TAU * v), 1.0 * (1 - u)]), resolution = (6, 32))
self.play(ShowCreation(cylinder))
self.wait()
self.remove(cylinder)
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)
surface = ParametricSurface(lambda u, v: np.array([u, v, np.sin(u ** 2 + v ** 2)]), u_min = -4, u_max = 4, v_min = -4, v_max = 4, resolution = (120, 120))
self.play(ShowCreation(surface))
self.wait()
self.remove(sphere)
生成した動画
以上。