Example #1
0
    def construct(self):
        digest_config(self, {})
        ## Usually shouldn't need this...
        self.frame_duration = self.CONFIG["frame_duration"]
        ##
        digest_config(self, {})
        circle = Circle(density=self.circle_density, color=self.circle_blue)
        circle.repeat(self.circle_repeats)
        circle.scale(self.radius)
        sphere = Sphere(density=self.sphere_density, color=self.sphere_blue)
        sphere.scale(self.radius)
        sphere.rotate(-np.pi / 7, [1, 0, 0])
        sphere.rotate(-np.pi / 7)
        iris = Mobject()
        iris.interpolate(circle, sphere, self.interpolation_factor)
        for mob, color in [(iris, self.sphere_brown),
                           (circle, self.circle_brown)]:
            mob.highlight(color, lambda (x, y, z): x < 0 and y > 0)
            mob.highlight(
                "black",
                lambda point: np.linalg.norm(point) < \
                              self.inner_radius_ratio*self.radius
            )
        self.name_mob = TextMobject("3Blue1Brown").center()
        self.name_mob.highlight("grey")
        self.name_mob.shift(2 * DOWN)

        self.play(Transform(circle, iris, run_time=self.run_time))
        self.frames = drag_pixels(self.frames)
        self.save_image(IMAGE_DIR)
        self.logo = MobjectFromPixelArray(self.frames[-1])
        self.add(self.name_mob)
        self.dither()
Example #2
0
    def construct(self):
        glass = Region(lambda x, y: y < 0, color=BLUE_E)
        kwargs = {"density": self.zoom_factor * DEFAULT_POINT_DENSITY_1D}
        top_line = Line(SPACE_HEIGHT * UP + 2 * LEFT, ORIGIN, **kwargs)
        extension = Line(ORIGIN, SPACE_HEIGHT * DOWN + 2 * RIGHT, **kwargs)
        bottom_line = Line(ORIGIN, SPACE_HEIGHT * DOWN + RIGHT, **kwargs)
        path1 = Mobject(top_line, extension)
        path2 = Mobject(top_line, bottom_line)
        for mob in path1, path2:
            mob.ingest_submobjects()
        extension.highlight(RED)
        theta1 = np.arctan(bottom_line.get_slope())
        theta2 = np.arctan(extension.get_slope())
        arc = Arc(theta2 - theta1, start_angle=theta1, radius=2)
        question_mark = TextMobject("$\\theta$?")
        question_mark.shift(arc.get_center() + 0.5 * DOWN + 0.25 * RIGHT)
        wave = self.wavify(path2)
        wave.highlight(YELLOW)
        wave.scale(0.5)

        self.add(glass)
        self.play(ShowCreation(path1))
        self.play(Transform(path1, path2))
        self.wait()
        # self.activate_zooming()
        self.wait()
        self.play(ShowPassingFlash(wave, run_time=3, rate_func=None))
        self.wait()
        self.play(ShowCreation(extension))
        self.play(ShowCreation(arc), ShimmerIn(question_mark))
Example #3
0
    def construct(self):
        curve = PeanoCurve(order=5)
        curve.stretch_to_fit_width(2 * SPACE_WIDTH)
        curve.stretch_to_fit_height(2 * SPACE_HEIGHT)
        curve_start = curve.copy()
        curve_start.apply_over_attr_arrays(lambda arr: arr[:200])
        time_line = get_time_line()
        time_line.shift(-time_line.number_to_point(2000))

        self.add(time_line)
        self.play(
            ApplyMethod(time_line.shift,
                        -time_line.number_to_point(1900),
                        run_time=3))
        brace = Brace(
            Mobject(
                Point(time_line.number_to_point(1865)),
                Point(time_line.number_to_point(1888)),
            ), UP)
        words = TextMobject("""
            Cantor drives himself (and the \\\\
            mathematical community at large) \\\\
            crazy with research on infinity.
        """)
        words.next_to(brace, UP)
        self.play(GrowFromCenter(brace), ShimmerIn(words))
        self.dither()
        self.play(Transform(time_line, curve_start), FadeOut(brace),
                  FadeOut(words))
        self.play(ShowCreation(curve, run_time=5, rate_func=None))
        self.dither()
Example #4
0
    def construct(self):
        CycloidScene.construct(self)

        equation = TexMobject(
            ["\\dfrac{\\sin(\\theta)}{\\sqrt{y}}", "= \\text{constant}"])
        sin_sqrt, const = equation.split()
        new_eq = equation.copy()
        new_eq.to_edge(UP, buff=1.3)
        cycloid_word = TextMobject("Cycloid")
        arrow = Arrow(2 * UP, cycloid_word)
        arrow.reverse_points()
        q_mark = TextMobject("?")

        self.play(*map(ShimmerIn, equation.split()))
        self.dither()
        self.play(ApplyMethod(equation.shift, 2.2 * UP), ShowCreation(arrow))
        q_mark.next_to(sin_sqrt)
        self.play(ShimmerIn(cycloid_word))
        self.dither()
        self.grow_parts()
        self.draw_cycloid()
        self.dither()
        extra_terms = [const, arrow, cycloid_word]
        self.play(*[Transform(mob, q_mark) for mob in extra_terms])
        self.remove(*extra_terms)
        self.roll_back()
        q_marks, arrows = self.get_q_marks_and_arrows(sin_sqrt)
        self.draw_cycloid(3, ShowCreation(q_marks), ShowCreation(arrows))
        self.dither()
Example #5
0
    def construct(self):
        definition = TexMobject([
            "\\text{HC}(", "x", ")",
            "=\\lim_{n \\to \\infty}\\text{PHC}_n(", "x", ")"
        ])
        definition.to_edge(UP)
        definition.split()[1].highlight(BLUE)
        definition.split()[-2].highlight(BLUE)
        intro = TextMobject("Three things need to be proven")
        prove_that = TextMobject("Prove that HC is $\\dots$")
        prove_that.scale(0.7)
        prove_that.to_edge(LEFT)
        items = TextMobject([
            "\\begin{enumerate}",
            "\\item Well-defined: ",
            "Points on Pseudo-Hilbert-curves really do converge",
            "\\item A Curve: ",
            "HC is continuous",
            "\\item Space-filling: ",
            "Each point in the unit square is an output of HC",
            "\\end{enumerate}",
        ]).split()
        items[1].highlight(GREEN)
        items[3].highlight(YELLOW_C)
        items[5].highlight(MAROON)
        Mobject(*items).to_edge(RIGHT)

        self.add(definition)
        self.play(ShimmerIn(intro))
        self.dither()
        self.play(Transform(intro, prove_that))
        for item in items[1:-1]:
            self.play(ShimmerIn(item))
            self.dither()
Example #6
0
    def construct(self):
        rect = Rectangle(height=4, width=6, color=WHITE)
        words = TextMobject("Details of proof")
        words.to_edge(UP)

        self.play(ShowCreation(rect), ShimmerIn(words))
        self.wait()
