Skip to content

I tried to improve radial waves class in many aspects #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Arch-User-0
Copy link

I thought the waves should propagate with time, have circular domain. In some cases, if there are several sources in a scene, it is needed to simulate a src start emitting waves while one src is already causing a wave to propagate. I could use functions like move_to() etc, but i wanted to do it with just maths, feel freee to change it if it leads to a better performance
Here are example files i got, i still plan to make it less cluttered in some cases (Eg-#2) but i dont see a way to do it yet with pure maths :

Eg: #1

class diffraction(ThreeDScene):

        def construct(self):

        self.set_camera_orientation(phi=15*DEGREES,theta=-120*DEGREES,zoom=0.7)
        self.renderer.camera.light_source.move_to(3 * OUT + 2*LEFT)

        plane_wave = LinearWave(amplitude=0.2,angular_frequency=2*PI,wavelength=1.5, x_range=[-8,2],y_range=[-3,3],    start_from=-7.5,cutoff_time=10/6)
        plane_wave.propagate_with_time()

        line_1 = Line(start=(2,6,0),end=(2,1.5,0))
        line_2 = Line(start=(2,-1.5,0),end=(2,-6,0))
        self.add(line_1,line_2)

        rad_wave = RadialWave(
    (0, -1.5, 0),
    (0, -1.35, 0),
    (0,  0.00, 0),
    (0,  1.325, 0),
    (0,  1.5, 0),
            amplitude=0.3,
            wavelength=1.5,
            angular_frequency=2*PI,
            x_range=[-5,5],
            y_range=[-5,5],
            shade_in_3d=True,
            stroke_width=0,
            start_when=1.35,
            angle_range=[-PI/2.2, PI/2.2],
            resolution=48
        )
        
        self.add(rad_wave,plane_wave)
        rad_wave.propogate_radially_with_time((2,0,0))
        self.wait(8)

Eg-#2

class interference(ThreeDScene):
    def construct(self):
        axes = ThreeDAxes()
        self.add(axes)

        self.set_camera_orientation(theta=35*DEGREES,phi=35*DEGREES,zoom=0.7)
        t=ValueTracker(0)
        wave_1 = RadialWave( 
            (0,0,0),
            amplitude=0.2,
            wavelength=3/4,
            angular_frequency=2*PI,
            x_range=[-5,5],
            y_range=[-5,5],
            stroke_width=0
        )
        # r_wave.start_updating_wave()
        
        wave_2 = RadialWave( 
            (3,4,0),
            amplitude=0.2,
            wavelength=3/4,
            angular_frequency=2*PI,
            x_range=[-5,5],
            y_range=[-5,5],
            stroke_width=0
        ).set_color(WHITE)
        wave_1.propogate_radially_with_time((0,0,0))
        wave_2.propogate_radially_with_time((3,4,0))

        net_wave = RadialWave( 
            (0,0,0),(3,4,0),
            amplitude=0.4,
            wavelength=3/4,
            angular_frequency=2*PI,
            x_range=[-3,3],
            y_range=[-3,3],
            stroke_width=0,
            start_when=np.sqrt(5)*4/3
        ).set_color(PINK)
        self.add(wave_1,wave_2,net_wave)
        
        net_wave.propogate_radially_with_time((1.5,2,0))
        
        self.wait(6)

You may not recognise some methods from LinearWave class as ive modified it too but i plan not to release it, yet
This is my first PR on github so sorry if i made formatting error or any other mistakes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant