LoginSignup
0
0

More than 3 years have passed since last update.

manimの作法 その56

Posted at

概要

manimの作法、調べてみた。
AnimatedStreamLines、使ってみた。

サンプルコード

from manimlib.imports import *

def joukowsky_map(z):
    if z == 0:
        return 0
    return z + fdiv(1, z)

def derivative(func, dt = 1e-7):
    return lambda z: (func(z + dt) - func(z)) / dt

def cylinder_flow_vector_field(point, R = 1, U = 1):
    z = R3_to_complex(point)
    return complex_to_R3(derivative(joukowsky_map)(z).conjugate())

class test(Scene):
    def construct(self):
        self.add_vector_field()
        self.begin_flow()
        self.add_circle()
        self.wait(5)
    def add_vector_field(self):
        vector_field = VectorField(cylinder_flow_vector_field, )
        for vector in vector_field:
            if get_norm(vector.get_start()) < 1:
                vector_field.remove(vector)
        vector_field.set_fill(opacity = 0.75)
        self.modify_vector_field(vector_field)
        self.add_foreground_mobjects(vector_field)
    def begin_flow(self):
        stream_lines = StreamLines(cylinder_flow_vector_field, colors = [BLUE_E, BLUE_D, BLUE_C], start_points_generator_config = {
            #   "delta_x": 0.125,
            #   "delta_y": 0.125,
        }, virtual_time = 5, )
        self.add(stream_lines)
        for stream_line in stream_lines:
            if get_norm(stream_line.points[0]) < 1:
                stream_lines.remove(stream_line)
        self.modify_flow(stream_lines)
        stream_line_animation = AnimatedStreamLines(stream_lines)
        stream_line_animation.update(3)
        self.add(stream_line_animation)
    def add_circle(self):
        circle = Circle(radius = 1, stroke_color = YELLOW, fill_color = BLACK, fill_opacity = 1, )
        self.modify_flow(circle)
        self.add_foreground_mobjects(circle)
    def modify_flow(self, mobject):
        pass
    def modify_vector_field(self, vector_field):
        pass





生成した動画

以上。

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