mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Added edits to intro scene
This commit is contained in:
parent
1ba56c3bba
commit
99783d77a0
1 changed files with 76 additions and 57 deletions
|
@ -214,6 +214,36 @@ class ScaleLightSources(Transform):
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
class ThinkAboutPondScene(PiCreatureScene):
|
||||||
|
CONFIG = {
|
||||||
|
"default_pi_creature_class" : Randolph,
|
||||||
|
}
|
||||||
|
def construct(self):
|
||||||
|
randy = self.pi_creature
|
||||||
|
randy.to_corner(DOWN+LEFT)
|
||||||
|
bubble = ThoughtBubble(
|
||||||
|
width = 9,
|
||||||
|
height = 5,
|
||||||
|
)
|
||||||
|
circles = bubble[:3]
|
||||||
|
angle = -15*DEGREES
|
||||||
|
circles.rotate(angle, about_point = bubble.get_bubble_center())
|
||||||
|
circles.shift(LARGE_BUFF*LEFT)
|
||||||
|
for circle in circles:
|
||||||
|
circle.rotate(-angle)
|
||||||
|
bubble.pin_to(randy)
|
||||||
|
bubble.shift_onto_screen()
|
||||||
|
|
||||||
|
self.play(
|
||||||
|
randy.change, "thinking",
|
||||||
|
ShowCreation(bubble)
|
||||||
|
)
|
||||||
|
self.wait(2)
|
||||||
|
self.play(randy.change, "happy", bubble)
|
||||||
|
self.wait(2)
|
||||||
|
self.play(randy.change, "hooray", bubble)
|
||||||
|
self.wait(2)
|
||||||
|
|
||||||
class IntroScene(PiCreatureScene):
|
class IntroScene(PiCreatureScene):
|
||||||
|
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
|
@ -223,23 +253,17 @@ class IntroScene(PiCreatureScene):
|
||||||
}
|
}
|
||||||
|
|
||||||
def construct(self):
|
def construct(self):
|
||||||
|
|
||||||
randy = self.get_primary_pi_creature()
|
randy = self.get_primary_pi_creature()
|
||||||
randy.scale(0.7).to_corner(DOWN+RIGHT)
|
randy.scale(0.7).to_corner(DOWN+RIGHT)
|
||||||
|
|
||||||
self.build_up_euler_sum()
|
self.build_up_euler_sum()
|
||||||
self.build_up_sum_on_number_line()
|
|
||||||
self.show_pi_answer()
|
self.show_pi_answer()
|
||||||
self.other_pi_formulas()
|
self.other_pi_formulas()
|
||||||
self.refocus_on_euler_sum()
|
self.refocus_on_euler_sum()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def build_up_euler_sum(self):
|
def build_up_euler_sum(self):
|
||||||
|
euler_sum = self.euler_sum = TexMobject(
|
||||||
self.euler_sum = TexMobject(
|
|
||||||
"1", "+",
|
"1", "+",
|
||||||
"{1 \\over 4}", "+",
|
"{1 \\over 4}", "+",
|
||||||
"{1 \\over 9}", "+",
|
"{1 \\over 9}", "+",
|
||||||
|
@ -248,16 +272,15 @@ class IntroScene(PiCreatureScene):
|
||||||
"\\cdots", "=",
|
"\\cdots", "=",
|
||||||
arg_separator = " \\, "
|
arg_separator = " \\, "
|
||||||
)
|
)
|
||||||
|
equals_sign = euler_sum.get_part_by_tex("=")
|
||||||
|
|
||||||
self.euler_sum.to_edge(UP)
|
self.euler_sum.to_edge(UP)
|
||||||
self.euler_sum.shift(2*LEFT)
|
self.euler_sum.shift(2*LEFT)
|
||||||
|
|
||||||
terms = [1./n**2 for n in range(1,6)]
|
terms = [1./n**2 for n in range(1,100)]
|
||||||
partial_results_values = np.cumsum(terms)
|
partial_results_values = np.cumsum(terms)
|
||||||
|
|
||||||
self.play(
|
self.play(FadeIn(euler_sum[0]))
|
||||||
FadeIn(self.euler_sum[0], run_time = self.duration)
|
|
||||||
)
|
|
||||||
|
|
||||||
equals_sign = self.euler_sum.get_part_by_tex("=")
|
equals_sign = self.euler_sum.get_part_by_tex("=")
|
||||||
|
|
||||||
|
@ -265,49 +288,7 @@ class IntroScene(PiCreatureScene):
|
||||||
num_decimal_points = 2)
|
num_decimal_points = 2)
|
||||||
self.partial_sum_decimal.next_to(equals_sign, RIGHT)
|
self.partial_sum_decimal.next_to(equals_sign, RIGHT)
|
||||||
|
|
||||||
|
## Number line
|
||||||
|
|
||||||
for i in range(4):
|
|
||||||
|
|
||||||
FadeIn(self.partial_sum_decimal, run_time = self.duration)
|
|
||||||
|
|
||||||
if i == 0:
|
|
||||||
|
|
||||||
self.play(
|
|
||||||
FadeIn(self.euler_sum[1], run_time = self.duration),
|
|
||||||
FadeIn(self.euler_sum[2], run_time = self.duration),
|
|
||||||
FadeIn(equals_sign, run_time = self.duration),
|
|
||||||
FadeIn(self.partial_sum_decimal, run_time = self.duration)
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
|
||||||
self.play(
|
|
||||||
FadeIn(self.euler_sum[2*i+1], run_time = self.duration),
|
|
||||||
FadeIn(self.euler_sum[2*i+2], run_time = self.duration),
|
|
||||||
ChangeDecimalToValue(
|
|
||||||
self.partial_sum_decimal,
|
|
||||||
partial_results_values[i+1],
|
|
||||||
run_time = self.duration,
|
|
||||||
num_decimal_points = 6,
|
|
||||||
show_ellipsis = True,
|
|
||||||
position_update_func = lambda m: m.next_to(equals_sign, RIGHT)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
self.wait()
|
|
||||||
|
|
||||||
self.q_marks = TextMobject("???").highlight(LIGHT_COLOR)
|
|
||||||
self.q_marks.move_to(self.partial_sum_decimal)
|
|
||||||
|
|
||||||
self.play(
|
|
||||||
FadeIn(self.euler_sum[-3], run_time = self.duration), # +
|
|
||||||
FadeIn(self.euler_sum[-2], run_time = self.duration), # ...
|
|
||||||
ReplacementTransform(self.partial_sum_decimal, self.q_marks)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def build_up_sum_on_number_line(self):
|
|
||||||
|
|
||||||
self.number_line = NumberLine(
|
self.number_line = NumberLine(
|
||||||
x_min = 0,
|
x_min = 0,
|
||||||
|
@ -365,6 +346,47 @@ class IntroScene(PiCreatureScene):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
for i in range(4):
|
||||||
|
|
||||||
|
FadeIn(self.partial_sum_decimal, run_time = self.duration)
|
||||||
|
|
||||||
|
if i == 0:
|
||||||
|
|
||||||
|
self.play(
|
||||||
|
FadeIn(self.euler_sum[1], run_time = self.duration),
|
||||||
|
FadeIn(self.euler_sum[2], run_time = self.duration),
|
||||||
|
FadeIn(equals_sign, run_time = self.duration),
|
||||||
|
FadeIn(self.partial_sum_decimal, run_time = self.duration)
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.play(
|
||||||
|
FadeIn(self.euler_sum[2*i+1], run_time = self.duration),
|
||||||
|
FadeIn(self.euler_sum[2*i+2], run_time = self.duration),
|
||||||
|
ChangeDecimalToValue(
|
||||||
|
self.partial_sum_decimal,
|
||||||
|
partial_results_values[i+1],
|
||||||
|
run_time = self.duration,
|
||||||
|
num_decimal_points = 6,
|
||||||
|
show_ellipsis = True,
|
||||||
|
position_update_func = lambda m: m.next_to(equals_sign, RIGHT)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.wait()
|
||||||
|
|
||||||
|
self.q_marks = TextMobject("???").highlight(LIGHT_COLOR)
|
||||||
|
self.q_marks.move_to(self.partial_sum_decimal)
|
||||||
|
|
||||||
|
self.play(
|
||||||
|
FadeIn(self.euler_sum[-3], run_time = self.duration), # +
|
||||||
|
FadeIn(self.euler_sum[-2], run_time = self.duration), # ...
|
||||||
|
ReplacementTransform(self.partial_sum_decimal, self.q_marks)
|
||||||
|
)
|
||||||
|
|
||||||
def show_pi_answer(self):
|
def show_pi_answer(self):
|
||||||
|
|
||||||
self.pi_answer = TexMobject("{\\pi^2 \\over 6}").highlight(YELLOW)
|
self.pi_answer = TexMobject("{\\pi^2 \\over 6}").highlight(YELLOW)
|
||||||
|
@ -373,7 +395,6 @@ class IntroScene(PiCreatureScene):
|
||||||
submobject_to_align = self.pi_answer[-2])
|
submobject_to_align = self.pi_answer[-2])
|
||||||
self.play(ReplacementTransform(self.q_marks, self.pi_answer))
|
self.play(ReplacementTransform(self.q_marks, self.pi_answer))
|
||||||
|
|
||||||
|
|
||||||
def other_pi_formulas(self):
|
def other_pi_formulas(self):
|
||||||
|
|
||||||
self.play(
|
self.play(
|
||||||
|
@ -409,8 +430,6 @@ class IntroScene(PiCreatureScene):
|
||||||
Write(self.wallis_product)
|
Write(self.wallis_product)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def refocus_on_euler_sum(self):
|
def refocus_on_euler_sum(self):
|
||||||
|
|
||||||
self.euler_sum.add(self.pi_answer)
|
self.euler_sum.add(self.pi_answer)
|
||||||
|
|
Loading…
Add table
Reference in a new issue