mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
142 lines
4.2 KiB
Python
142 lines
4.2 KiB
Python
![]() |
from big_ol_pile_of_manim_imports import *
|
||
|
from active_projects.ode.part1.shared_constructs import *
|
||
|
|
||
|
|
||
|
class SmallAngleApproximationTex(Scene):
|
||
|
def construct(self):
|
||
|
approx = TexMobject(
|
||
|
"\\sin", "(", "\\theta", ") \\approx \\theta",
|
||
|
tex_to_color_map={"\\theta": RED},
|
||
|
arg_separator="",
|
||
|
)
|
||
|
|
||
|
implies = TexMobject("\\Downarrow")
|
||
|
period = TexMobject(
|
||
|
"\\text{Period}", "\\approx",
|
||
|
"2\\pi \\sqrt{\\,{L} / {g}}",
|
||
|
**Lg_formula_config,
|
||
|
)
|
||
|
group = VGroup(approx, implies, period)
|
||
|
group.arrange(DOWN)
|
||
|
|
||
|
approx_brace = Brace(approx, UP, buff=SMALL_BUFF)
|
||
|
approx_words = TextMobject(
|
||
|
"For small $\\theta$",
|
||
|
tex_to_color_map={"$\\theta$": RED},
|
||
|
)
|
||
|
approx_words.scale(0.75)
|
||
|
approx_words.next_to(approx_brace, UP, SMALL_BUFF)
|
||
|
|
||
|
self.add(approx, approx_brace, approx_words)
|
||
|
self.play(
|
||
|
Write(implies),
|
||
|
FadeInFrom(period, LEFT)
|
||
|
)
|
||
|
self.wait()
|
||
|
|
||
|
|
||
|
class StrogatzQuote(Scene):
|
||
|
def construct(self):
|
||
|
law_words = "laws of physics"
|
||
|
language_words = "language of differential equations"
|
||
|
author = "-Steven Strogatz"
|
||
|
quote = TextMobject(
|
||
|
"""
|
||
|
\\Large
|
||
|
``Since Newton, mankind has come to realize
|
||
|
that the laws of physics are always expressed
|
||
|
in the language of differential equations.''\\\\
|
||
|
""" + author,
|
||
|
alignment="",
|
||
|
arg_separator=" ",
|
||
|
substrings_to_isolate=[law_words, language_words, author]
|
||
|
)
|
||
|
law_part = quote.get_part_by_tex(law_words)
|
||
|
language_part = quote.get_part_by_tex(language_words)
|
||
|
author_part = quote.get_part_by_tex(author)
|
||
|
quote.set_width(12)
|
||
|
quote.to_edge(UP)
|
||
|
quote[-2].shift(SMALL_BUFF * LEFT)
|
||
|
author_part.shift(RIGHT + 0.5 * DOWN)
|
||
|
author_part.scale(1.2, about_edge=UL)
|
||
|
|
||
|
movers = VGroup(*quote[:-1].family_members_with_points())
|
||
|
for mover in movers:
|
||
|
mover.save_state()
|
||
|
disc = Circle(radius=0.05)
|
||
|
disc.set_stroke(width=0)
|
||
|
disc.set_fill(BLACK, 0)
|
||
|
disc.move_to(mover)
|
||
|
mover.become(disc)
|
||
|
self.play(
|
||
|
FadeInFrom(author_part, LEFT),
|
||
|
LaggedStartMap(
|
||
|
# FadeInFromLarge,
|
||
|
# quote[:-1].family_members_with_points(),
|
||
|
Restore, movers,
|
||
|
lag_ratio=0.005,
|
||
|
run_time=2,
|
||
|
)
|
||
|
# FadeInFromDown(quote[:-1]),
|
||
|
# lag_ratio=0.01,
|
||
|
)
|
||
|
self.wait()
|
||
|
self.play(
|
||
|
Write(law_part.copy().set_color(YELLOW)),
|
||
|
run_time=1,
|
||
|
)
|
||
|
self.wait()
|
||
|
self.play(
|
||
|
Write(language_part.copy().set_color(BLUE)),
|
||
|
run_time=1.5,
|
||
|
)
|
||
|
self.wait(2)
|
||
|
|
||
|
|
||
|
class SetAsideSeekingSolution(Scene):
|
||
|
def construct(self):
|
||
|
ode = get_ode()
|
||
|
ode.to_edge(UP)
|
||
|
q1 = TextMobject("Find an exact solution")
|
||
|
q1.set_color(YELLOW)
|
||
|
q2 = TexMobject(
|
||
|
"\\text{What is }", "\\theta", "(t)",
|
||
|
"\\text{'s personality?}",
|
||
|
tex_to_color_map={"\\theta": BLUE},
|
||
|
arg_separator="",
|
||
|
)
|
||
|
theta = q2.get_part_by_tex("\\theta")
|
||
|
|
||
|
for q in q1, q2:
|
||
|
q.scale(1.5)
|
||
|
q.next_to(ode, DOWN, MED_LARGE_BUFF)
|
||
|
eyes = Eyes(theta, height=0.1)
|
||
|
|
||
|
self.add(ode)
|
||
|
self.add(q1)
|
||
|
self.wait()
|
||
|
self.play(
|
||
|
q1.scale, 0.3,
|
||
|
q1.to_corner, UR, MED_SMALL_BUFF,
|
||
|
)
|
||
|
self.play(FadeInFrom(q2, DOWN))
|
||
|
self.play(
|
||
|
eyes.blink,
|
||
|
rate_func=lambda t: smooth(1 - t),
|
||
|
)
|
||
|
self.play(eyes.look_at, q2.get_left())
|
||
|
self.play(eyes.look_at, q2.get_right())
|
||
|
self.play(
|
||
|
eyes.blink,
|
||
|
rate_func=squish_rate_func(there_and_back)
|
||
|
)
|
||
|
self.wait()
|
||
|
self.play(
|
||
|
eyes.change_mode, "confused",
|
||
|
eyes.look_at, ode.get_left(),
|
||
|
)
|
||
|
self.play(
|
||
|
eyes.blink,
|
||
|
rate_func=squish_rate_func(there_and_back)
|
||
|
)
|