Example #7
0
    def construct(self):
        words, s = TextMobject(["Pseudo-Hilbert Curve", "s"]).split()
        pre_words = TextMobject("Order 1")
        pre_words.next_to(words, LEFT, buff = 0.5)
        s.next_to(words, RIGHT, buff = 0.05, aligned_edge = DOWN)
        cluster = Mobject(pre_words, words, s)
        cluster.center()
        cluster.scale(0.7)
        cluster.to_edge(UP, buff = 0.3)
        cluster.highlight(GREEN)
        grid1 = Grid(1, 1)
        grid2 = Grid(2, 2)
        curve = HilbertCurve(order = 1)

        self.add(words, s)
        self.dither()
        self.play(Transform(
            s, pre_words, 
            path_func = path_along_arc(-np.pi/3)
        ))
        self.dither()
        self.play(ShowCreation(grid1))
        self.dither()
        self.play(ShowCreation(grid2))
        self.dither()
        kwargs = {
            "run_time" : 5,
            "rate_func" : None
        }
        self.play(ShowCreation(curve, **kwargs))
        self.dither()
Example #8
0
    def construct(self):
        logo = ImageMobject("LogoGeneration", invert = False)
        name_mob = TextMobject("3Blue1Brown").center()
        name_mob.highlight("grey")
        name_mob.shift(2*DOWN)
        self.add(name_mob, logo)

        new_text = TextMobject(["with ", "Steven Strogatz"])
        new_text.next_to(name_mob, DOWN)
        self.play(*[
            ShimmerIn(part)
            for part in new_text.split()
        ])
        self.dither()
        with_word, steve = new_text.split()
        steve_copy = steve.copy().center().to_edge(UP)
        # logo.sort_points(lambda p : -np.linalg.norm(p))
        sort_by_color(logo)
        self.play(
            Transform(steve, steve_copy),
            DelayByOrder(Transform(logo, Point())),
            FadeOut(with_word),
            FadeOut(name_mob),
            run_time = 3
        )
Example #9
0
    def construct(self):
        words = TextMobject([
            "Fermat's principle:",
            """
            If a beam of light travels
            from point $A$ to $B$, it does so along the 
            fastest path possible.
            """
        ])
        words.split()[0].highlight(BLUE)
        everything = MobjectFromRegion(Region())
        everything.scale(0.9)
        angles = np.apply_along_axis(
            angle_of_vector, 1, everything.points
        )
        norms = np.apply_along_axis(
            np.linalg.norm, 1, everything.points
        )
        norms -= np.min(norms)
        norms /= np.max(norms)
        alphas = 0.25 + 0.75 * norms * (1 + np.sin(12*angles))/2
        everything.rgbs = alphas.repeat(3).reshape((len(alphas), 3))

        Mobject(everything, words).show()

        everything.sort_points(np.linalg.norm)        
        self.add(words)
        self.play(
            DelayByOrder(FadeIn(everything, run_time = 3)),
            Animation(words)
        )
        self.play(
            ApplyMethod(everything.highlight, WHITE),
        )
        self.dither()
Example #10
0
    def show_angles(self):
        words = TextMobject("""
            Let's see what happens as we change
            the angle in this seed
        """)
        words.to_edge(UP)
        koch, sharper_koch, duller_koch = curves = [
            CurveClass(order=1)
            for CurveClass in StraightKoch, SharperKoch, DullerKoch
        ]
        arcs = [
            Arc(2 * (np.pi / 2 - curve.angle),
                radius=r,
                start_angle=np.pi + curve.angle).shift(
                    curve.points[curve.get_num_points() / 2])
            for curve, r in zip(curves, [0.6, 0.7, 0.4])
        ]
        theta = TexMobject("\\theta")
        theta.shift(arcs[0].get_center() + 2.5 * DOWN)
        arrow = Arrow(theta, arcs[0])

        self.add(words, koch)
        self.play(ShowCreation(arcs[0]))
        self.play(ShowCreation(arrow), ShimmerIn(theta))
        self.wait(2)
        self.remove(theta, arrow)
        self.play(
            Transform(koch, duller_koch),
            Transform(arcs[0], arcs[2]),
        )
        self.play(
            Transform(koch, sharper_koch),
            Transform(arcs[0], arcs[1]),
        )
        self.clear()
Example #11
0
    def construct(self):
        point_a, point_b = 3*LEFT, 3*RIGHT
        dots = []
        for point, char in [(point_a, "A"), (point_b, "B")]:
            dot = Dot(point)
            letter = TexMobject(char)
            letter.next_to(dot, UP+LEFT)
            dot.add(letter)
            dots.append(dot)

        path = ParametricFunction(
            lambda t : (t/2 + np.cos(t))*RIGHT + np.sin(t)*UP,
            start = -2*np.pi,
            end = 2*np.pi
        )
        path.scale(6/(2*np.pi))
        path.shift(point_a - path.points[0])
        path.highlight(RED)
        line = Line(point_a, point_b)
        words = TextMobject("Shortest path from $A$ to $B$")
        words.to_edge(UP)

        self.play(
            ShimmerIn(words),
            *map(GrowFromCenter, dots)
        )
        self.play(ShowCreation(path))
        self.play(Transform(
            path, line,
            path_func = path_along_arc(np.pi)
        ))
        self.dither()
Example #12
0
    def finite_analog(self, left_mob, arrow, right_mob):
        self.clear()
        self.add(left_mob, arrow, right_mob)
        ex = TextMobject("\\times")
        ex.highlight(RED)
        # ex.shift(arrow.get_center())
        middle = TexMobject("\\sum_{n=0}^N 2^n \\equiv -1 \\mod 2^{N+1}")
        finite_analog = TextMobject("Finite analog")
        finite_analog.scale(0.8)
        brace = Brace(middle, UP)
        finite_analog.next_to(brace, UP)
        new_left = left_mob.copy().to_edge(LEFT)
        new_right = right_mob.copy().to_edge(RIGHT)
        left_arrow, right_arrow = [
            Arrow(mob1.get_right()[0] * RIGHT,
                  mob2.get_left()[0] * RIGHT,
                  buff=0)
            for mob1, mob2 in [(new_left, middle), (middle, new_right)]
        ]
        for mob in ex, middle:
            mob.sort_points(np.linalg.norm)

        self.play(GrowFromCenter(ex))
        self.wait()
        self.play(Transform(left_mob, new_left),
                  Transform(arrow.copy(), left_arrow),
                  DelayByOrder(Transform(ex, middle)),
                  Transform(arrow, right_arrow),
                  Transform(right_mob, new_right))
        self.play(GrowFromCenter(brace), ShimmerIn(finite_analog))
        self.wait()
        self.equivalence(left_mob, left_arrow,
                         Mobject(middle, brace, finite_analog))
Example #13
0
    def construct(self):
        text = TextMobject("Which path minimizes travel time?")
        text.to_edge(UP)
        self.generate_start_and_end_points()
        point_a = Dot(self.start_point)
        point_b = Dot(self.end_point)
        A = TextMobject("A").next_to(point_a, UP)
        B = TextMobject("B").next_to(point_b, DOWN)
        paths = self.get_paths()

        for point, letter in [(point_a, A), (point_b, B)]:
            self.play(
                ShowCreation(point),
                ShimmerIn(letter)
            )
        self.play(ShimmerIn(text))
        curr_path = paths[0].copy()
        curr_path_copy = curr_path.copy().ingest_submobjects()
        self.play(
            self.photon_run_along_path(curr_path),
            ShowCreation(curr_path_copy, rate_func = rush_into)
        )
        self.remove(curr_path_copy)
        for path in paths[1:] + [paths[0]]:
            self.play(Transform(curr_path, path, run_time = 4))
        self.dither()
        self.path = curr_path.ingest_submobjects()
