Simple ManyFormulas scene

This commit is contained in:
Grant Sanderson 2018-03-12 17:28:52 -07:00
parent 6405647225
commit debb6ea07b

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
from helpers import * from helpers import *
from mobject.tex_mobject import TexMobject from mobject.tex_mobject import TexMobject
@ -31,29 +33,32 @@ from mobject.svg_mobject import *
from mobject.tex_mobject import * from mobject.tex_mobject import *
from topics.graph_scene import * from topics.graph_scene import *
RESOURCE_DIR = os.path.join(MEDIA_DIR, "3b1b_videos", "π Day 2018")
class PiTauDebate(PiCreatureScene): class PiTauDebate(PiCreatureScene):
def construct(self): def construct(self):
pi, tau = self.pi, self.tau pi, tau = self.pi, self.tau
self.add(pi, tau) self.add(pi, tau)
pi_value = TextMobject("3.1415...!")
pi_value.highlight(BLUE)
tau_value = TextMobject("6.2831...!")
tau_value.highlight(GREEN)
self.play(PiCreatureSays( self.play(PiCreatureSays(
pi, "3.1415...!", pi, pi_value,
target_mode = "angry", target_mode = "angry",
look_at_arg = tau.eyes, look_at_arg = tau.eyes,
# bubble_kwargs = {"width" : 3} # bubble_kwargs = {"width" : 3}
)) ))
self.play(PiCreatureSays( self.play(PiCreatureSays(
tau, "6.2831...!", tau, tau_value,
target_mode = "angry", target_mode = "angry",
look_at_arg = pi.eyes, look_at_arg = pi.eyes,
bubble_kwargs = {"width" : 3, "height" : 2}, bubble_kwargs = {"width" : 3, "height" : 2},
)) ))
self.wait(2) self.wait()
self.play(
RemovePiCreatureBubble(pi),
RemovePiCreatureBubble(tau),
)
# Show tau # Show tau
circle = Circle(color = YELLOW, radius = 1.25) circle = Circle(color = YELLOW, radius = 1.25)
@ -82,7 +87,11 @@ class PiTauDebate(PiCreatureScene):
**kwargs **kwargs
) )
self.play(ShowCreation(radius), Write(one)) self.play(
ShowCreation(radius), Write(one),
RemovePiCreatureBubble(pi),
RemovePiCreatureBubble(tau),
)
self.play( self.play(
tau.change, "hooray", tau.change, "hooray",
pi.change, "sassy", pi.change, "sassy",
@ -138,9 +147,89 @@ class PiTauDebate(PiCreatureScene):
tau.to_edge(DOWN).shift(4*RIGHT) tau.to_edge(DOWN).shift(4*RIGHT)
return VGroup(pi, tau) return VGroup(pi, tau)
class HartlAndPalais(Scene):
def construct(self):
hartl_rect = ScreenRectangle(
color = WHITE,
stroke_width = 1,
)
hartl_rect.scale_to_fit_width(SPACE_WIDTH - 1)
hartl_rect.to_edge(LEFT)
palais_rect = hartl_rect.copy()
palais_rect.to_edge(RIGHT)
tau_words = TextMobject("$\\tau$ ``tau''")
tau_words.next_to(hartl_rect, UP)
hartl_words = TextMobject("Michael Hartl's \\\\ ``Tau manifesto''")
hartl_words.next_to(hartl_rect, DOWN)
palais_words = TextMobject("Robert Palais' \\\\ ``Pi is Wrong!''")
palais_words.next_to(palais_rect, DOWN)
for words in hartl_words, palais_words:
words.scale(0.7, about_edge = UP)
three_legged_creature = ThreeLeggedPiCreature(height = 1.5)
three_legged_creature.next_to(palais_rect, UP)
# self.add(hartl_rect, palais_rect)
self.add(hartl_words)
self.play(Write(tau_words))
self.wait()
self.play(FadeIn(palais_words))
self.play(FadeIn(three_legged_creature))
self.play(three_legged_creature.change_mode, "wave")
self.play(Blink(three_legged_creature))
self.wait()
class ManyFormulas(Scene):
def construct(self):
formulas = VGroup(
TexMobject("\\sin(x + \\tau) = \\sin(x)"),
TexMobject("e^{\\tau i} = 1"),
TexMobject("n! \\approx \\sqrt{\\tau n} \\left(\\frac{n}{e} \\right)^n"),
TexMobject("c_n = \\frac{1}{\\tau} \\int_0^\\tau f(x) e^{inx}dx"),
)
formulas.arrange_submobjects(DOWN, buff = MED_LARGE_BUFF)
formulas.to_edge(LEFT)
self.play(LaggedStart(FadeIn, formulas, run_time = 3))
circle = Circle(color = YELLOW, radius = 2)
circle.to_edge(RIGHT)
radius = Line(circle.get_center(), circle.get_right())
radius.highlight(WHITE)
angle_groups = VGroup()
for denom in 8, 4, 3:
radius_copy = radius.copy()
radius_copy.rotate(TAU/denom, about_point = circle.get_center())
arc = circle.copy()
arc.set_stroke(RED, width = 4)
arc.pointwise_become_partial(circle, 0, 1./denom)
mini_arc = arc.copy()
mini_arc.set_stroke(WHITE, 2)
mini_arc.scale(0.2, about_point = circle.get_center())
tau_tex = TexMobject("\\tau/%d"%denom)
tau_tex.next_to(
mini_arc,
mini_arc.point_from_proportion(0.5) - circle.get_center()
)
angle_group = VGroup(radius_copy, mini_arc, tau_tex, arc)
angle_groups.add(angle_group)
angle_group = angle_groups[0]
self.play(*map(FadeIn, [circle, radius]))
self.play(
FadeIn(angle_group),
circle.fade, 0.25,
)
self.wait()
for group in angle_groups[1:]:
self.play(Transform(angle_group, group, path_arc = TAU/8))
self.wait()