본문 바로가기

Programming/Manim code

(57)
[Manim Collection]Table of Contents 1. Sine Curve by Rotating Dot around the Circle - Code: infograph.tistory.com/230 - Explain the code (by Korean): infograph.tistory.com/222 2. Sine/Cosine curve by rotating the dot around the circle - code: infograph.tistory.com/231 - explain the code (by Korean): infograph.tistory.com/223 3. Moving sine-wave - code: infograph.tistory.com/232 - explain the code (by Korean): infograph.tistory.com..
Draw dots with several circles Code from manimlib.imports import * # draw dots instead the lines class Rotate_Circles3_DrawDots(Scene): def construct(self): running_time = 10.2 ### 1. circles and dots circles_radius = [2.5, 1, 0.8, 0.4, 0.1] circle_orgins = [ np.array([0, 0, 0]), np.array([0 + 2.5, 0, 0]), np.array([2.5 + 1, 0, 0]), np.array([3.5 + 0.8, 0, 0]), np.array([4.3 + 0.1, 0, 0]), ] curve_start = np.array([4.4, 0, 0]..
Draw line with rotating circles Code # draw curve by the last dot class Rotate_Circles2(Scene): def construct(self): running_time = 10.2 ### 1. circles and dots circles_radius = [2.5, 1, 0.8, 0.4, 0.1] circle_orgins = [ np.array([0, 0, 0]), np.array([0 + 2.5, 0, 0]), np.array([2.5 + 1, 0, 0]), np.array([3.5 + 0.8, 0, 0]), np.array([4.3 + 0.1, 0, 0]), ] curve_start = np.array([4.4, 0, 0]) circles = [Circle(radius=r, name=str(i)..
Draw waves by several moving circles Code from manimlib.imports import * class Rotate_Circles(Scene): def construct(self): self.draw_axis() self.rotate_dots() self.wait() def draw_axis(self): #1. axis x_start = np.array([-6.5,0,0]) x_axis = Line(x_start, np.array([6, 0, 0]), color=BLUE, ) y_axis = Line(np.array([-4, 2, 0]), np.array([-4, -2, 0]), color=BLUE) self.add(x_axis, y_axis) #2. circles circles_radius = [1, 0.5, 0.3, 0.2, 0..
Draw elbow-line between two dots code from manimlib.imports import * class ConnectObjects_ByLine(Scene): def construct(self): #1. Creates dots and display them dot1, dot2 = Dot(), Dot() dot1.shift(UP) connected_line = VGroup(Line(dot1.get_center(), dot2.get_center())) self.add(dot1, dot2, connected_line) #2. makes update function to draw the line between the dots def update_line(mob): x1, y1 = dot1.get_center()[0], dot1.get_cen..
Draw summed Sine-wave (Two Circles) code from manimlib.imports import * class TwoCircle_RightSide(Scene): def construct(self): self.show_axis() self.show_circle_dot() self.draw_cycle() self.wait() def show_axis(self): self.x_start = np.array([-6.5,2,0]) x_axis = Line(self.x_start, np.array([6, 2, 0])) y_axis = Line(np.array([-5, 0, 0]), np.array([-5, 0, 0])) self.add(x_axis, y_axis) self.circle1_origin = np.array([-5, 2, 0]) self...
Draw moving sine-wave changing the amplitude Code from manimlib.imports import * class ChangeAmp_SineCurve(Scene): def construct(self): self.show_axis() self.show_circle_dot() self.draw_several_cycle() self.wait() def show_axis(self): self.x_start = np.array([-6,0,0]) x_axis = Line(self.x_start, np.array([6, 0, 0])) y_axis = Line(np.array([-4, -2, 0]), np.array([-4, 2, 0])) self.add(x_axis, y_axis) self.origin_point = np.array([-4, 0, 0]) ..
Draw moving wave by the rotating dots Code from manimlib.imports import * class LongSineCurve(Scene): def construct(self): self.show_axis() self.show_circle_dot() self.draw_several_cycle() self.wait() def show_axis(self): self.x_start = np.array([-6,0,0]) x_axis = Line(self.x_start, np.array([6, 0, 0])) y_axis = Line(np.array([-4, -2, 0]), np.array([-4, 2, 0])) self.add(x_axis, y_axis) self.origin_point = np.array([-4, 0, 0]) self.c..
Moving Sine-Wave Code from manimlib.imports import * class MovingWave(Scene): def construct(self): self.draw_axis() self.draw_sine_wave() def draw_axis(self): x_axis = Line(np.array([-4,0,0]), np.array([4,0,0])) y_axis = Line(np.array([-4,2,0]), np.array([-4,-2,0])) self.add(x_axis, y_axis) self.x_min = -4 self.x_max = 4 def draw_sine_wave(self): sine_wave = self.get_sine_wave() vt = ValueTracker(0) def update_w..
Sine/Cosine curve by rotating the dot around the circle Code from manimlib.imports import * class SineCosine_Curve(Scene): def construct(self): self.show_axis() self.show_circle() self.move_dot_and_draw_curve() self.wait() def show_axis(self): x_start = np.array([-6,2,0]) x_end = np.array([3,2,0]) y_start = np.array([-4,-3,0]) y_end = np.array([-4,3.5,0]) x_axis = Line(x_start, x_end) y_axis = Line(y_start, y_end) self.add(x_axis, y_axis) self.add_xy..