Example #1
0
 def get_det(self):
     matrix = Matrix(np.array([
         ["\\hat{\\imath}", "\\hat{\\jmath}", "\\hat{k}"],
         ["v_%d"%d for d in range(1, 4)],
         ["w_%d"%d for d in range(1, 4)],
     ]).T)
     matrix.set_column_colors(X_COLOR, V_COLOR, W_COLOR)
     matrix.get_mob_matrix()[1, 0].set_color(Y_COLOR)
     matrix.get_mob_matrix()[2, 0].set_color(Z_COLOR)
     VGroup(*matrix.get_mob_matrix()[1, 1:]).shift(0.15*DOWN)
     VGroup(*matrix.get_mob_matrix()[2, 1:]).shift(0.35*DOWN)
     det_text = get_det_text(matrix)
     det_text.add(matrix)
     return det_text
Example #2
0
    def show_triple_cross_product(self):
        colors = [WHITE, ORANGE, W_COLOR]
        tex_mobs = list(map(TexMobject, get_vect_tex(*"uvw")))
        u_tex, v_tex, w_tex = tex_mobs
        arrays = [
            Matrix(["%s_%d"%(s, d) for d in range(1, 4)])
            for s in "uvw"
        ]
        defs_equals = VGroup()
        definitions = VGroup()
        for array, tex_mob, color in zip(arrays, tex_mobs, colors):
            array.set_column_colors(color)
            tex_mob.set_color(color)
            equals = TexMobject("=")
            definition = VGroup(tex_mob, equals, array)
            definition.arrange(RIGHT)
            definitions.add(definition)
            defs_equals.add(equals)
        definitions.arrange(buff = MED_SMALL_BUFF)
        definitions.shift(2*DOWN)

        mobs_with_targets = list(it.chain(
            tex_mobs, *[a.get_entries() for a in arrays]
        ))
        for mob in mobs_with_targets:
            mob.target = mob.copy()
        matrix = Matrix(np.array([
            [e.target for e in array.get_entries()]
            for array in arrays
        ]).T)
        det_text = get_det_text(matrix, background_rect = False)
        syms = times1, times2, equals = [
            TexMobject(sym) 
            for sym in ("\\times", "\\times", "=",)
        ]
        triple_cross = VGroup(
            u_tex.target, times1, v_tex.target, times2, w_tex.target, equals
        )
        triple_cross.arrange()

        final_mobs = VGroup(triple_cross, VGroup(det_text, matrix))
        final_mobs.arrange()
        final_mobs.next_to(self.title, DOWN, buff = MED_SMALL_BUFF)

        for mob in definitions, final_mobs:
            mob.set_width(FRAME_X_RADIUS - 1)

        for array in arrays:
            brackets = array.get_brackets()
            brackets.target = matrix.get_brackets()
            mobs_with_targets.append(brackets)
        for def_equals in defs_equals:
            def_equals.target = equals
            mobs_with_targets.append(def_equals)

        self.play(FadeIn(
            definitions,
            run_time = 2,
            lag_ratio = 0.5
        ))
        self.wait(2)
        self.play(*[
            Transform(mob.copy(), mob.target)
            for mob in tex_mobs
        ] + [
            Write(times1),
            Write(times2),
        ])
        triple_cross.add(*self.get_mobjects_from_last_animation()[:3])
        self.play(*[
            Transform(mob.copy(), mob.target)
            for mob in mobs_with_targets
            if mob not in tex_mobs
        ])
        u_entries = self.get_mobjects_from_last_animation()[:3]
        v_entries = self.get_mobjects_from_last_animation()[3:6]
        w_entries = self.get_mobjects_from_last_animation()[6:9]
        self.play(Write(det_text))
        self.wait(2)

        self.det_text = det_text
        self.definitions = definitions
        self.u_entries = u_entries
        self.v_entries = v_entries
        self.w_entries = w_entries
        self.matrix = matrix
        self.triple_cross = triple_cross
        self.v_tex, self.w_tex = v_tex, w_tex
        self.equals = equals