Beispiel #1
0
    def setup(self):
        # The has_already_setup attr is to not break all the old Scenes
        if hasattr(self, "has_already_setup"):
            return
        self.has_already_setup = True
        self.background_mobjects = []
        self.submobjects = []
        self.transformable_mobjects = []
        self.moving_vectors = []
        self.transformable_labels = []
        self.moving_mobjects = []

        self.t_matrix = np.array(self.t_matrix)
        self.background_plane = NumberPlane(**self.background_plane_kwargs)

        if self.show_coordinates:
            self.background_plane.add_coordinates()
        if self.include_background_plane:
            self.add_background_mobject(self.background_plane)
        if self.include_foreground_plane:
            self.plane = NumberPlane(**self.foreground_plane_kwargs)
            self.add_transformable_mobject(self.plane)
        if self.show_basis_vectors:
            self.basis_vectors = self.get_basis_vectors(
                i_hat_color=self.i_hat_color,
                j_hat_color=self.j_hat_color,
            )
            self.moving_vectors += list(self.basis_vectors)
            self.i_hat, self.j_hat = self.basis_vectors
            self.add(self.basis_vectors)
 def construct(self):
     my_plane = NumberPlane(x_line_frequency=2,
                            y_line_frequency=2,
                            faded_line_ratio=2)
     my_plane.add(my_plane.get_axis_labels())
     self.add(my_plane)
     self.wait()
    def construct(self):
        plane = NumberPlane(**self.plane_kwargs)
        plane.add(plane.get_axis_labels())
        self.add(plane)

        self.field = VGroup(*[
            self.calc_field(x * RIGHT + y * UP) for x in np.arange(-9, 9, 1)
            for y in np.arange(-5, 5, 1)
        ])

        source_charge = self.Positron().move_to(self.point_charge_loc)
        self.play(FadeIn(source_charge))
        self.play(ShowCreation(self.field))
        self.moving_charge()
Beispiel #4
0
 def add_plane(self, animate=False, **kwargs):
     """
     Adds a NumberPlane object to the background.
     Parameters
     ----------
     animate : (bool=False)
         Whether or not to animate the addition of the plane via ShowCreation.
     **kwargs
         Any valid keyword arguments accepted by NumberPlane.
     
     Returns
     -------
     NumberPlane
         The NumberPlane object.
     """
     plane = NumberPlane(**kwargs)
     if animate:
         self.play(ShowCreation(plane, lag_ratio=0.5))
     self.add(plane)
     return plane
    def construct(self):
        plane = NumberPlane()
        plane.add(plane.get_axis_labels())
        self.add(plane)

        points = [
            x * RIGHT + y * UP for x in np.arange(-5, 5, 1)
            for y in np.arange(-5, 5, 1)
        ]

        vec_field = []
        for point in points:
            field = 0.5 * RIGHT + 0.5 * UP
            result = Vector(field).shift(point)
            vec_field.append(result)

        draw_field = VGroup(*vec_field)

        self.play(ShowCreation(draw_field))
        self.wait(2)
Beispiel #6
0
    def construct(self):
        # Background
        plane = NumberPlane(x_range=(0, 14, 0.5), y_range=(0, 8, 0.5))
        plane.axes.set_stroke(BLUE, 1)
        plane.fade(0.5)
        self.add(plane)

        # Pis
        pis = self.get_pis()
        pis.set_height(self.pi_height)
        pis.arrange(RIGHT, aligned_edge=DOWN)
        pis.move_to(self.pi_bottom, DOWN)
        self.pis = pis
        self.add(pis)

        plane.move_to(pis.get_bottom() + SMALL_BUFF * DOWN)

        # Message
        if self.use_date:
            message = self.get_date_message()
        else:
            message = self.get_probabalistic_message()
        message.set_height(self.message_height)
        message.next_to(pis, DOWN)
        message.set_stroke(BLACK, 5, background=True)
        self.add(message)

        # Suppoerter note
        if self.add_supporter_note:
            note = self.get_supporter_note()
            note.scale(0.5)
            message.shift((MED_SMALL_BUFF - SMALL_BUFF) * UP)
            note.next_to(message, DOWN, SMALL_BUFF)
            self.add(note)

        yellow_parts = [sm for sm in message if sm.get_color() == YELLOW]
        for pi in pis:
            if yellow_parts:
                pi.look_at(yellow_parts[-1])
            else:
                pi.look_at(message)
Beispiel #7
0
 def add_plane(self, animate=False, **kwargs):
     plane = NumberPlane(**kwargs)
     if animate:
         self.play(ShowCreation(plane, lag_ratio=0.5))
     self.add(plane)
     return plane
Beispiel #8
0
 def add_plane(self, animate=False, **kwargs):
     plane = NumberPlane(**kwargs)
     if animate:
         self.play(ShowCreation(plane, submobject_mode="lagged_start"))
     self.add(plane)
     return plane