Finished eoc8

This commit is contained in:
Grant Sanderson 2017-04-14 23:30:29 -07:00
parent 5300bf24d2
commit c3b8b36e4e
3 changed files with 113 additions and 63 deletions

View file

@ -568,7 +568,8 @@ class ConstantVelocityCar(Scene):
class ConstantVelocityPlot(PlotVelocity): class ConstantVelocityPlot(PlotVelocity):
CONFIG = { CONFIG = {
"x_axis_label" : "Time" "x_axis_label" : "Time",
"units_of_area_color" : BLUE_E,
} }
def construct(self): def construct(self):
self.setup_axes() self.setup_axes()
@ -684,7 +685,7 @@ class ConstantVelocityPlot(PlotVelocity):
square = Square( square = Square(
stroke_color = BLACK, stroke_color = BLACK,
stroke_width = 1, stroke_width = 1,
fill_color = PINK, fill_color = self.units_of_area_color,
fill_opacity = 1, fill_opacity = 1,
) )
square.replace( square.replace(
@ -712,6 +713,7 @@ class ConstantVelocityPlot(PlotVelocity):
) )
self.play(Indicate(self.y_axis_label_mob)) self.play(Indicate(self.y_axis_label_mob))
self.play(FadeOut(y_line)) self.play(FadeOut(y_line))
for FadeClass in FadeIn, FadeOut: for FadeClass in FadeIn, FadeOut:
self.play( self.play(
FadeClass( FadeClass(
@ -756,6 +758,8 @@ class PiecewiseConstantPlot(PlotVelocity):
"tick_size" : 0.2, "tick_size" : 0.2,
} }
def construct(self): def construct(self):
self.force_skipping()
self.setup_graph() self.setup_graph()
self.always_changing() self.always_changing()
self.show_piecewise_constant_graph() self.show_piecewise_constant_graph()
@ -1089,7 +1093,9 @@ class PiecewiseConstantPlot(PlotVelocity):
def show_v_dt_for_all_rectangles(self): def show_v_dt_for_all_rectangles(self):
dt_brace_group = VGroup(self.dt_brace, self.dt_label) dt_brace_group = VGroup(self.dt_brace, self.dt_label)
rects_subset = self.rects[10:15] rects_subset = self.rects[10:20]
self.revert_to_original_skipping_status()
last_rect = None last_rect = None
for rect in rects_subset: for rect in rects_subset:
@ -1385,9 +1391,18 @@ class PiecewiseConstantPlot(PlotVelocity):
ticks.highlight(YELLOW) ticks.highlight(YELLOW)
return ticks return ticks
class DontKnowHowToHandleNonConstant(TeacherStudentsScene):
def construct(self):
self.play(*[
ApplyMethod(pi.change, "maybe", UP)
for pi in self.get_pi_creatures()
])
self.dither(3)
class CarJourneyApproximation(Scene): class CarJourneyApproximation(Scene):
CONFIG = { CONFIG = {
"n_jumps" : 5, "n_jumps" : 5,
"bottom_words" : "Approximated motion (5 jumps)",
} }
def construct(self): def construct(self):
points = [5*LEFT + v for v in UP, 2*DOWN] points = [5*LEFT + v for v in UP, 2*DOWN]
@ -1395,8 +1410,9 @@ class CarJourneyApproximation(Scene):
h_line = Line(LEFT, RIGHT).scale(SPACE_WIDTH) h_line = Line(LEFT, RIGHT).scale(SPACE_WIDTH)
words = [ words = [
TextMobject("Real motion (smooth)").shift(3*UP), TextMobject("Real motion (smooth)").shift(3*UP),
TextMobject("Approximated motion (jerky)").shift(0.5*DOWN), TextMobject(self.bottom_words).shift(0.5*DOWN),
] ]
words[1].highlight(GREEN)
self.add(h_line, *cars + words) self.add(h_line, *cars + words)
@ -1427,6 +1443,7 @@ class CarJourneyApproximation(Scene):
class LessWrongCarJourneyApproximation(CarJourneyApproximation): class LessWrongCarJourneyApproximation(CarJourneyApproximation):
CONFIG = { CONFIG = {
"n_jumps" : 20, "n_jumps" : 20,
"bottom_words" : "Better approximation (20 jumps)",
} }
class TellMeThatsNotSurprising(TeacherStudentsScene): class TellMeThatsNotSurprising(TeacherStudentsScene):
@ -2715,9 +2732,64 @@ class NextVideo(TeacherStudentsScene):
self.play(Write(integral)) self.play(Write(integral))
self.dither(5) self.dither(5)
class Chapter8PatreonThanks(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",
"Dan Buchoff",
"Derek Dai",
"Joseph John Cox",
"Luc Ritchie",
"Robert Teed",
"Jason Hise",
"Meshal Alshammari",
"Bernd Sing",
"Nils Schneider",
"James Thornton",
"Mustafa Mahdi",
"Jonathan Eppele",
"Mathew Bramson",
"Jerry Ling",
"Mark Govea",
"Vecht",
"Shimin Kuang",
"Rish Kundalia",
"Achille Brighton",
"Ripta Pasay",
]
}
class Thumbnail(FundamentalTheorem):
CONFIG = {
"x_axis_label" : "",
"y_axis_label" : "",
"graph_origin" : 1.5*DOWN + 4*LEFT,
"y_axis_height" : 5,
}
def construct(self):
self.setup_axes()
graph = self.get_graph(
lambda x : -0.01*x*(x-3)*(x-6)*(x-12) + 3,
color = YELLOW
)
rects = self.get_riemann_rectangles(
graph,
x_min = 1, x_max = 8,
dx = 0.5,
)
self.add(rects, graph)

View file

@ -125,7 +125,7 @@ class PiCreature(SVGMobject):
def change(self, new_mode, look_at_arg = None): def change(self, new_mode, look_at_arg = None):
self.change_mode(new_mode) self.change_mode(new_mode)
if look_at_arg: if look_at_arg is not None:
self.look_at(look_at_arg) self.look_at(look_at_arg)
return self return self
@ -184,7 +184,6 @@ class PiCreature(SVGMobject):
self.look(top_mouth_point - bottom_mouth_point) self.look(top_mouth_point - bottom_mouth_point)
return self return self
def get_all_pi_creature_modes(): def get_all_pi_creature_modes():
result = [] result = []
prefix = "PiCreatures_" prefix = "PiCreatures_"
@ -196,7 +195,6 @@ def get_all_pi_creature_modes():
) )
return result return result
class Randolph(PiCreature): class Randolph(PiCreature):
pass #Nothing more than an alternative name pass #Nothing more than an alternative name
@ -206,7 +204,6 @@ class Mortimer(PiCreature):
"flip_at_start" : True, "flip_at_start" : True,
} }
class Mathematician(PiCreature): class Mathematician(PiCreature):
CONFIG = { CONFIG = {
"color" : GREY, "color" : GREY,
@ -232,7 +229,6 @@ class BabyPiCreature(PiCreature):
pupil.scale_in_place(self.pupil_scale_factor) pupil.scale_in_place(self.pupil_scale_factor)
self.look(looking_direction) self.look(looking_direction)
class Blink(ApplyMethod): class Blink(ApplyMethod):
CONFIG = { CONFIG = {
"rate_func" : squish_rate_func(there_and_back) "rate_func" : squish_rate_func(there_and_back)
@ -360,7 +356,7 @@ class RemovePiCreatureBubble(AnimationGroup):
if surrounding_scene is not None: if surrounding_scene is not None:
surrounding_scene.add(self.pi_creature) surrounding_scene.add(self.pi_creature)
###########
class PiCreatureScene(Scene): class PiCreatureScene(Scene):
CONFIG = { CONFIG = {
@ -566,7 +562,6 @@ class PiCreatureScene(Scene):
for pi in pi_creatures for pi in pi_creatures
])) ]))
class TeacherStudentsScene(PiCreatureScene): class TeacherStudentsScene(PiCreatureScene):
CONFIG = { CONFIG = {
"student_colors" : [BLUE_D, BLUE_C, BLUE_E], "student_colors" : [BLUE_D, BLUE_C, BLUE_E],

View file

@ -3,7 +3,7 @@ from helpers import *
from scene.scene import Scene from scene.scene import Scene
from animation.simple_animations import Write, DrawBorderThenFill from animation.simple_animations import Write, DrawBorderThenFill
from animation.transform import FadeIn, ApplyMethod from animation.transform import FadeIn, FadeOut, ApplyMethod
from mobject.vectorized_mobject import VGroup from mobject.vectorized_mobject import VGroup
from mobject.tex_mobject import TexMobject, TextMobject from mobject.tex_mobject import TexMobject, TextMobject
from topics.characters import Mortimer, Blink from topics.characters import Mortimer, Blink
@ -90,8 +90,9 @@ class PatreonThanks(Scene):
"Ripta Pasay", "Ripta Pasay",
"Felipe Diniz", "Felipe Diniz",
], ],
"max_patrons_height" : 2*SPACE_HEIGHT - 1, "patron_group_size" : 8,
"patron_scale_val" : 0.7, "patron_scale_val" : 0.7,
} }
def construct(self): def construct(self):
morty = Mortimer() morty = Mortimer()
@ -105,59 +106,41 @@ class PatreonThanks(Scene):
patreon_logo = PatreonLogo() patreon_logo = PatreonLogo()
patreon_logo.next_to(morty, UP, buff = MED_LARGE_BUFF) patreon_logo.next_to(morty, UP, buff = MED_LARGE_BUFF)
left_patrons = VGroup(*map(TextMobject, patrons = map(TextMobject, self.specific_patrons)
self.specific_patrons[:n_patrons/2] patron_groups = []
)) index = 0
right_patrons = VGroup(*map(TextMobject, counter = 0
self.specific_patrons[n_patrons/2:] while index < len(patrons):
)) next_index = index + self.patron_group_size
for patrons in left_patrons, right_patrons: group = VGroup(*patrons[index:next_index])
patrons.arrange_submobjects( group.arrange_submobjects(DOWN, aligned_edge = LEFT)
DOWN, aligned_edge = LEFT, if counter%2 == 0:
buff = 1.5*MED_SMALL_BUFF group.to_edge(LEFT)
) else:
group.to_edge(RIGHT)
all_patrons = VGroup(left_patrons, right_patrons) patron_groups.append(group)
all_patrons.scale(self.patron_scale_val) index = next_index
for patrons, vect in (left_patrons, LEFT), (right_patrons, RIGHT): counter += 1
patrons.to_edge(vect, buff = MED_SMALL_BUFF)
if patrons.get_height() > 2*SPACE_HEIGHT - LARGE_BUFF:
patrons.to_edge(UP, buff = MED_SMALL_BUFF)
shift_distance = max(
0, (all_patrons.get_height() - 2*SPACE_HEIGHT)
)
if shift_distance > 0:
shift_distance += 1
velocity = shift_distance/9.0
def get_shift_anim():
return ApplyMethod(
all_patrons.shift, velocity*UP,
rate_func = None
)
self.play( self.play(
morty.change_mode, "gracious", morty.change_mode, "gracious",
DrawBorderThenFill(patreon_logo), DrawBorderThenFill(patreon_logo),
) )
self.play(Write(special_thanks, run_time = 1)) self.play(Write(special_thanks, run_time = 1))
self.play( for i, group in enumerate(patron_groups):
Write(left_patrons), anims = [
morty.look_at, left_patrons FadeIn(
) group, run_time = 2,
self.play( submobject_mode = "lagged_start",
Write(right_patrons), lag_factor = 4,
morty.look_at, right_patrons ),
) morty.look_at, group.get_top(),
self.play(Blink(morty), get_shift_anim()) ]
for patrons in left_patrons, right_patrons: if i >= 2:
for index in 0, -1: anims.append(FadeOut(patron_groups[i-2]))
self.play( self.play(*anims)
morty.look_at, patrons[index], self.play(morty.look_at, group.get_bottom())
get_shift_anim() self.play(Blink(morty))
)
self.play(get_shift_anim())