Example #14
0
    def show_diameter(self):
        exceptions = [
            self.circle, self.tangent_line, self.pc_line,
            self.right_angle_symbol
        ]
        everything = set(self.mobjects).difference(exceptions)
        everything_copy = Mobject(*everything).copy()
        light_everything = everything_copy.copy()
        dark_everything = everything_copy.copy()
        dark_everything.fade(0.8)
        bottom_point = np.array(self.c_point)
        bottom_point += 2 * self.radius * DOWN
        diameter = Line(bottom_point, self.c_point)
        brace = Brace(diameter, RIGHT)
        diameter_word = TextMobject("Diameter")
        d_mob = TexMobject("D")
        diameter_word.next_to(brace)
        d_mob.next_to(diameter)

        self.remove(*everything)
        self.play(Transform(everything_copy, dark_everything))
        self.dither()
        self.play(ShowCreation(diameter))
        self.play(GrowFromCenter(brace))
        self.play(ShimmerIn(diameter_word))
        self.dither()
        self.play(*[Transform(mob, d_mob) for mob in brace, diameter_word])
        self.remove(brace, diameter_word)
        self.add(d_mob)
        self.play(Transform(everything_copy, light_everything))
        self.remove(everything_copy)
        self.add(*everything)

        self.d_mob = d_mob
        self.bottom_point = bottom_point
Example #15
0
    def construct(self):
        glass = Region(lambda x, y : y < 0, color = BLUE_E)
        self.generate_start_and_end_points()
        straight = Line(self.start_point, self.end_point)
        slow = TextMobject("Slow")
        slow.rotate(np.arctan(straight.get_slope()))
        slow.shift(straight.points[int(0.7*straight.get_num_points())])
        slow.shift(0.5*DOWN)
        too_long = TextMobject("Too long")
        too_long.shift(UP)
        air = TextMobject("Air").shift(2*UP)
        water = TextMobject("Water").shift(2*DOWN)

        self.add(glass)
        self.play(GrowFromCenter(air))
        self.play(GrowFromCenter(water))
        self.dither()
        self.remove(air, water)
        ShowMultiplePathsScene.construct(self)
        self.play(
            Transform(self.path, straight)
        )
        self.dither()
        self.play(GrowFromCenter(slow))
        self.dither()
        self.remove(slow)
        self.leftmost.ingest_submobjects()
        self.play(Transform(self.path, self.leftmost, run_time = 3))
        self.dither()
        self.play(ShimmerIn(too_long))
        self.dither()
Example #16
0
    def construct(self):
        low_res = ImageMobject("low_resolution_lion", invert = False)
        high_res = ImageMobject("Lion", invert = False)
        grid = get_grid().scale(0.8)
        for mob in low_res, high_res:
            mob.replace(grid, stretch = True)
        side_brace = Brace(low_res, LEFT)
        top_brace = Brace(low_res, UP)
        top_words = TextMobject("256 Px", size = "\\normal")
        side_words = top_words.copy().rotate(np.pi/2)
        top_words.next_to(top_brace, UP)
        side_words.next_to(side_brace, LEFT)

        self.add(high_res)
        self.dither()
        self.play(DelayByOrder(Transform(high_res, low_res)))
        self.dither()
        self.play(
            GrowFromCenter(top_brace),
            GrowFromCenter(side_brace),
            ShimmerIn(top_words),
            ShimmerIn(side_words)
        )
        self.dither()
        for mob in grid, high_res:
            mob.sort_points(np.linalg.norm)
        self.play(DelayByOrder(Transform(high_res, grid)))
        self.dither()
Example #17
0
    def construct(self):
        t_axis = NumberLine()
        theta_axis = NumberLine().rotate(np.pi / 2)
        theta_mob = TexMobject("\\theta(t)")
        t_mob = TexMobject("t")
        theta_mob.next_to(theta_axis, RIGHT)
        theta_mob.to_edge(UP)
        t_mob.next_to(t_axis, UP)
        t_mob.to_edge(RIGHT)
        graph = ParametricFunction(
            lambda t: 4 * t * RIGHT + 2 * smooth(t) * UP)
        line = Line(graph.points[0], graph.points[-1], color=WHITE)
        q_mark = TextMobject("?")
        q_mark.next_to(Point(graph.get_center()), LEFT)
        stars = Stars(color=BLACK)
        stars.scale(0.1).shift(q_mark.get_center())

        squiggle = ParametricFunction(lambda t: t * RIGHT + 0.2 * t * (5 - t) *
                                      (np.sin(t)**2) * UP,
                                      start=0,
                                      end=5)

        self.play(ShowCreation(t_axis), ShowCreation(theta_axis),
                  ShimmerIn(theta_mob), ShimmerIn(t_mob))
        self.play(ShimmerIn(q_mark), ShowCreation(graph))
        self.wait()
        self.play(Transform(q_mark, stars), Transform(graph, line))
        self.wait()
        self.play(Transform(graph, squiggle))
        self.wait()
Example #18
0
    def construct(self):
        point_a, point_b = 3 * LEFT, 3 * RIGHT
        dots = []
        for point, char in [(point_a, "A"), (point_b, "B")]:
            dot = Dot(point)
            letter = TexMobject(char)
            letter.next_to(dot, UP + LEFT)
            dot.add(letter)
            dots.append(dot)

        path = ParametricFunction(lambda t:
                                  (t / 2 + np.cos(t)) * RIGHT + np.sin(t) * UP,
                                  start=-2 * np.pi,
                                  end=2 * np.pi)
        path.scale(6 / (2 * np.pi))
        path.shift(point_a - path.points[0])
        path.highlight(RED)
        line = Line(point_a, point_b)
        words = TextMobject("Shortest path from $A$ to $B$")
        words.to_edge(UP)

        self.play(ShimmerIn(words), *map(GrowFromCenter, dots))
        self.play(ShowCreation(path))
        self.play(Transform(path, line, path_func=path_along_arc(np.pi)))
        self.wait()
Example #19
0
    def construct(self):
        scale_factor = 0.9
        grid = Grid(4, 4, point_thickness = 1)
        curve = HilbertCurve(order = 2)
        for mob in grid, curve:
            mob.scale(scale_factor)
        words = TextMobject("""
            Sequence of curves is stable 
            $\\leftrightarrow$ existence of limit curve
        """, size = "\\normal")
        words.scale(1.25)
        words.to_edge(UP)

        self.add(curve, grid)
        self.dither()
        for n in range(3, 7):
            if n == 5:
                self.play(ShimmerIn(words))
            new_grid = Grid(2**n, 2**n, point_thickness = 1)
            new_curve = HilbertCurve(order = n)
            for mob in new_grid, new_curve:
                mob.scale(scale_factor)
            self.play(
                ShowCreation(new_grid),
                Animation(curve)
            )
            self.remove(grid)
            grid = new_grid
            self.play(Transform(curve, new_curve))
            self.dither()
