mirror of
https://github.com/3b1b/manim.git
synced 2025-08-01 06:22:54 +08:00
Beginning Bell's and Waves projects
This commit is contained in:
116
waves.py
Normal file
116
waves.py
Normal file
@ -0,0 +1,116 @@
|
||||
from helpers import *
|
||||
|
||||
from mobject.tex_mobject import TexMobject
|
||||
from mobject import Mobject
|
||||
from mobject.image_mobject import ImageMobject
|
||||
from mobject.vectorized_mobject import *
|
||||
|
||||
from animation.animation import Animation
|
||||
from animation.transform import *
|
||||
from animation.simple_animations import *
|
||||
from animation.continual_animation import ContinualAnimation
|
||||
from animation.playground import *
|
||||
from topics.geometry import *
|
||||
from topics.characters import *
|
||||
from topics.functions import *
|
||||
from topics.fractals import *
|
||||
from topics.number_line import *
|
||||
from topics.combinatorics import *
|
||||
from topics.numerals import *
|
||||
from topics.three_dimensions import *
|
||||
from topics.objects import *
|
||||
from topics.probability import *
|
||||
from topics.complex_numbers import *
|
||||
from scene import Scene
|
||||
from scene.reconfigurable_scene import ReconfigurableScene
|
||||
from scene.zoomed_scene import *
|
||||
from camera import Camera
|
||||
from mobject.svg_mobject import *
|
||||
from mobject.tex_mobject import *
|
||||
|
||||
E_COLOR = BLUE
|
||||
M_COLOR = RED
|
||||
|
||||
class OscillatingVector(ContinualAnimation):
|
||||
CONFIG = {
|
||||
"tail" : ORIGIN,
|
||||
"frequency" : 1,
|
||||
"A_x" : 1,
|
||||
"A_y" : 0,
|
||||
"phi_x" : 0,
|
||||
"phi_y" : 0,
|
||||
}
|
||||
def setup(self):
|
||||
self.vector = self.mobject
|
||||
|
||||
def update_mobject(self, dt):
|
||||
f = self.frequency
|
||||
t = self.total_time
|
||||
angle = 2*np.pi*f*t
|
||||
vect = np.array([
|
||||
self.A_x*np.exp(complex(0, angle + self.phi_x)),
|
||||
self.A_y*np.exp(complex(0, angle + self.phi_y)),
|
||||
0,
|
||||
]).real
|
||||
self.vector.put_start_and_end_on(self.tail, self.tail+vect)
|
||||
|
||||
|
||||
class EMScene(Scene):
|
||||
def construct(self):
|
||||
pass
|
||||
|
||||
|
||||
class Test(Scene):
|
||||
def construct(self):
|
||||
E_vect = Vector(UP, color = E_COLOR)
|
||||
wiggle = OscillatingVector(
|
||||
E_vect,
|
||||
A_x = 2,
|
||||
A_y = 1,
|
||||
phi_x = np.pi/2,
|
||||
frequency = 0.5,
|
||||
tail = UP+RIGHT,
|
||||
)
|
||||
randy = Randolph()
|
||||
|
||||
self.add(randy, wiggle)
|
||||
self.dither(2)
|
||||
self.play(FadeOut(E_vect))
|
||||
self.dither(2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user