Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from manim import *
- from numpy import sin, cos
- import random
- #Variables
- chaos_num = 10
- fly_speed = 8
- time = [0,5,7,8,10]
- #Random Variables
- A = [random.random()*0.5 for ii in range(chaos_num)]
- B = [random.random()*0.5 for ii in range(chaos_num)]
- Omega = [random.random()*fly_speed for ii in range(chaos_num)]
- Phi = [random.random()*2*PI for ii in range(chaos_num)]
- Psi = [random.random()*2*PI for ii in range(chaos_num)]
- def Fly_Path(t):
- x = sum([a*cos(w*t+phi) for a,w,phi in zip(A,Omega,Phi)])
- y = sum([b*sin(w*t+psi) for b,w,psi in zip(B,Omega,Psi)])
- return(x,y,0)
- class AnimateAxis(Scene):
- def construct(self):
- ## COLOR
- self.camera.background_color = "#fff9ae"
- ## THE ASSETS
- #
- def Fly_Path_N(start,end):
- return ParametricFunction(Fly_Path,
- t_range=[start, end],
- fill_opacity=0,
- color = RED)
- #Define Fly Paths
- fly_path1 = Fly_Path_N(time[0],time[1])
- fly_path2 = Fly_Path_N(time[1],time[2])
- fly_path3 = Fly_Path_N(time[2],time[3])
- fly_path4 = Fly_Path_N(time[3],time[4])
- #Define Axes
- ceiling_axis = Axes(
- x_range=[0, 5, 1],
- y_range=[0, 5, 1],
- tips=False,
- axis_config={"include_numbers": False,
- "include_ticks": False,
- "color": BLACK},
- x_length=5,
- y_length=5
- )
- #Define Ticks
- ceiling_ticks = Axes(
- x_range=[0, 5, 1],
- y_range=[0, 5, 1],
- tips=False,
- axis_config={"include_numbers": False,
- "color": BLACK},
- x_length=5,
- y_length=5
- )
- ## THE ANIMATION ##
- #Fly Appears
- self.play(Create(fly_path1),
- run_time = time[1],
- rate_func=linear)
- #Axis Appears
- self.play(Create(fly_path2),
- Create(ceiling_axis),
- rate_func=linear,
- run_time = time[2]-time[1])
- #Ticks Appear
- self.play(Create(fly_path3),
- DrawBorderThenFill(ceiling_ticks),
- rate_func=linear,
- run_time = time[3]-time[2])
- #Fly Keeps Flying
- self.play(Create(fly_path4),
- rate_func=linear,
- run_time = time[4]-time[3])
- self.wait(5) # Wait for 1 second at the end
Advertisement
Add Comment
Please, Sign In to add comment