Example #20
0
    def construct(self):
        grids = [
            Grid(
                2**order, 2**order,
                stroke_width = 1
            ).shift(0.3*DOWN)
            for order in 6, 7
        ]
        grid = grids[0]
        side_brace = Brace(grid, LEFT)
        top_brace = Brace(grid, UP)
        top_words = TextMobject("256")
        new_top_words = TextMobject("512")
        side_words = top_words.copy()
        new_side_words = new_top_words.copy()
        for words in top_words, new_top_words:
            words.next_to(top_brace, UP, buff = 0.1)
        for words in side_words, new_side_words:
            words.next_to(side_brace, LEFT)

        self.add(grid)
        self.play(
            GrowFromCenter(side_brace),
            GrowFromCenter(top_brace),
            ShimmerIn(top_words),
            ShimmerIn(side_words)
        )
        self.dither()
        self.play(
            DelayByOrder(Transform(*grids)),
            Transform(top_words, new_top_words),
            Transform(side_words, new_side_words)
        )
        self.dither()
Example #21
0
    def construct(self):
        self.add_cycloid_end_points()
        start = self.point_a.get_center()
        end = self.point_b.get_center()
        angle = 2 * np.pi / 3
        path = Arc(angle, radius=3)
        path.gradient_highlight(RED_D, WHITE)
        radius = Line(ORIGIN, path.points[0])
        randy = Randolph()
        randy.scale(RANDY_SCALE_FACTOR)
        randy.shift(-randy.get_bottom())
        randy_copy = randy.copy()
        words = TextMobject(
            "Circular paths are good, \\\\ but still not the best")
        words.shift(UP)

        self.play(
            ShowCreation(path),
            ApplyMethod(radius.rotate, angle, path_func=path_along_arc(angle)))
        self.play(FadeOut(radius))
        self.play(ApplyMethod(path.position_endpoints_on,
                              start,
                              end,
                              path_func=path_along_arc(-angle)),
                  run_time=3)
        self.adjust_mobject_to_index(randy_copy, 1, path.points)
        self.play(FadeIn(randy_copy))
        self.remove(randy_copy)
        self.slide(randy, path)
        self.play(ShimmerIn(words))
        self.dither()
Example #22
0
    def construct(self):
        self.knob = Circle(color=BLUE_D)
        self.knob.add_line(UP, DOWN)
        self.knob.to_corner(UP + RIGHT)
        self.knob.shift(0.5 * DOWN)
        self.last_angle = np.pi / 2
        arrow = Vector(ORIGIN, RIGHT)
        arrow.next_to(self.knob, LEFT)
        words = TextMobject("Turn this knob over time to define the curve")
        words.next_to(arrow, LEFT)
        self.path = self.get_path()
        self.path.shift(1.5 * DOWN)
        self.path.show()
        self.path.highlight(BLACK)

        randy = Randolph()
        randy.scale(RANDY_SCALE_FACTOR)
        randy.shift(-randy.get_bottom())

        self.play(ShimmerIn(words))
        self.play(ShowCreation(arrow))
        self.play(ShowCreation(self.knob))
        self.dither()
        self.add(self.path)

        self.slide(randy, self.path)
        self.dither()
    def construct(self):
        europe = ImageMobject("Europe", use_cache = False)
        self.add(europe)
        self.freeze_background()

        mathematicians = [
            ("Newton", [-1.75, -0.75, 0]),
            ("Jacob_Bernoulli",[-0.75, -1.75, 0]),
            ("Ehrenfried_von_Tschirnhaus",[0.5, -0.5, 0]),
            ("Gottfried_Wilhelm_von_Leibniz",[0.2, -1.75, 0]),
            ("Guillaume_de_L'Hopital", [-1.75, -1.25, 0]),
        ]

        for name, point in mathematicians:
            man = ImageMobject(name, invert = False)
            if name == "Newton":
                name = "Isaac_Newton"
            name_mob = TextMobject(name.replace("_", " "))
            name_mob.to_corner(UP+LEFT, buff=0.75)
            self.add(name_mob)
            man.scale_to_fit_height(4)
            mobject = Point(man.get_corner(UP+LEFT))
            self.play(Transform(mobject, man))
            man.scale(0.2)
            man.shift(point)
            self.play(Transform(mobject, man))
            self.remove(name_mob)
Example #24
0
    def construct(self):
        self.knob = Circle(color = BLUE_D)
        self.knob.add_line(UP, DOWN)
        self.knob.to_corner(UP+RIGHT)
        self.knob.shift(0.5*DOWN)
        self.last_angle = np.pi/2
        arrow = Vector(ORIGIN, RIGHT)
        arrow.next_to(self.knob, LEFT)
        words = TextMobject("Turn this knob over time to define the curve")
        words.next_to(arrow, LEFT)
        self.path = self.get_path()
        self.path.shift(1.5*DOWN)
        self.path.show()
        self.path.highlight(BLACK)        

        randy = Randolph()
        randy.scale(RANDY_SCALE_VAL)
        randy.shift(-randy.get_bottom())

        self.play(ShimmerIn(words))
        self.play(ShowCreation(arrow))
        self.play(ShowCreation(self.knob))
        self.dither()
        self.add(self.path)

        self.slide(randy, self.path)
        self.dither()
Example #25
0
    def construct(self):
        europe = ImageMobject("Europe", use_cache = False)
        self.add(europe)
        self.freeze_background()

        mathematicians = [
            ("Newton", [-1.75, -0.75, 0]),
            ("Jacob_Bernoulli",[-0.75, -1.75, 0]),
            ("Ehrenfried_von_Tschirnhaus",[0.5, -0.5, 0]),
            ("Gottfried_Wilhelm_von_Leibniz",[0.2, -1.75, 0]),
            ("Guillaume_de_L'Hopital", [-1.75, -1.25, 0]),
        ]

        for name, point in mathematicians:
            man = ImageMobject(name, invert = False)
            if name == "Newton":
                name = "Isaac_Newton"
            name_mob = TextMobject(name.replace("_", " "))
            name_mob.to_corner(UP+LEFT, buff=0.75)
            self.add(name_mob)
            man.scale_to_fit_height(4)
            mobject = Point(man.get_corner(UP+LEFT))
            self.play(Transform(mobject, man))
            man.scale(0.2)
            man.shift(point)
            self.play(Transform(mobject, man))
            self.remove(name_mob)
Example #26
0
    def construct(self):
        words = TextMobject([
            "Fermat's principle:", """
            If a beam of light travels
            from point $A$ to $B$, it does so along the 
            fastest path possible.
            """
        ])
        words.split()[0].highlight(BLUE)
        everything = MobjectFromRegion(Region())
        everything.scale(0.9)
        angles = np.apply_along_axis(angle_of_vector, 1, everything.points)
        norms = np.apply_along_axis(np.linalg.norm, 1, everything.points)
        norms -= np.min(norms)
        norms /= np.max(norms)
        alphas = 0.25 + 0.75 * norms * (1 + np.sin(12 * angles)) / 2
        everything.rgbs = alphas.repeat(3).reshape((len(alphas), 3))

        Mobject(everything, words).show()

        everything.sort_points(np.linalg.norm)
        self.add(words)
        self.play(DelayByOrder(FadeIn(everything, run_time=3)),
                  Animation(words))
        self.play(ApplyMethod(everything.highlight, WHITE), )
        self.dither()
Example #27
0
    def construct(self):
        hilbert_curves, snake_curves = [
            [
                CurveClass(order = n)
                for n in range(2, 7)
            ]
            for CurveClass in HilbertCurve, SnakeCurve
        ]
        for curve in hilbert_curves+snake_curves:
            curve.scale(0.8)
        for curve in hilbert_curves:
            curve.to_edge(LEFT)
        for curve in snake_curves:
            curve.to_edge(RIGHT)
        greater_than = TexMobject(">")
        question_mark = TextMobject("?")
        question_mark.next_to(greater_than, UP)

        self.add(greater_than, question_mark)
        hilbert_curve = hilbert_curves[0]
        snake_curve = snake_curves[0]
        for new_hc, new_sc in zip(hilbert_curves[1:], snake_curves[1:]):
            self.play(*[
                Transform(hilbert_curve, new_hc),
                Transform(snake_curve, new_sc)
            ])
            self.dither()
Example #28
0
 def construct(self):
     words = TextMobject([
         "A function must be", "\\emph{continuous}",
         "if it is to represent a curve."
     ])
     words.split()[1].highlight(YELLOW_C)
     self.add(words)
     self.dither()
Example #29
0
 def setup_background(self):
     glass = Region(lambda x, y : y < 0, color = BLUE_E)
     self.generate_start_and_end_points()
     point_a = Dot(self.start_point)
     point_b = Dot(self.end_point)
     A = TextMobject("A").next_to(point_a, UP)
     B = TextMobject("B").next_to(point_b, DOWN)
     self.add(glass, point_a, point_b, A, B)
Example #30
0
 def construct(self):
     text = TextMobject("Light")
     text.to_edge(UP)
     self.play(ShimmerIn(text))
     self.play(self.photon_run_along_path(
         Cycloid(), rate_func = None
     ))
     self.dither()
Example #31
0
 def construct(self):
     words = TextMobject([
         "This could be the end\\dots",
         "but\\dots"
     ])
     for part in words.split():
         self.play(ShimmerIn(part))
         self.dither()
Example #32
0
 def construct(self):
     text = TextMobject("Light")
     text.to_edge(UP)
     self.play(ShimmerIn(text))
     self.play(self.photon_run_along_path(
         Cycloid(), rate_func = None
     ))
     self.wait()
Example #33
0
    def construct(self):
        dated_events = [
            {
                "date" : 1696, 
                "text": "Johann Bernoulli poses Brachistochrone problem",
                "picture" : "Johann_Bernoulli2"
            },
            {
                "date" : 1662, 
                "text" : "Fermat states his principle of least time",
                "picture" : "Pierre_de_Fermat"
            }
        ]
        speical_dates = [2016] + [
            obj["date"] for obj in dated_events
        ]
        centuries = range(1600, 2100, 100)
        timeline = NumberLine(
            numerical_radius = 300,
            number_at_center = 1800,
            unit_length_to_spatial_width = SPACE_WIDTH/100,
            tick_frequency = 10,
            numbers_with_elongated_ticks = centuries
        )
        timeline.add_numbers(*centuries)
        centers = [
            Point(timeline.number_to_point(year))
            for year in speical_dates
        ]
        timeline.add(*centers)
        timeline.shift(-centers[0].get_center())

        self.add(timeline)
        self.dither()
        run_times = iter([3, 1])
        for point, event in zip(centers[1:], dated_events):
            self.play(ApplyMethod(
                timeline.shift, -point.get_center(), 
                run_time = run_times.next()
            ))
            picture = ImageMobject(event["picture"], invert = False)
            picture.scale_to_fit_width(2)
            picture.to_corner(UP+RIGHT)
            event_mob = TextMobject(event["text"])
            event_mob.shift(2*LEFT+2*UP)
            date_mob = TexMobject(str(event["date"]))
            date_mob.scale(0.5)
            date_mob.shift(0.6*UP)
            line = Line(event_mob.get_bottom(), 0.2*UP)
            self.play(
                ShimmerIn(event_mob),
                ShowCreation(line),
                ShimmerIn(date_mob)
            )
            self.play(FadeIn(picture))
            self.dither(3)
            self.play(*map(FadeOut, [event_mob, date_mob, line, picture]))
Example #34
0
 def label_jump(self):
     jump_points = Mobject(Point(self.spiril1.points[-1]),
                           Point(self.spiril2.points[0]))
     self.brace = Brace(jump_points, RIGHT)
     self.jump = TextMobject("Jump")
     self.jump.next_to(self.brace, RIGHT)
     self.play(GrowFromCenter(self.brace), ShimmerIn(self.jump))
     self.dither()
     self.remove(self.brace, self.jump)
Example #35
0
    def show_pendulum(self, arc_angle = np.pi, arc_color = GREEN):
        words = TextMobject(": Instantaneous center of rotation")
        words.next_to(self.c_label)
        line = Line(self.p_point, self.c_point)
        line_angle = line.get_angle()+np.pi
        line_length = line.get_length()
        line.add(self.p_dot.copy())
        line.get_center = lambda : self.c_point
        tangent_line = Line(3*LEFT, 3*RIGHT)
        tangent_line.rotate(line_angle-np.pi/2)
        tangent_line.shift(self.p_point)
        tangent_line.highlight(arc_color)
        right_angle_symbol = Mobject(
            Line(UP, UP+RIGHT),
            Line(UP+RIGHT, RIGHT)
        )
        right_angle_symbol.scale(0.3)
        right_angle_symbol.rotate(tangent_line.get_angle()+np.pi)
        right_angle_symbol.shift(self.p_point)

        self.play(ShowCreation(line))
        self.play(ShimmerIn(words))
        self.wait()
        pairs = [    
            (line_angle, arc_angle/2),
            (line_angle+arc_angle/2, -arc_angle),
            (line_angle-arc_angle/2, arc_angle/2),
        ]
        arcs = []
        for start, angle in pairs:
            arc = Arc(
                angle = angle,
                radius = line_length,
                start_angle = start,
                color = GREEN
            )
            arc.shift(self.c_point)
            self.play(
                ShowCreation(arc),
                ApplyMethod(
                    line.rotate_in_place, 
                    angle,
                    path_func = path_along_arc(angle)
                ),
                run_time = 2
            )
            arcs.append(arc)
        self.wait()
        self.play(Transform(arcs[1], tangent_line))
        self.add(tangent_line)
        self.play(ShowCreation(right_angle_symbol))
        self.wait()

        self.tangent_line = tangent_line
        self.right_angle_symbol = right_angle_symbol
        self.pc_line = line
        self.remove(words, *arcs)
Example #36
0
 def construct(self):
     curve = HilbertCurve(order=1)
     words = TextMobject("``Hilbert Curve''")
     words.to_edge(UP, buff=0.2)
     self.play(ShimmerIn(words),
               Transform(curve, HilbertCurve(order=2)),
               run_time=2)
     for n in range(3, 8):
         self.play(Transform(curve, HilbertCurve(order=n)), run_time=5. / n)
Example #37
0
    def show_pendulum(self, arc_angle = np.pi, arc_color = GREEN):
        words = TextMobject(": Instantaneous center of rotation")
        words.next_to(self.c_label)
        line = Line(self.p_point, self.c_point)
        line_angle = line.get_angle()+np.pi
        line_length = line.get_length()
        line.add(self.p_dot.copy())
        line.get_center = lambda : self.c_point
        tangent_line = Line(3*LEFT, 3*RIGHT)
        tangent_line.rotate(line_angle-np.pi/2)
        tangent_line.shift(self.p_point)
        tangent_line.highlight(arc_color)
        right_angle_symbol = Mobject(
            Line(UP, UP+RIGHT),
            Line(UP+RIGHT, RIGHT)
        )
        right_angle_symbol.scale(0.3)
        right_angle_symbol.rotate(tangent_line.get_angle()+np.pi)
        right_angle_symbol.shift(self.p_point)

        self.play(ShowCreation(line))
        self.play(ShimmerIn(words))
        self.dither()
        pairs = [    
            (line_angle, arc_angle/2),
            (line_angle+arc_angle/2, -arc_angle),
            (line_angle-arc_angle/2, arc_angle/2),
        ]
        arcs = []
        for start, angle in pairs:
            arc = Arc(
                angle = angle,
                radius = line_length,
                start_angle = start,
                color = GREEN
            )
            arc.shift(self.c_point)
            self.play(
                ShowCreation(arc),
                ApplyMethod(
                    line.rotate_in_place, 
                    angle,
                    path_func = path_along_arc(angle)
                ),
                run_time = 2
            )
            arcs.append(arc)
        self.dither()
        self.play(Transform(arcs[1], tangent_line))
        self.add(tangent_line)
        self.play(ShowCreation(right_angle_symbol))
        self.dither()

        self.tangent_line = tangent_line
        self.right_angle_symbol = right_angle_symbol
        self.pc_line = line
        self.remove(words, *arcs)
Example #38
0
 def construct(self):
     words = TextMobject([
         "A function must be",
         "\\emph{continuous}", 
         "if it is to represent a curve."
     ])
     words.split()[1].highlight(YELLOW_C)
     self.add(words)
     self.dither()
Example #39
0
    def construct(self, order):
        if order == 2:
            result_tex = "(0.125, 0.75)"
        elif order == 3:
            result_tex = "(0.0758,  0.6875)"

        phc, arg, result = TexMobject([
            "\\text{PHC}_%d"%order, 
            "(0.3)", 
            "= %s"%result_tex
        ]).to_edge(UP).split()
        function = TextMobject("Function", size = "\\normal")
        function.shift(phc.get_center()+DOWN+2*LEFT)
        function_arrow = Arrow(function, phc)

        line = Line(5*LEFT, 5*RIGHT)
        curve = HilbertCurve(order = order)
        line.match_colors(curve)
        grid = Grid(2**order, 2**order)
        grid.fade()
        for mob in curve, grid:
            mob.scale(0.7)
        index = int(0.3*line.get_num_points())
        dot1 = Dot(line.points[index])
        arrow1 = Arrow(arg, dot1, buff = 0.1)
        dot2 = Dot(curve.points[index])
        arrow2 = Arrow(result.get_bottom(), dot2, buff = 0.1)

        self.add(phc)
        self.play(
            ShimmerIn(function),
            ShowCreation(function_arrow)
        )
        self.dither()
        self.remove(function_arrow, function)
        self.play(ShowCreation(line))
        self.dither()
        self.play(
            ShimmerIn(arg),
            ShowCreation(arrow1),
            ShowCreation(dot1)
        )
        self.dither()
        self.remove(arrow1)
        self.play(
            FadeIn(grid),            
            Transform(line, curve),
            Transform(dot1, dot2),
            run_time = 2
        )
        self.dither()
        self.play(
            ShimmerIn(result),
            ShowCreation(arrow2)
        )
        self.dither()
Example #40
0
    def construct(self, order):
        if order == 2:
            result_tex = "(0.125, 0.75)"
        elif order == 3:
            result_tex = "(0.0758,  0.6875)"

        phc, arg, result = TexMobject([
            "\\text{PHC}_%d"%order, 
            "(0.3)", 
            "= %s"%result_tex
        ]).to_edge(UP).split()
        function = TextMobject("Function", size = "\\normal")
        function.shift(phc.get_center()+DOWN+2*LEFT)
        function_arrow = Arrow(function, phc)

        line = Line(5*LEFT, 5*RIGHT)
        curve = HilbertCurve(order = order)
        line.match_colors(curve)
        grid = Grid(2**order, 2**order)
        grid.fade()
        for mob in curve, grid:
            mob.scale(0.7)
        index = int(0.3*line.get_num_points())
        dot1 = Dot(line.points[index])
        arrow1 = Arrow(arg, dot1, buff = 0.1)
        dot2 = Dot(curve.points[index])
        arrow2 = Arrow(result.get_bottom(), dot2, buff = 0.1)

        self.add(phc)
        self.play(
            ShimmerIn(function),
            ShowCreation(function_arrow)
        )
        self.wait()
        self.remove(function_arrow, function)
        self.play(ShowCreation(line))
        self.wait()
        self.play(
            ShimmerIn(arg),
            ShowCreation(arrow1),
            ShowCreation(dot1)
        )
        self.wait()
        self.remove(arrow1)
        self.play(
            FadeIn(grid),            
            Transform(line, curve),
            Transform(dot1, dot2),
            run_time = 2
        )
        self.wait()
        self.play(
            ShimmerIn(result),
            ShowCreation(arrow2)
        )
        self.wait()
Example #41
0
    def construct(self):
        words = TextMobject("Yet another bit of Mark Levi cleverness")
        words.to_edge(UP)
        levi = ImageMobject("Mark_Levi", invert = False)
        levi.scale_to_fit_width(6)
        levi.show()

        self.add(levi)
        self.play(ShimmerIn(words))
        self.dither(2)
Example #42
0
    def construct(self):
        rect = Rectangle(height = 4, width = 6, color = WHITE)
        words = TextMobject("Details of proof")
        words.to_edge(UP)

        self.play(
            ShowCreation(rect),
            ShimmerIn(words)
        )
        self.dither()
Example #43
0
    def construct(self):
        words = TextMobject("Yet another bit of Mark Levi cleverness")
        words.to_edge(UP)
        levi = ImageMobject("Mark_Levi", invert=False)
        levi.scale_to_fit_width(6)
        levi.show()

        self.add(levi)
        self.play(ShimmerIn(words))
        self.wait(2)
Example #44
0
 def add_title(self, title, scale_factor = 1.5, animate = False):
     if not isinstance(title, Mobject):
         title = TextMobject(title).scale(scale_factor)
     title.to_edge(UP)
     title.add_background_rectangle()
     if animate:
         self.play(Write(title))
     self.add_foreground_mobject(title)
     self.title = title
     return self
Example #45
0
    def construct(self):
        words = TextMobject([
            "One does not simply define the limit \\\\ \
            of a sequence of", "curves", "\\dots"
        ])
        top_words = TextMobject(["curves", "are functions"]).to_edge(UP)
        curves1 = words.split()[1]
        curves2 = top_words.split()[0]
        words.ingest_submobjects()
        number = TexMobject("0.27")
        pair = TexMobject("(0.53, 0.02)")
        pair.next_to(number, buff=2)
        arrow = Arrow(number, pair)
        Mobject(number, arrow, pair).center().shift(UP)
        number_line = UnitInterval()
        number_line.stretch_to_fit_width(5)
        number_line.to_edge(LEFT).shift(DOWN)
        grid = Grid(4, 4).scale(0.4)
        grid.next_to(number_line, buff=2)
        low_arrow = Arrow(number_line, grid)

        self.play(ShimmerIn(words))
        self.dither()
        self.play(FadeOut(words), ApplyMethod(curves1.replace, curves2),
                  ShimmerIn(top_words.split()[1]))
        self.dither()
        self.play(FadeIn(number))
        self.play(ShowCreation(arrow))
        self.play(FadeIn(pair))
        self.dither()
        self.play(ShowCreation(number_line))
        self.play(ShowCreation(low_arrow))
        self.play(ShowCreation(grid))
        self.dither()
