Advertisement
Guest User

Untitled

a guest
May 24th, 2024
138
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. from manim import *
  2. import numpy as np
  3.  
  4. class atomAbsorbsHeat(Scene):
  5. def get_sine_wave(self,dx=0):
  6. return FunctionGraph\
  7. (
  8. lambda x: 0.1*np.sin((12*x+dx)),
  9. color = YELLOW,
  10. x_range=[-3, 3]
  11. )
  12.  
  13. def construct(self):
  14. photon = self.get_sine_wave()
  15. d_theta = ValueTracker(0)
  16. def updateWave(func):
  17. func.become\
  18. (
  19. self.get_sine_wave(dx=d_theta.get_value())
  20. )
  21. return func
  22. photon.add_updater(updateWave)
  23. photon.rotate(PI/2)
  24.  
  25. nucleus = Circle(radius=0.5, color=RED, fill_opacity=1)
  26.  
  27. electron = Circle(radius=0.1, color=BLUE, fill_opacity=1).shift(2*RIGHT) #next_to(nucleus,2*RIGHT)
  28.  
  29. orbit1 = Circle(radius=2, color=BLUE_A,stroke_width=1)
  30.  
  31. orbit2 = Circle(radius=3.3, color=BLUE_A, stroke_width=1)
  32.  
  33. everything = VGroup(nucleus,orbit1,orbit2,electron,photon)
  34.  
  35. self.play(FadeIn(everything))
  36. self.play(d_theta.animate.set_value(2*PI*-10))
  37. self.wait()
Advertisement
Comments
  • uwezi
    1 year
    # Python 1.18 KB | 0 0
    1. class atomAbsorbsHeat(Scene):
    2.     def get_sine_wave(self,dx=0):
    3.         return FunctionGraph\
    4.                 (
    5.                     lambda x: 0.1*np.sin((12*x+dx)),
    6.                     color = YELLOW,
    7.                     x_range=[-3, 3]
    8.                 )
    9.  
    10.     def construct(self):
    11.         photon = self.get_sine_wave()
    12.         d_theta = ValueTracker(0)
    13.         phi =ValueTracker(0)
    14.         def updateWave(func):
    15.             func.become\
    16.                     (
    17.                         self.get_sine_wave(dx=d_theta.get_value()).rotate(phi.get_value())
    18.                     )
    19.             return func
    20.         photon.add_updater(updateWave)
    21.  
    22.         nucleus = Circle(radius=0.5, color=RED, fill_opacity=1)
    23.  
    24.         electron = Circle(radius=0.1, color=BLUE, fill_opacity=1).shift(2*RIGHT) #next_to(nucleus,2*RIGHT)
    25.  
    26.         orbit1 = Circle(radius=2, color=BLUE_A,stroke_width=1)
    27.  
    28.         orbit2 = Circle(radius=3.3, color=BLUE_A, stroke_width=1)
    29.  
    30.         everything = VGroup(nucleus,orbit1,orbit2,electron,photon)
    31.  
    32.         self.play(FadeIn(everything))
    33.         self.play(phi.animate.set_value(PI/2))
    34.         self.play(d_theta.animate.set_value(2*PI*-10))
    35.         self.wait()
    36.  
    37.  
Add Comment
Please, Sign In to add comment
Advertisement