class GrowToOrder8PseudoHilbertCurve(Scene): def construct(self): self.curve = HilbertCurve(order=1) self.add(self.curve) self.dither() while self.curve.order < 8: self.increase_order() def increase_order(self): mini_curves = [ self.curve.copy().scale(0.5).shift(1.5 * vect) for vect in [LEFT + DOWN, LEFT + UP, RIGHT + UP, RIGHT + DOWN] ] self.remove(self.curve) self.play(Transform(self.curve.copy(), mini_curves[0])) self.play( *[GrowFromCenter(mini_curve) for mini_curve in mini_curves[1:]]) self.dither() self.clear() self.add(*mini_curves) self.play(*[ ApplyMethod(curve.rotate_in_place, np.pi, axis) for curve, axis in [(mini_curves[0], UP + RIGHT), (mini_curves[3], UP + LEFT)] ]) self.curve = HilbertCurve(order=self.curve.order + 1) self.play(ShowCreation(self.curve, run_time=2)) self.remove(*mini_curves) self.dither()
def construct(self): curve = HilbertCurve(order = 6) curve.set_color(WHITE) colored_curve = curve.copy() colored_curve.thin_out(3) lion = ImageMobject("lion", invert = False) lion.replace(curve, stretch = True) sparce_lion = lion.copy() sparce_lion.thin_out(100) distance_matrix = cdist(colored_curve.points, sparce_lion.points) closest_point_indices = np.apply_along_axis( np.argmin, 1, distance_matrix ) colored_curve.rgbas = sparce_lion.rgbas[closest_point_indices] line = Line(5*LEFT, 5*RIGHT) Mobject.align_data(line, colored_curve) line.rgbas = colored_curve.rgbas self.add(lion) self.play(ShowCreation(curve, run_time = 3)) self.play( FadeOut(lion), Transform(curve, colored_curve), run_time = 3 ) self.wait() self.play(Transform(curve, line, run_time = 5)) self.wait()
def construct(self): coords_set = [ORIGIN] for n in range(int(FRAME_WIDTH)): for vect in UP, RIGHT: for k in range(n): new_coords = coords_set[-1]+((-1)**n)*vect coords_set.append(new_coords) square = Square(side_length = 1, color = WHITE) squares = Mobject(*[ square.copy().shift(coords) for coords in coords_set ]).ingest_submobjects() self.play( DelayByOrder(FadeIn(squares)), run_time = 3 ) curve = HilbertCurve(order = 6).scale(1./6) all_curves = Mobject(*[ curve.copy().shift(coords) for coords in coords_set ]).ingest_submobjects() all_curves.thin_out(10) self.play(ShowCreation( all_curves, rate_func = None, run_time = 15 ))
def construct(self): curve = HilbertCurve(order=1) grid = Grid(2, 2, stroke_width=1) self.add(grid, curve) for order in range(2, 6): self.wait() new_grid = Grid(2**order, 2**order, stroke_width=1) self.play(ShowCreation(new_grid), Animation(curve)) self.remove(grid) grid = new_grid self.play(Transform(curve, HilbertCurve(order=order))) square = Square(side_length=6, color=WHITE) square.corner = Mobject1D() square.corner.add_line(3 * DOWN, ORIGIN) square.corner.add_line(ORIGIN, 3 * RIGHT) square.digest_mobject_attrs() square.scale(2**(-5)) square.corner.set_color( Color(rgb=curve.rgbas[curve.get_num_points() / 3])) square.shift( grid.get_corner(UP+LEFT)-\ square.get_corner(UP+LEFT) ) self.wait() self.play(FadeOut(grid), FadeOut(curve), FadeIn(square)) self.play(ApplyMethod(square.replace, grid)) self.wait()
def construct(self): scale_factor = 0.9 grid = Grid(4, 4, stroke_width=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.wait() for n in range(3, 7): if n == 5: self.play(ShimmerIn(words)) new_grid = Grid(2**n, 2**n, stroke_width=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.wait()
def construct(self): curve = HilbertCurve(order = 6) curve.highlight(WHITE) colored_curve = curve.copy() colored_curve.thin_out(3) lion = ImageMobject("lion", invert = False) lion.replace(curve, stretch = True) sparce_lion = lion.copy() sparce_lion.thin_out(100) distance_matrix = cdist(colored_curve.points, sparce_lion.points) closest_point_indices = np.apply_along_axis( np.argmin, 1, distance_matrix ) colored_curve.rgbas = sparce_lion.rgbas[closest_point_indices] line = Line(5*LEFT, 5*RIGHT) Mobject.align_data(line, colored_curve) line.rgbas = colored_curve.rgbas self.add(lion) self.play(ShowCreation(curve, run_time = 3)) self.play( FadeOut(lion), Transform(curve, colored_curve), run_time = 3 ) self.wait() self.play(Transform(curve, line, run_time = 5)) self.wait()
def construct(self): coords_set = [ORIGIN] for n in range(int(2*SPACE_WIDTH)): for vect in UP, RIGHT: for k in range(n): new_coords = coords_set[-1]+((-1)**n)*vect coords_set.append(new_coords) square = Square(side_length = 1, color = WHITE) squares = Mobject(*[ square.copy().shift(coords) for coords in coords_set ]).ingest_submobjects() self.play( DelayByOrder(FadeIn(squares)), run_time = 3 ) curve = HilbertCurve(order = 6).scale(1./6) all_curves = Mobject(*[ curve.copy().shift(coords) for coords in coords_set ]).ingest_submobjects() all_curves.thin_out(10) self.play(ShowCreation( all_curves, rate_func = None, run_time = 15 ))
def construct(self): words = TextMobject("Order 3 Pseudo-Hilbert Curve") words.set_color(GREEN) words.to_edge(UP) grid4 = Mobject(Grid(2, 2), Grid(4, 4, stroke_width=2)) grid8 = Grid(8, 8, stroke_width=1) order_3_curve = HilbertCurve(order=3) mini_curves = [ HilbertCurve(order=2).scale(0.5).shift(1.5 * vect) for vect in [LEFT + DOWN, LEFT + UP, RIGHT + UP, RIGHT + DOWN] ] self.add(words, grid4) self.wait() self.play(ShowCreation(grid8)) self.wait() self.play(*map(GrowFromCenter, mini_curves)) self.wait() self.clear() self.add(words, grid8, *mini_curves) self.play(*[ ApplyMethod(curve.rotate_in_place, np.pi, axis) for curve, axis in [(mini_curves[0], UP + RIGHT), (mini_curves[3], UP + LEFT)] ]) self.play(ShowCreation(order_3_curve, run_time=5)) self.wait()
def increase_order(self): mini_curves = [ self.curve.copy().scale(0.5).shift(1.5*vect) for vect in [ LEFT+DOWN, LEFT+UP, RIGHT+UP, RIGHT+DOWN ] ] self.remove(self.curve) self.play( Transform(self.curve.copy(), mini_curves[0]) ) self.play(*[ GrowFromCenter(mini_curve) for mini_curve in mini_curves[1:] ]) self.wait() self.clear() self.add(*mini_curves) self.play(*[ ApplyMethod(curve.rotate, np.pi, axis) for curve, axis in [ (mini_curves[0], UP+RIGHT), (mini_curves[3], UP+LEFT) ] ]) self.curve = HilbertCurve(order = self.curve.order+1) self.play(ShowCreation(self.curve, run_time = 2)) self.remove(*mini_curves) self.wait()
def construct(self): words = TextMobject("Order 2 Pseudo-Hilbert Curve") words.to_edge(UP, buff=0.3) words.set_color(GREEN) grid2 = Grid(2, 2) grid4 = Grid(4, 4, stroke_width=2) # order_1_curve = HilbertCurve(order = 1) # squaggle_curve = order_1_curve.copy().apply_function( # lambda (x, y, z) : (x + np.cos(3*y), y + np.sin(3*x), z) # ) # squaggle_curve.show() mini_curves = [ HilbertCurve(order=1).scale(0.5).shift(1.5 * vect) for vect in [LEFT + DOWN, LEFT + UP, RIGHT + UP, RIGHT + DOWN] ] last_curve = mini_curves[0] naive_curve = Mobject(last_curve) for mini_curve in mini_curves[1:]: line = Line(last_curve.points[-1], mini_curve.points[0]) naive_curve.add(line, mini_curve) last_curve = mini_curve naive_curve.ingest_submobjects() naive_curve.set_color_by_gradient(RED, GREEN) order_2_curve = HilbertCurve(order=2) self.add(words, grid2) self.wait() self.play(ShowCreation(grid4)) self.play(*[ShowCreation(mini_curve) for mini_curve in mini_curves]) self.wait() self.play(ShowCreation(naive_curve, run_time=5)) self.remove(*mini_curves) self.wait() self.play(Transform(naive_curve, order_2_curve)) self.wait()
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)
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 = Tex([ "\\text{PHC}_%d"%order, "(0.3)", "= %s"%result_tex ]).to_edge(UP).split() function = TexText("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.get_points()[index]) arrow1 = Arrow(arg, dot1, buff = 0.1) dot2 = Dot(curve.get_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()
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.wait() 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.wait() 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(), stroke_width=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.wait()
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.wait() 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.wait() text.to_edge(UP) text_parts = text.split() for index in 1, -1: text_parts[index].set_color() starters = Mobject(*func_parts + [ Point(mob.get_center(), stroke_width=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.wait()
def construct(self, order): start_color, end_color = RED, GREEN curve = HilbertCurve(order = order) line = Line(5*LEFT, 5*RIGHT) for mob in curve, line: mob.set_color_by_gradient(start_color, end_color) freq_line = get_freq_line() freq_line.replace(line, stretch = True) unit = 6./(2**order) #sidelength of pixel up = unit*UP right = unit*RIGHT lower_left = 3*(LEFT+DOWN) squares = Mobject(*[ Square( side_length = unit, color = WHITE ).shift(x*right+y*up) for x, y in it.product(list(range(2**order)), list(range(2**order))) ]) squares.center() targets = Mobject() for square in squares.submobjects: center = square.get_center() distances = np.apply_along_axis( lambda p : get_norm(p-center), 1, curve.points ) index_along_curve = np.argmin(distances) fraction_along_curve = index_along_curve/float(curve.get_num_points()) target = square.copy().center().scale(0.8/(2**order)) line_index = int(fraction_along_curve*line.get_num_points()) target.shift(line.get_points()[line_index]) targets.add(target) self.add(squares) self.play(ShowCreation( curve, run_time = 5, rate_func=linear )) self.wait() self.play( Transform(curve, line), Transform(squares, targets), run_time = 3 ) self.wait() self.play(ShowCreation(freq_line)) self.wait()
def construct(self, order): start_color, end_color = RED, GREEN curve = HilbertCurve(order = order) line = Line(5*LEFT, 5*RIGHT) for mob in curve, line: mob.gradient_highlight(start_color, end_color) freq_line = get_freq_line() freq_line.replace(line, stretch = True) unit = 6./(2**order) #sidelength of pixel up = unit*UP right = unit*RIGHT lower_left = 3*(LEFT+DOWN) squares = Mobject(*[ Square( side_length = unit, color = WHITE ).shift(x*right+y*up) for x, y in it.product(range(2**order), range(2**order)) ]) squares.center() targets = Mobject() for square in squares.submobjects: center = square.get_center() distances = np.apply_along_axis( lambda p : np.linalg.norm(p-center), 1, curve.points ) index_along_curve = np.argmin(distances) fraction_along_curve = index_along_curve/float(curve.get_num_points()) target = square.copy().center().scale(0.8/(2**order)) line_index = int(fraction_along_curve*line.get_num_points()) target.shift(line.points[line_index]) targets.add(target) self.add(squares) self.play(ShowCreation( curve, run_time = 5, rate_func = None )) self.dither() self.play( Transform(curve, line), Transform(squares, targets), run_time = 3 ) self.dither() self.play(ShowCreation(freq_line)) self.dither()
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.set_color(GREEN) grid1 = Grid(1, 1) grid2 = Grid(2, 2) curve = HilbertCurve(order = 1) self.add(words, s) self.wait() self.play(Transform( s, pre_words, path_func = path_along_arc(-np.pi/3) )) self.wait() self.play(ShowCreation(grid1)) self.wait() self.play(ShowCreation(grid2)) self.wait() kwargs = { "run_time" : 5, "rate_func" : None } self.play(ShowCreation(curve, **kwargs)) self.wait()
def increase_order(self): mini_curves = [ self.curve.copy().scale(0.5).shift(1.5*vect) for vect in [ LEFT+DOWN, LEFT+UP, RIGHT+UP, RIGHT+DOWN ] ] self.remove(self.curve) self.play( Transform(self.curve.copy(), mini_curves[0]) ) self.play(*[ GrowFromCenter(mini_curve) for mini_curve in mini_curves[1:] ]) self.dither() self.clear() self.add(*mini_curves) self.play(*[ ApplyMethod(curve.rotate_in_place, np.pi, axis) for curve, axis in [ (mini_curves[0], UP+RIGHT), (mini_curves[3], UP+LEFT) ] ]) self.curve = HilbertCurve(order = self.curve.order+1) self.play(ShowCreation(self.curve, run_time = 2)) self.remove(*mini_curves) self.dither()
def construct(self): start_words = TextMobject([ "``", "Space Filling", "Curve ''", ]).to_edge(TOP, buff = 0.25) quote, space_filling, curve_quote = start_words.copy().split() curve_quote.shift( space_filling.get_left()-\ curve_quote.get_left() ) space_filling = Point(space_filling.get_center()) end_words = Mobject(*[ quote, space_filling, curve_quote ]).center().to_edge(TOP, buff = 0.25) space_filling_fractal = TextMobject(""" ``Space Filling Fractal'' """).to_edge(UP) curve = HilbertCurve(order = 2).shift(DOWN) fine_curve = HilbertCurve(order = 8) fine_curve.replace(curve) dots = Mobject(*[ Dot( curve.points[n*curve.get_num_points()/15], color = YELLOW_C ) for n in range(1, 15) if n not in [4, 11] ]) start_words.shift(2*(UP+LEFT)) self.play( ApplyMethod(start_words.shift, 2*(DOWN+RIGHT)) ) self.wait() self.play(Transform(start_words, end_words)) self.wait() self.play(ShowCreation(curve)) self.wait() self.play(ShowCreation( dots, run_time = 3, )) self.wait() self.clear() self.play(ShowCreation(fine_curve, run_time = 5)) self.wait() self.play(ShimmerIn(space_filling_fractal)) self.wait()
def construct(self): val = 0.7 text = TexMobject([ "\\text{HC}(", "x", ")", "=\\lim_{n \\to \\infty}\\text{PHC}_n(", "x", ")" ]) text.to_edge(UP) x1 = text.split()[1] x2 = text.split()[-2] x2.highlight(BLUE) explanation = TextMobject("Actual Hilbert curve function") exp_arrow = Arrow(explanation, text.split()[0]) curve = UnitInterval() dot = Dot(curve.number_to_point(val)) x_arrow = Arrow(x1.get_bottom(), dot, buff = 0) curve.sort_points(lambda p : p[0]) curve.add_numbers(0, 1) self.add(*text.split()[:3]) self.play( ShimmerIn(explanation), ShowCreation(exp_arrow) ) self.wait() self.remove(explanation, exp_arrow) self.play(ShowCreation(curve)) self.play( ApplyMethod(x1.highlight, BLUE), ShowCreation(x_arrow), ShowCreation(dot) ) self.wait() self.remove(x_arrow) limit = Mobject(*text.split()[3:]).ingest_submobjects() limit.stroke_width = 1 self.play(ShimmerIn(limit)) for num in range(1, 9): new_curve = HilbertCurve(order = num) new_curve.scale(0.8) new_dot = Dot(new_curve.points[int(val*new_curve.get_num_points())]) self.play( Transform(curve, new_curve), Transform(dot, new_dot), )
def construct(self): val = 0.7 text = TexMobject([ "\\text{HC}(", "x", ")", "=\\lim_{n \\to \\infty}\\text{PHC}_n(", "x", ")" ]) text.to_edge(UP) x1 = text.split()[1] x2 = text.split()[-2] x2.set_color(BLUE) explanation = TextMobject("Actual Hilbert curve function") exp_arrow = Arrow(explanation, text.split()[0]) curve = UnitInterval() dot = Dot(curve.number_to_point(val)) x_arrow = Arrow(x1.get_bottom(), dot, buff = 0) curve.sort_points(lambda p : p[0]) curve.add_numbers(0, 1) self.add(*text.split()[:3]) self.play( ShimmerIn(explanation), ShowCreation(exp_arrow) ) self.wait() self.remove(explanation, exp_arrow) self.play(ShowCreation(curve)) self.play( ApplyMethod(x1.set_color, BLUE), ShowCreation(x_arrow), ShowCreation(dot) ) self.wait() self.remove(x_arrow) limit = Mobject(*text.split()[3:]).ingest_submobjects() limit.stroke_width = 1 self.play(ShimmerIn(limit)) for num in range(1, 9): new_curve = HilbertCurve(order = num) new_curve.scale(0.8) new_dot = Dot(new_curve.points[int(val*new_curve.get_num_points())]) self.play( Transform(curve, new_curve), Transform(dot, new_dot), )
def construct(self): curve = HilbertCurve(order = 1) grid = Grid(2, 2, stroke_width=1) self.add(grid, curve) for order in range(2, 6): self.wait() new_grid = Grid(2**order, 2**order, stroke_width=1) self.play( ShowCreation(new_grid), Animation(curve) ) self.remove(grid) grid = new_grid self.play(Transform( curve, HilbertCurve(order = order) )) square = Square(side_length = 6, color = WHITE) square.corner = Mobject1D() square.corner.add_line(3*DOWN, ORIGIN) square.corner.add_line(ORIGIN, 3*RIGHT) square.digest_mobject_attrs() square.scale(2**(-5)) square.corner.set_color( Color(rgb = curve.rgbas[curve.get_num_points()/3]) ) square.shift( grid.get_corner(UP+LEFT)-\ square.get_corner(UP+LEFT) ) self.wait() self.play( FadeOut(grid), FadeOut(curve), FadeIn(square) ) self.play( ApplyMethod(square.replace, grid) ) self.wait()
def construct(self): time_line = get_time_line() time_line.shift(-time_line.number_to_point(1900)) hilbert_curve = HilbertCurve(order = 3) peano_curve = PeanoCurve(order = 2) for curve in hilbert_curve, peano_curve: curve.scale(0.5) hilbert_curve.to_corner(DOWN+RIGHT) peano_curve.to_corner(UP+LEFT) squares = Mobject(*[ Square(side_length=3, color=WHITE).replace(curve) for curve in hilbert_curve, peano_curve ]) self.add(time_line) self.wait() for year, curve, vect, text in [ (1890, peano_curve, UP, "Peano Curve"), (1891, hilbert_curve, DOWN, "Hilbert Curve"), ]: point = time_line.number_to_point(year) point[1] = 0.2 arrow = Arrow(point+2*vect, point, buff = 0.1) arrow.gradient_highlight(curve.start_color, curve.end_color) year_mob = TexMobject(str(year)) year_mob.next_to(arrow, vect) words = TextMobject(text) words.next_to(year_mob, vect) self.play( ShowCreation(arrow), ShimmerIn(year_mob), ShimmerIn(words) ) self.play(ShowCreation(curve)) self.wait() self.play(ShowCreation(squares)) self.wait() self.play(ApplyMethod( Mobject(*self.mobjects).shift, 20*(DOWN+RIGHT) ))
def construct(self): time_line = get_time_line() time_line.shift(-time_line.number_to_point(1900)) hilbert_curve = HilbertCurve(order = 3) peano_curve = PeanoCurve(order = 2) for curve in hilbert_curve, peano_curve: curve.scale(0.5) hilbert_curve.to_corner(DOWN+RIGHT) peano_curve.to_corner(UP+LEFT) squares = Mobject(*[ Square(side_length=3, color=WHITE).replace(curve) for curve in hilbert_curve, peano_curve ]) self.add(time_line) self.wait() for year, curve, vect, text in [ (1890, peano_curve, UP, "Peano Curve"), (1891, hilbert_curve, DOWN, "Hilbert Curve"), ]: point = time_line.number_to_point(year) point[1] = 0.2 arrow = Arrow(point+2*vect, point, buff = 0.1) arrow.set_color_by_gradient(curve.start_color, curve.end_color) year_mob = TexMobject(str(year)) year_mob.next_to(arrow, vect) words = TextMobject(text) words.next_to(year_mob, vect) self.play( ShowCreation(arrow), ShimmerIn(year_mob), ShimmerIn(words) ) self.play(ShowCreation(curve)) self.wait() self.play(ShowCreation(squares)) self.wait() self.play(ApplyMethod( Mobject(*self.mobjects).shift, 20*(DOWN+RIGHT) ))
def construct(self): text = TextMobject([ "PHC", "_n", "(", "x", ")$", " has a limit point ", "as $n \\to \\infty$", "\\\\ for all $x$" ]) parts = text.split() parts[-1].next_to(Mobject(*parts[:-1]), DOWN) parts[-1].set_color(BLUE) parts[3].set_color(BLUE) parts[1].set_color() parts[-2].set_color() text.to_edge(UP) curve = UnitInterval() curve.sort_points(lambda p : p[0]) vals = np.arange(0.1, 1, 0.1) dots = Mobject(*[ Dot(curve.number_to_point(val)) for val in vals ]) curve.add_numbers(0, 1) starter_dots = dots.copy().ingest_submobjects() starter_dots.shift(2*UP) self.add(curve, text) self.wait() self.play(DelayByOrder(ApplyMethod(starter_dots.shift, 2*DOWN))) self.wait() self.remove(starter_dots) self.add(dots) for num in range(1, 10): new_curve = HilbertCurve(order = num) new_curve.scale(0.8) new_dots = Mobject(*[ Dot(new_curve.points[int(val*new_curve.get_num_points())]) for val in vals ]) self.play( Transform(curve, new_curve), Transform(dots, new_dots), )
def construct(self): text = TextMobject([ "PHC", "_n", "(", "x", ")$", " has a limit point ", "as $n \\to \\infty$", "\\\\ for all $x$" ]) parts = text.split() parts[-1].next_to(Mobject(*parts[:-1]), DOWN) parts[-1].highlight(BLUE) parts[3].highlight(BLUE) parts[1].highlight() parts[-2].highlight() text.to_edge(UP) curve = UnitInterval() curve.sort_points(lambda p : p[0]) vals = np.arange(0.1, 1, 0.1) dots = Mobject(*[ Dot(curve.number_to_point(val)) for val in vals ]) curve.add_numbers(0, 1) starter_dots = dots.copy().ingest_submobjects() starter_dots.shift(2*UP) self.add(curve, text) self.wait() self.play(DelayByOrder(ApplyMethod(starter_dots.shift, 2*DOWN))) self.wait() self.remove(starter_dots) self.add(dots) for num in range(1, 10): new_curve = HilbertCurve(order = num) new_curve.scale(0.8) new_dots = Mobject(*[ Dot(new_curve.points[int(val*new_curve.get_num_points())]) for val in vals ]) self.play( Transform(curve, new_curve), Transform(dots, new_dots), )
def construct(self): start_words = TexText([ "``", "Space Filling", "Curve ''", ]).to_edge(TOP, buff = 0.25) quote, space_filling, curve_quote = start_words.copy().split() curve_quote.shift( space_filling.get_left()-\ curve_quote.get_left() ) space_filling = Point(space_filling.get_center()) end_words = Mobject(*[ quote, space_filling, curve_quote ]).center().to_edge(TOP, buff = 0.25) space_filling_fractal = TexText(""" ``Space Filling Fractal'' """).to_edge(UP) curve = HilbertCurve(order = 2).shift(DOWN) fine_curve = HilbertCurve(order = 8) fine_curve.replace(curve) dots = Mobject(*[ Dot( curve.get_points()[n*curve.get_num_points()/15], color = YELLOW_C ) for n in range(1, 15) if n not in [4, 11] ]) start_words.shift(2*(UP+LEFT)) self.play( ApplyMethod(start_words.shift, 2*(DOWN+RIGHT)) ) self.wait() self.play(Transform(start_words, end_words)) self.wait() self.play(ShowCreation(curve)) self.wait() self.play(ShowCreation( dots, run_time = 3, )) self.wait() self.clear() self.play(ShowCreation(fine_curve, run_time = 5)) self.wait() self.play(ShimmerIn(space_filling_fractal)) self.wait()
def construct(self): mathy, bubble = get_mathy_and_bubble() bubble.write("For a 256x256 pixel array...") words = TextMobject("Order 8 Pseudo-Hilbert Curve") words.set_color(GREEN) words.to_edge(UP, buff=0.3) curve = HilbertCurve(order=8) self.add(mathy, bubble) self.play(ShimmerIn(bubble.content)) self.wait() self.clear() self.add(words) self.play(ShowCreation(curve, run_time=7, rate_func=None)) self.wait()
def construct(self): self.curve = HilbertCurve(order = 1) self.add(self.curve) self.dither() while self.curve.order < 8: self.increase_order()
def construct(self): self.curve = HilbertCurve(order = 1) self.add(self.curve) self.wait() while self.curve.order < 8: self.increase_order()