Example #46
0
    def construct(self):
        one_solution = TextMobject(["One ", "solution"])
        two_insights = TextMobject(["Two ", " insights"])
        two, insights = two_insights.split()
        johann = ImageMobject("Johann_Bernoulli2", invert=False)
        mark = ImageMobject("Mark_Levi", invert=False)
        for mob in johann, mark:
            mob.scale(0.4)
        johann.next_to(insights, LEFT)
        mark.next_to(johann, RIGHT)
        name = TextMobject("Mark Levi").to_edge(UP)

        self.play(*map(ShimmerIn, one_solution.split()))
        self.dither()
        for pair in zip(one_solution.split(), two_insights.split()):
            self.play(Transform(*pair, path_func=path_along_arc(np.pi)))
        self.dither()
        self.clear()
        self.add(two, insights)
        for word, man in [(two, johann), (insights, mark)]:
            self.play(Transform(word, Point(word.get_left())),
                      GrowFromCenter(man))
            self.dither()
        self.clear()
        self.play(ApplyMethod(mark.center))
        self.play(ShimmerIn(name))
        self.dither()
Example #47
0
    def construct(self):
        grid = Grid(16, 16).fade()
        snake_curve = SnakeCurve(order=4)
        words = TextMobject("``Snake Curve''")
        words.next_to(grid, UP)

        self.add(grid)
        self.play(ShowCreation(snake_curve, run_time=7, rate_func=None))
        self.dither()
        self.play(ShimmerIn(words))
        self.dither()
Example #48
0
    def rearrange(self):
        sqrt_nudge = 0.2*LEFT        
        y, equals = self.y_equals.split()
        d, sin, squared, theta = self.y_expression.split()
        y_sqrt = TexMobject("\\sqrt{\\phantom{y}}")
        d_sqrt = y_sqrt.copy()
        y_sqrt.shift(y.get_center()+sqrt_nudge)
        d_sqrt.shift(d.get_center()+sqrt_nudge)

        self.play(
            ShimmerIn(y_sqrt),
            ShimmerIn(d_sqrt),
            ApplyMethod(squared.shift, 4*UP),
            ApplyMethod(theta.shift, 1.5* squared.get_width()*LEFT)
        )
        self.dither()
        y_sqrt.add(y)
        d_sqrt.add(d)
        sin.add(theta)

        sin_over = TexMobject("\\dfrac{\\phantom{\\sin(\\theta)}}{\\quad}")
        sin_over.next_to(sin, DOWN, 0.15)
        new_eq = equals.copy()
        new_eq.next_to(sin_over, LEFT)
        one_over = TexMobject("\\dfrac{1}{\\quad}")
        one_over.next_to(new_eq, LEFT)
        one_over.shift(
            (sin_over.get_bottom()[1]-one_over.get_bottom()[1])*UP
        )

        self.play(
            Transform(equals, new_eq),
            ShimmerIn(sin_over),
            ShimmerIn(one_over),
            ApplyMethod(
                d_sqrt.next_to, one_over, DOWN,
                path_func = path_along_arc(-np.pi)
            ),
            ApplyMethod(
                y_sqrt.next_to, sin_over, DOWN,
                path_func = path_along_arc(-np.pi)
            ),
            run_time = 2
        )
        self.dither()

        brace = Brace(d_sqrt, DOWN)
        constant = TextMobject("Constant")
        constant.next_to(brace, DOWN)

        self.play(
            GrowFromCenter(brace),
            ShimmerIn(constant)
        )
Example #49
0
    def rearrange(self):
        sqrt_nudge = 0.2*LEFT        
        y, equals = self.y_equals.split()
        d, sin, squared, theta = self.y_expression.split()
        y_sqrt = TexMobject("\\sqrt{\\phantom{y}}")
        d_sqrt = y_sqrt.copy()
        y_sqrt.shift(y.get_center()+sqrt_nudge)
        d_sqrt.shift(d.get_center()+sqrt_nudge)

        self.play(
            ShimmerIn(y_sqrt),
            ShimmerIn(d_sqrt),
            ApplyMethod(squared.shift, 4*UP),
            ApplyMethod(theta.shift, 1.5* squared.get_width()*LEFT)
        )
        self.wait()
        y_sqrt.add(y)
        d_sqrt.add(d)
        sin.add(theta)

        sin_over = TexMobject("\\dfrac{\\phantom{\\sin(\\theta)}}{\\quad}")
        sin_over.next_to(sin, DOWN, 0.15)
        new_eq = equals.copy()
        new_eq.next_to(sin_over, LEFT)
        one_over = TexMobject("\\dfrac{1}{\\quad}")
        one_over.next_to(new_eq, LEFT)
        one_over.shift(
            (sin_over.get_bottom()[1]-one_over.get_bottom()[1])*UP
        )

        self.play(
            Transform(equals, new_eq),
            ShimmerIn(sin_over),
            ShimmerIn(one_over),
            ApplyMethod(
                d_sqrt.next_to, one_over, DOWN,
                path_func = path_along_arc(-np.pi)
            ),
            ApplyMethod(
                y_sqrt.next_to, sin_over, DOWN,
                path_func = path_along_arc(-np.pi)
            ),
            run_time = 2
        )
        self.wait()

        brace = Brace(d_sqrt, DOWN)
        constant = TextMobject("Constant")
        constant.next_to(brace, DOWN)

        self.play(
            GrowFromCenter(brace),
            ShimmerIn(constant)
        )
Example #50
0
    def construct(self):
        val = 0.3
        text = TextMobject([
            "PHC", "$_n", "(", "%3.1f"%val, ")$", 
            " has a ", "limit point ", "as $n \\to \\infty$"
        ])
        func_parts = text.copy().split()[:5]
        Mobject(*func_parts).center().to_edge(UP)
        num_str, val_str = func_parts[1], func_parts[3]
        curve = UnitInterval()
        curve.sort_points(lambda p : p[0])
        dot = Dot().shift(curve.number_to_point(val))
        arrow = Arrow(val_str, dot, buff = 0.1)
        curve.add_numbers(0, 1)

        self.play(ShowCreation(curve))
        self.play(
            ShimmerIn(val_str),
            ShowCreation(arrow),
            ShowCreation(dot)
        )
        self.dither()
        self.play(
            FadeOut(arrow),
            *[
                FadeIn(func_parts[i])
                for i in 0, 1, 2, 4
            ]
        )
        for num in range(2,9):
            new_curve = HilbertCurve(order = num)
            new_curve.scale(0.8)
            new_dot = Dot(new_curve.points[int(val*new_curve.get_num_points())])
            new_num_str = TexMobject(str(num)).replace(num_str)
            self.play(
                Transform(curve, new_curve),
                Transform(dot, new_dot),
                Transform(num_str, new_num_str)
            )
            self.dither()

        text.to_edge(UP)
        text_parts = text.split()
        for index in 1, -1:
            text_parts[index].highlight()
        starters = Mobject(*func_parts + [
            Point(mob.get_center(), point_thickness=1)
            for mob in text_parts[5:]
        ])
        self.play(Transform(starters, text))
        arrow = Arrow(text_parts[-2].get_bottom(), dot, buff = 0.1)
        self.play(ShowCreation(arrow))
        self.dither()
