Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Final animations for diffyq chapter 3

Grant Sandersondfeb11a2ab81
diff --git a/active_projects/ode/part3/discrete_case.py b/active_projects/ode/part3/discrete_case.py
index 7d0678133..2c8ae08c0 100644
--- a/active_projects/ode/part3/discrete_case.py
+++ b/active_projects/ode/part3/discrete_case.py
@@ -99,7 +99,7 @@ class ShowNewRuleAtDiscreteBoundary(DiscreteSetup):
)
self.wait()
- # Point to inward neighbord
+ # Point to inward neighbor
new_arrows = VGroup(*[
Arrow(
d1.get_center(),
diff --git a/active_projects/ode/part3/staging.py b/active_projects/ode/part3/staging.py
index 6bde259c6..e7cc4871a 100644
--- a/active_projects/ode/part3/staging.py
+++ b/active_projects/ode/part3/staging.py
@@ -1140,7 +1140,7 @@ class EndScreen(PatreonEndScreen):
"Jonathan Eppele",
"Kai-Siang Ang",
"Kanan Gill",
- "Kartik Cating-Subramanian",
+ "Kartik\\\\Cating-Subramanian",
"L0j1k",
"Lee Redden",
"Linh Tran",
diff --git a/active_projects/ode/part3/temperature_graphs.py b/active_projects/ode/part3/temperature_graphs.py
index 1fea7a6ec..539a43e87 100644
--- a/active_projects/ode/part3/temperature_graphs.py
+++ b/active_projects/ode/part3/temperature_graphs.py
@@ -45,7 +45,7 @@ class TemperatureGraphScene(SpecialThreeDScene):
if include_labels:
self.add_axes_labels(axes)
- # Adjust axis orinetations
+ # Adjust axis orientation
axes.x_axis.rotate(
90 * DEGREES, RIGHT,
about_point=axes.c2p(0, 0, 0),
@@ -674,9 +674,9 @@ class OceanOfPossibilities(TemperatureGraphScene):
def setup_axes(self):
axes = self.get_three_d_axes(include_numbers=True)
axes.add(axes.input_plane)
- axes.scale(0.9)
+ axes.scale(0.8)
axes.center()
- axes.shift(0.5 * OUT + RIGHT)
+ axes.shift(OUT + RIGHT)
self.add(axes)
self.axes = axes
@@ -2073,6 +2073,7 @@ class ManipulateSinExpSurface(TemperatureGraphScene):
"^2": WHITE,
},
},
+ "graph_config": {},
"initial_phi": -90 * DEGREES,
"initial_omega": 1,
}
@@ -2094,6 +2095,7 @@ class ManipulateSinExpSurface(TemperatureGraphScene):
L = TexMobject("L")
L.rotate(90 * DEGREES, RIGHT)
L.next_to(axes.x_axis.get_end(), IN)
+ axes.x_axis.label = L
axes.x_axis.add(L)
axes.shift(5 * LEFT + 0.5 * IN)
@@ -2424,6 +2426,7 @@ class ManipulateSinExpSurface(TemperatureGraphScene):
lambda: self.get_time_slice_graph(
self.axes, self.func,
t=self.t_tracker.get_value(),
+ **self.graph_config
)
)
@@ -2769,3 +2772,58 @@ class ShowHarmonicSurfaces(ManipulateSinExpSurface):
)
result.to_edge(UP)
return result
+
+
+class Thumbnail(ShowHarmonicSurfaces):
+ CONFIG = {
+ "default_surface_config": {
+ "resolution": (40, 30),
+ # "resolution": (10, 10),
+ },
+ "graph_config": {
+ "stroke_width": 8,
+ },
+ }
+
+ def construct(self):
+ self.setup_axes()
+ self.initialize_parameter_trackers()
+ self.add_surface()
+ self.add_graph()
+ #
+ self.omega_tracker.set_value(3 * PI / 10)
+ self.set_camera_orientation(
+ theta=-70 * DEGREES,
+ )
+
+ axes = self.axes
+ for axis in [axes.y_axis, axes.z_axis]:
+ axis.numbers.set_opacity(0)
+ axis.remove(*axis.numbers)
+ axes.x_axis.label.set_opacity(0)
+ axes.z_axis.label.set_opacity(0)
+
+ for n in range(2, 16, 2):
+ new_graph = self.get_time_slice_graph(
+ axes, self.func, t=n,
+ **self.graph_config
+ )
+ new_graph.set_shade_in_3d(True)
+ new_graph.set_stroke(
+ width=8 / np.sqrt(n),
+ # opacity=1 / n**(1 / 4),
+ )
+ self.add(new_graph)
+
+ words = TextMobject(
+ "Sine waves + Linearity + Fourier = Solution"
+ )
+ words.set_width(FRAME_WIDTH - 1)
+ words.to_edge(DOWN)
+ words.shift(2 * DOWN)
+ self.add_fixed_in_frame_mobjects(words)
+
+ self.camera.frame_center.shift(DOWN)
+ self.update_mobjects(0)
+ self.surface.set_stroke(width=0.1)
+ self.surface.set_fill(opacity=0.2)
diff --git a/active_projects/ode/part3/wordy_scenes.py b/active_projects/ode/part3/wordy_scenes.py
index e32792cf3..e1160ff80 100644
--- a/active_projects/ode/part3/wordy_scenes.py
+++ b/active_projects/ode/part3/wordy_scenes.py
@@ -176,6 +176,94 @@ class BorderRect(Scene):
self.add(rect)
+class SeekIdealized(Scene):
+ def construct(self):
+ phrases = VGroup(*[
+ TextMobject(
+ "Seek", text, "problems",
+ tex_to_color_map={
+ "realistic": GREEN,
+ "{idealized}": YELLOW,
+ "over-idealized": YELLOW,
+ "general": BLUE,
+ }
+ )
+ for text in [
+ "realistic",
+ "{idealized}",
+ "over-idealized",
+ "general",
+ ]
+ ])
+ phrases.scale(2)
+ words = VGroup()
+ for phrase in phrases:
+ phrase.center()
+ word = phrase[1]
+ words.add(word)
+ phrase.remove(word)
+ arrow = Vector(DOWN)
+ arrow.set_stroke(WHITE, 6)
+ arrow.next_to(words[3], UP)
+ low_arrow = arrow.copy()
+ low_arrow.next_to(words[3], DOWN)
+
+ solutions = TextMobject("solutions")
+ solutions.scale(2)
+ solutions.move_to(phrases[3][1], UL)
+ models = TextMobject("models")
+ models.scale(2)
+ models.next_to(
+ words[0], RIGHT, buff=0.35,
+ aligned_edge=DOWN
+ )
+
+ phrases.center()
+ phrase = phrases[0]
+
+ self.add(phrase)
+ self.add(words[0])
+ self.wait()
+ words[0].save_state()
+ self.play(
+ words[0].to_edge, DOWN,
+ words[0].set_opacity, 0.5,
+ Transform(phrase, phrases[1]),
+ FadeInFrom(words[1], UP)
+ )
+ self.wait()
+ # self.play(
+ # words[1].move_to, words[2], RIGHT,
+ # FadeIn(words[2]),
+ # Transform(phrase, phrases[2])
+ # )
+ # self.wait()
+ self.play(
+ words[1].next_to, arrow, UP,
+ ShowCreation(arrow),
+ MaintainPositionRelativeTo(
+ phrase, words[1]
+ ),
+ FadeInFrom(solutions, LEFT),
+ FadeIn(words[3]),
+ )
+ self.wait()
+
+ words[0].generate_target()
+ words[0].target.next_to(low_arrow, DOWN)
+ words[0].target.set_opacity(1)
+ models.shift(
+ words[0].target.get_center() -
+ words[0].saved_state.get_center()
+ )
+ self.play(
+ MoveToTarget(words[0]),
+ ShowCreation(low_arrow),
+ FadeInFrom(models, LEFT)
+ )
+ self.wait()
+
+
class SecondDerivativeOfSine(Scene):
def construct(self):
equation = TexMobject(
@@ -769,3 +857,63 @@ class CompareFreqDecays2to4(CompareFreqDecays1to2):
CONFIG = {
"freqs": [2, 4],
}
+
+
+class WorryAboutGenerality(TeacherStudentsScene, WriteHeatEquationTemplate):
+ def construct(self):
+ eq = self.get_d1_equation()
+ diffyq = self.get_diffyq_set()
+ is_in = TexMobject("\\in")
+ is_in.scale(2)
+
+ group = VGroup(eq, is_in, diffyq)
+ group.arrange(RIGHT, buff=MED_LARGE_BUFF)
+ group.to_edge(UP)
+
+ arrow = Vector(DOWN)
+ arrow.set_stroke(WHITE, 5)
+ arrow.next_to(eq, DOWN)
+ themes = TextMobject("Frequent themes")
+ themes.scale(1.5)
+ themes.next_to(arrow, DOWN)
+
+ self.play(
+ self.get_student_changes(
+ "sad", "tired", "pleading"
+ ),
+ self.teacher.change, "raise_right_hand",
+ FadeInFromDown(eq)
+ )
+ self.play(Write(group[1:]))
+ self.wait(2)
+ self.play(
+ ShowCreation(arrow),
+ self.get_student_changes(*3 * ["pondering"]),
+ )
+ self.play(
+ FadeInFrom(themes, UP),
+ self.get_student_changes(*3 * ["thinking"]),
+ self.teacher.change, "happy"
+ )
+ self.wait(4)
+
+
+ # def get_d1_equation(self):
+ # result = super().get_d1_equation()
+ # lp, rp = parens = TexMobject("(", ")")
+ # parens.match_height(result)
+ # lp.next_to(result, LEFT, SMALL_BUFF)
+ # rp.next_to(result, RIGHT, SMALL_BUFF)
+ # result.add_to_back(lp)
+ # result.add(rp)
+ # return result
+
+ def get_diffyq_set(self):
+ words = TextMobject(
+ "Differential\\\\equations"
+ )
+ words.scale(1.5)
+ words.set_color(BLUE)
+ lb = Brace(words, LEFT)
+ rb = Brace(words, RIGHT)
+ return VGroup(lb, words, rb)