Some simple eoc cleanup

This commit is contained in:
Grant Sanderson 2017-04-29 18:23:00 -07:00
parent 6f729fe063
commit ad25f65327
5 changed files with 217 additions and 14 deletions

View file

@ -2754,6 +2754,7 @@ class EndScreen(PiCreatureScene):
} }
def construct(self): def construct(self):
words = TextMobject("Clicky stuffs") words = TextMobject("Clicky stuffs")
words.scale(1.5)
words.next_to(self.pi_creature, UP) words.next_to(self.pi_creature, UP)
words.to_edge(UP) words.to_edge(UP)

View file

@ -197,6 +197,11 @@ class Pendulum(ReconfigurableScene):
"radius" : 4, "radius" : 4,
"weight_radius" : 0.2, "weight_radius" : 0.2,
"angle" : np.pi/6, "angle" : np.pi/6,
"approx_tex" : [
"\\approx 1 - ", "{\\theta", "^2", "\\over", "2}"
],
"leave_original_cosine" : False,
"perform_substitution" : True,
} }
def construct(self): def construct(self):
self.draw_pendulum() self.draw_pendulum()
@ -206,7 +211,6 @@ class Pendulum(ReconfigurableScene):
self.substitute_approximation() self.substitute_approximation()
self.show_confusion() self.show_confusion()
def draw_pendulum(self): def draw_pendulum(self):
pendulum = self.get_pendulum() pendulum = self.get_pendulum()
ceiling = self.get_ceiling() ceiling = self.get_ceiling()
@ -295,6 +299,10 @@ class Pendulum(ReconfigurableScene):
cosine.generate_target() cosine.generate_target()
cosine.save_state() cosine.save_state()
cosine.target.next_to(morty, UP) cosine.target.next_to(morty, UP)
if self.leave_original_cosine:
cosine_copy = cosine.copy()
self.add(cosine_copy)
self.one_minus.add(cosine_copy)
self.play(FadeIn(morty)) self.play(FadeIn(morty))
self.play( self.play(
@ -330,6 +338,8 @@ class Pendulum(ReconfigurableScene):
morty.change, "pondering", cosine_approx morty.change, "pondering", cosine_approx
) )
self.dither() self.dither()
if not self.perform_substitution:
return
self.play( self.play(
ApplyMethod( ApplyMethod(
cosine_approx.theta_squared_over_two.copy().next_to, cosine_approx.theta_squared_over_two.copy().next_to,
@ -466,11 +476,9 @@ class Pendulum(ReconfigurableScene):
return arc, theta return arc, theta
def get_cosine_approx(self): def get_cosine_approx(self):
approx = TexMobject( approx = TexMobject(*self.approx_tex)
"\\approx 1 - ", "{\\theta", "^2", "\\over", "2}"
)
approx.highlight_by_tex("theta", YELLOW) approx.highlight_by_tex("theta", YELLOW)
approx.theta_squared_over_two = VGroup(*approx[-4:]) approx.theta_squared_over_two = VGroup(*approx[1:5])
return approx return approx
@ -484,6 +492,18 @@ class Pendulum(ReconfigurableScene):
def swing_rate_func(self, t): def swing_rate_func(self, t):
return (1-np.cos(np.pi*t))/2.0 return (1-np.cos(np.pi*t))/2.0
class PendulumWithBetterApprox(Pendulum):
CONFIG = {
"approx_tex" : [
"\\approx 1 - ", "{\\theta", "^2", "\\over", "2}",
"+", "{\\theta", "^4", "\\over", "24}"
],
"leave_original_cosine" : True,
"perform_substitution" : False,
}
def show_confusion(self):
pass
class ExampleApproximationWithCos(ExampleApproximationWithSine): class ExampleApproximationWithCos(ExampleApproximationWithSine):
CONFIG = { CONFIG = {
"function" : np.cos, "function" : np.cos,
@ -1852,9 +1872,56 @@ class HigherTermsDontMessUpLowerTerms(Scene):
self.play(Write(equals_zero)) self.play(Write(equals_zero))
self.dither(3) self.dither(3)
class EachTermControlsOneDerivative(Scene):
def construct(self):
colors = CubicAndQuarticApproximations.CONFIG["colors"]
polynomial = TexMobject(
"P(x) = ", "c_0", "+", "c_1", "x", *it.chain(*[
["+", "c_%d"%n, "x^%d"%n]
for n in range(2, 5)
])
)
consts = polynomial.get_parts_by_tex("c")
deriv_words = VGroup(*[
TextMobject("Controls \\\\ $%s(0)$"%tex)
for tex in [
"P",
"\\frac{dP}{dx}",
] + [
"\\frac{d^%d P}{dx^%d}"%(n, n)
for n in range(2, 5)
]
])
deriv_words.arrange_submobjects(
RIGHT,
buff = LARGE_BUFF,
aligned_edge = UP
)
deriv_words.scale_to_fit_width(2*SPACE_WIDTH - MED_LARGE_BUFF)
deriv_words.to_edge(UP)
for const, deriv, color in zip(consts, deriv_words, colors):
for mob in const, deriv:
mob.highlight(color)
arrow = Arrow(
const.get_top(),
deriv.get_bottom(),
# buff = SMALL_BUFF,
color = color
)
deriv.arrow = arrow
self.add(polynomial)
for deriv in deriv_words:
self.play(
ShowCreation(deriv.arrow),
FadeIn(deriv)
)
self.dither()
class ApproximateNearNewPoint(CubicAndQuarticApproximations): class ApproximateNearNewPoint(CubicAndQuarticApproximations):
CONFIG = { CONFIG = {
"target_approx_centers" : [-np.pi/2, np.pi/2, np.pi], "target_approx_centers" : [np.pi/2, np.pi],
} }
def construct(self): def construct(self):
self.setup_axes() self.setup_axes()
@ -1962,6 +2029,14 @@ class ApproximateNearNewPoint(CubicAndQuarticApproximations):
]) ])
return self.get_graph(func, color = GREEN) return self.get_graph(func, color = GREEN)
class OnAPhilosophicalLevel(TeacherStudentsScene):
def construct(self):
self.teacher_says(
"And on a \\\\ philosophical level",
run_time = 1
)
self.dither(3)
class TranslationOfInformation(CubicAndQuarticApproximations): class TranslationOfInformation(CubicAndQuarticApproximations):
def construct(self): def construct(self):
self.add_background() self.add_background()
@ -1989,7 +2064,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations):
deriv_info.next_to(ORIGIN, LEFT, LARGE_BUFF) deriv_info.next_to(ORIGIN, LEFT, LARGE_BUFF)
deriv_info.to_edge(UP) deriv_info.to_edge(UP)
output_info = TextMobject( output_info = TextMobject(
"Output \\\\ information \\\\ near that piont" "Output \\\\ information \\\\ near that point"
) )
output_info.next_to(ORIGIN, RIGHT, LARGE_BUFF) output_info.next_to(ORIGIN, RIGHT, LARGE_BUFF)
output_info.to_edge(UP) output_info.to_edge(UP)
@ -2419,6 +2494,18 @@ class TranslationOfInformation(CubicAndQuarticApproximations):
return result return result
class ThisIsAStandardFormula(TeacherStudentsScene):
def construct(self):
self.teacher_says(
"You will see this \\\\ in your texts",
run_time = 1
)
self.change_student_modes(
*["sad"]*3,
look_at_arg = SPACE_HEIGHT*UP
)
self.dither(2)
class ExpPolynomial(TranslationOfInformation, ExampleApproximationWithExp): class ExpPolynomial(TranslationOfInformation, ExampleApproximationWithExp):
CONFIG = { CONFIG = {
"x_tick_frequency" : 1, "x_tick_frequency" : 1,
@ -2569,12 +2656,23 @@ class ShowSecondTerm(TeacherStudentsScene):
words = TextMobject("Geometric view") words = TextMobject("Geometric view")
words.next_to(box, UP) words.next_to(box, UP)
self.play(Write(polynomial)) self.teacher_says(
"Now for \\\\ something fun!",
target_mode = "hooray"
)
self.dither(2)
self.play(
RemovePiCreatureBubble(
self.teacher,
target_mode = "raise_right_hand"
),
Write(polynomial)
)
self.play( self.play(
ShowCreation(box), ShowCreation(box),
FadeIn(words), FadeIn(words),
self.teacher.change_mode, "raise_right_hand"
) )
self.change_student_modes(*["pondering"]*3)
self.dither(3) self.dither(3)
class SecondTermIntuition(AreaIsDerivative): class SecondTermIntuition(AreaIsDerivative):
@ -2899,6 +2997,20 @@ class SecondTermIntuition(AreaIsDerivative):
self.play(FadeIn(VGroup(*analytic_taylor[5:]))) self.play(FadeIn(VGroup(*analytic_taylor[5:])))
self.dither(3) self.dither(3)
class EachTermHasMeaning(TeacherStudentsScene):
def construct(self):
self.get_pi_creatures().scale_in_place(0.8).shift(UP)
self.teacher_says(
"Each term \\\\ has meaning!",
target_mode = "hooray",
bubble_kwargs = {"height" : 3, "width" : 4}
)
self.change_student_modes(
*["thinking"]*3,
look_at_arg = 4*UP
)
self.dither(3)
class AskAboutInfiniteSum(TeacherStudentsScene): class AskAboutInfiniteSum(TeacherStudentsScene):
def construct(self): def construct(self):
self.ask_question() self.ask_question()
@ -3513,9 +3625,70 @@ class MoreToBeSaid(TeacherStudentsScene):
self.play(ShowCreation(rect)) self.play(ShowCreation(rect))
self.dither(4) self.dither(4)
class Chapter10Thanks(PatreonThanks):
CONFIG = {
"specific_patrons" : [
"Ali Yahya",
"CrypticSwarm",
"Kaustuv DeBiswas",
"Kathryn Schmiedicke",
"Karan Bhargava",
"Ankit Agarwal",
"Yu Jun",
"Dave Nicponski",
"Damion Kistler",
"Juan Benet",
"Othman Alikhan",
"Markus Persson",
"Joseph John Cox",
"Dan Buchoff",
"Derek Dai",
"Luc Ritchie",
"Ahmad Bamieh",
"Mark Govea",
"Zac Wentzell",
"Robert Teed",
"Jason Hise",
"Meshal Alshammari",
"Bernd Sing",
"Nils Schneider",
"James Thornton",
"Mustafa Mahdi",
"Jonathan Eppele",
"Mathew Bramson",
"Jerry Ling",
"Vecht",
"Shimin Kuang",
"Rish Kundalia",
"Achille Brighton",
"Ripta Pasay",
],
}
class Thumbnail(ExampleApproximationWithSine):
CONFIG = {
"graph_origin" : DOWN,
"x_axis_label" : "",
"y_axis_label" : "",
"x_axis_width" : 14,
"graph_stroke_width" : 8,
}
def construct(self):
self.setup_axes()
cos_graph = self.get_graph(np.cos)
cos_graph.set_stroke(BLUE, self.graph_stroke_width)
quad_graph = self.get_graph(taylor_approximation(np.cos, 2))
quad_graph.set_stroke(GREEN, self.graph_stroke_width)
quartic = self.get_graph(taylor_approximation(np.cos, 4))
quartic.set_stroke(PINK, self.graph_stroke_width)
self.add(cos_graph, quad_graph, quartic)
title = TextMobject("Taylor Series")
title.scale_to_fit_width(1.5*SPACE_WIDTH)
title.add_background_rectangle()
title.to_edge(UP)
self.add(title)

View file

@ -2533,7 +2533,7 @@ class NextVideos(TeacherStudentsScene):
self.dither(2) self.dither(2)
self.change_student_modes(*["thinking"]*3) self.change_student_modes(*["thinking"]*3)
self.dither(3) self.dither(3)
class Chapter2PatreonThanks(PatreonThanks): class Chapter2PatreonThanks(PatreonThanks):
CONFIG = { CONFIG = {
"specific_patrons" : [ "specific_patrons" : [

View file

@ -2788,6 +2788,34 @@ class Chapter3PatreonThanks(PatreonThanks):
] ]
} }
class Promotion(PiCreatureScene):
CONFIG = {
"seconds_to_blink" : 5,
}
def construct(self):
url = TextMobject("https://brilliant.org/3b1b/")
url.to_corner(UP+LEFT)
rect = Rectangle(height = 9, width = 16)
rect.scale_to_fit_height(5.5)
rect.next_to(url, DOWN)
rect.to_edge(LEFT)
self.play(
Write(url),
self.pi_creature.change, "raise_right_hand"
)
self.play(ShowCreation(rect))
self.dither(2)
self.change_mode("thinking")
self.dither()
self.look_at(url)
self.dither(10)
self.change_mode("happy")
self.dither(10)
self.change_mode("raise_right_hand")
self.dither(10)
class Thumbnail(NudgeSideLengthOfCube): class Thumbnail(NudgeSideLengthOfCube):
def construct(self): def construct(self):
self.introduce_cube() self.introduce_cube()

View file

@ -2270,7 +2270,8 @@ class Chapter4Thanks(PatreonThanks):
"Kirk Werklund", "Kirk Werklund",
"Ripta Pasay", "Ripta Pasay",
"Felipe Diniz", "Felipe Diniz",
] ],
"patron_group_size" : 8,
} }
class Thumbnail(IntroduceProductAsArea): class Thumbnail(IntroduceProductAsArea):