Example #51
0
    def construct(self):
        point_a = 3*LEFT+3*UP
        point_b = 1.5*RIGHT+3*DOWN
        midpoint = ORIGIN

        lines, arcs, thetas = [], [], []
        counter = it.count(1)
        for point in point_a, point_b:
            line = Line(point, midpoint, color = RED_D)
            angle = np.pi/2-np.abs(np.arctan(line.get_slope()))
            arc = Arc(angle, radius = 0.5).rotate(np.pi/2)
            if point is point_b:
                arc.rotate(np.pi)
                line.reverse_points()
            theta = TexMobject("\\theta_%d"%counter.next())
            theta.scale(0.5)
            theta.shift(2*arc.get_center())
            arc.shift(midpoint)
            theta.shift(midpoint)

            lines.append(line)
            arcs.append(arc)
            thetas.append(theta)
        vert_line = Line(2*UP, 2*DOWN)
        vert_line.shift(midpoint)
        path = Mobject(*lines).ingest_submobjects()
        glass = Region(lambda x, y : y < 0, color = BLUE_E)
        self.add(glass)
        equation = TexMobject([
            "\\dfrac{\\sin(\\theta_1)}{v_{\\text{air}}}",
            "=",            
            "\\dfrac{\\sin(\\theta_2)}{v_{\\text{water}}}",
        ])
        equation.to_corner(UP+RIGHT)
        exp1, equals, exp2 = equation.split()
        snells_law = TextMobject("Snell's Law:")
        snells_law.highlight(YELLOW)
        snells_law.to_edge(UP)

        self.play(ShimmerIn(snells_law))
        self.dither()
        self.play(ShowCreation(path))
        self.play(self.photon_run_along_path(path))
        self.dither()
        self.play(ShowCreation(vert_line))
        self.play(*map(ShowCreation, arcs))
        self.play(*map(GrowFromCenter, thetas))
        self.dither()
        self.play(ShimmerIn(exp1))
        self.dither()
        self.play(*map(ShimmerIn, [equals, exp2]))
        self.dither()
Example #52
0
    def construct(self):
        mathy, bubble = get_mathy_and_bubble()
        squiggle_mouth = mathy.mouth.copy()
        squiggle_mouth.apply_function(
            lambda (x, y, z) : (x, y+0.02*np.sin(50*x), z)
        )
        bubble.ingest_submobjects()        
        bubble.write("Why not use a Hilbert curve \\textinterrobang ")
        words1 = bubble.content
        bubble.write("So, it's not one curve but an infinite family of curves \\dots")
        words2 = bubble.content
        bubble.write("Well, no, it \\emph{is} just one thing, but I need \\\\ \
                      to tell you about a certain infinite family first.")
        words3 =  bubble.content
        description = TextMobject("Mathematician friend", size = "\\small")
        description.next_to(mathy, buff = 2)
        arrow = Arrow(description, mathy)

        self.add(mathy)
        self.play(
            ShowCreation(arrow),
            ShimmerIn(description)
        )
        self.dither()
        point = Point(bubble.get_tip())
        self.play(
            Transform(point, bubble),
        )
        self.remove(point)
        self.add(bubble)
        self.play(ShimmerIn(words1))
        self.dither()
        self.remove(description, arrow)
        self.play(
            Transform(mathy.mouth, squiggle_mouth),
            ApplyMethod(mathy.arm.wag, 0.2*RIGHT, LEFT),
        )
        self.remove(words1)
        self.add(words2)
        self.dither(2)
        self.remove(words2)
        self.add(words3)
        self.dither(2)
        self.play(
            ApplyPointwiseFunction(
                lambda p : 15*p/np.linalg.norm(p),
                bubble
            ),
            ApplyMethod(mathy.shift, 5*(DOWN+LEFT)),
            FadeOut(words3),
            run_time = 3
        )
Example #53
0
    def construct(self):
        left_words = TextMobject("Infinite result")
        right_words = TextMobject("Finite world")
        for words in left_words, right_words:
            words.scale(0.8)
        left_formula = TexMobject(
            "\\sum_{n = 0}^{\\infty} 2^n = -1"
        )
        right_formula = TexMobject("111\\cdots111")
        for formula in left_formula, right_formula:
            formula.add(
                Brace(formula, UP),
            )
            formula.ingest_sub_mobjects()
        right_overwords = TextMobject(
            "\\substack{\
                \\text{How computers} \\\\ \
                \\text{represent $-1$}\
            }"
        ).scale(1.5)

        left_mobs = [left_words, left_formula]
        right_mobs = [right_words, right_formula]
        for mob in left_mobs:
            mob.to_edge(RIGHT, buff = 1)
            mob.shift(SPACE_WIDTH*LEFT)
        for mob in right_mobs:
            mob.to_edge(LEFT, buff = 1)
            mob.shift(SPACE_WIDTH*RIGHT)
        arrow = Arrow(left_words, right_words)
        right_overwords.next_to(right_formula, UP)

        self.play(ShimmerIn(left_words))
        self.play(ShowCreation(arrow))
        self.play(ShimmerIn(right_words))
        self.dither()
        self.play(
            ShimmerIn(left_formula),
            ApplyMethod(left_words.next_to, left_formula, UP)
        )
        self.dither()
        self.play(
            ShimmerIn(right_formula),
            Transform(right_words, right_overwords)
        )
        self.dither()
        self.finite_analog(
            Mobject(left_formula, left_words),
            arrow,
            Mobject(right_formula, right_words)
        )
Example #54
0
 def __init__(self, word, **kwargs):
     self.path = Cycloid(end_theta = np.pi)        
     word_mob = TextMobject(list(word))
     end_word = word_mob.copy()
     end_word.shift(-end_word.get_bottom())
     end_word.shift(self.path.get_corner(DOWN+RIGHT))
     end_word.shift(3*RIGHT)
     self.end_letters = end_word.split()
     for letter in word_mob.split():
         letter.center()
         letter.angle = 0
     unit_interval = np.arange(0, 1, 1./len(word))
     self.start_times = 0.5*(1-(unit_interval))
     Animation.__init__(self, word_mob, **kwargs)
Example #55
0
    def construct(self):
        words = TextMobject("""
            It might come as a surprise how some well-known
            fractals can be described with curves.
        """)
        words.to_edge(UP)

        self.setup(Sierpinski)
        self.add(TextMobject("Speaking of other fractals\\dots"))
        self.dither(3)
        self.clear()
        self.play(ShimmerIn(words))
        for x in range(9):
            self.increase_order()
Example #56
0
 def construct(self):
     curve = HilbertCurve(order = 1)
     words = TextMobject("``Hilbert Curve''")
     words.to_edge(UP, buff = 0.2)
     self.play(
         ShimmerIn(words),
         Transform(curve, HilbertCurve(order = 2)),
         run_time = 2
     )
     for n in range(3, 8):
         self.play(
             Transform(curve, HilbertCurve(order = n)),
             run_time = 5. /n
         )