Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

FourierSeriesIntro

Grant Sandersonb536c21b6bca
diff --git a/active_projects/ode/all_part2_scenes.py b/active_projects/ode/all_part2_scenes.py
index c39a02e13..3ce142706 100644
--- a/active_projects/ode/all_part2_scenes.py
+++ b/active_projects/ode/all_part2_scenes.py
@@ -8,12 +8,15 @@ ALL_SCENE_CLASSES = [
FourierOfPiSymbol,
FourierOfPiSymbol5,
FourierOfTrebleClef,
+ FourierOfEighthNote,
+ FourierOfN,
# CirclesDrawingWave,
# Scenes for video
ExplainCircleAnimations,
- FourierSeriesIntro,
FourierSeriesIntroBackground4,
FourierSeriesIntroBackground8,
FourierSeriesIntroBackground12,
FourierSeriesIntroBackground20,
+ FourierSeriesIntro,
+ PartTwoOfTour,
]
diff --git a/active_projects/ode/part1/staging.py b/active_projects/ode/part1/staging.py
index 1deb25b05..d9f553f62 100644
--- a/active_projects/ode/part1/staging.py
+++ b/active_projects/ode/part1/staging.py
@@ -102,6 +102,7 @@ class TourOfDifferentialEquations(MovingCameraScene):
"fill_color": BLACK,
},
"camera_config": {"background_color": DARKER_GREY},
+ "zoomed_thumbnail_index": 0,
}
def construct(self):
@@ -140,6 +141,7 @@ class TourOfDifferentialEquations(MovingCameraScene):
dots = TexMobject("\\dots")
dots.next_to(thumbnails[-1], RIGHT)
+ self.add_phase_space_preview(thumbnails[0])
self.add_heat_preview(thumbnails[1])
self.add_fourier_series(thumbnails[2])
self.add_matrix_exponent(thumbnails[3])
@@ -166,7 +168,7 @@ class TourOfDifferentialEquations(MovingCameraScene):
self.wait()
self.play(
self.camera_frame.replace,
- thumbnails[0],
+ thumbnails[self.zoomed_thumbnail_index],
run_time=3,
)
self.wait()
@@ -203,6 +205,11 @@ class TourOfDifferentialEquations(MovingCameraScene):
self.wait()
#
+ def add_phase_space_preview(self, thumbnail):
+ image = ImageMobject("LovePhaseSpace")
+ image.replace(thumbnail)
+ thumbnail.add(image)
+
def add_heat_preview(self, thumbnail):
image = ImageMobject("HeatSurfaceExample")
image.replace(thumbnail)
diff --git a/active_projects/ode/part2/staging.py b/active_projects/ode/part2/staging.py
index a4ceac3b7..bbaac905b 100644
--- a/active_projects/ode/part2/staging.py
+++ b/active_projects/ode/part2/staging.py
@@ -1,15 +1,47 @@
from big_ol_pile_of_manim_imports import *
+from active_projects.ode.part1.staging import TourOfDifferentialEquations
class FourierSeriesIntro(Scene):
def construct(self):
+ title_scale_value = 1.5
+
title = TextMobject(
- "Fourier ", "Series", ":",
- " An origin story",
- arg_separator="",
+ "Fourier ", "Series",
)
- title.scale(2)
+ title.scale(title_scale_value)
title.to_edge(UP)
+ title.generate_target()
+
+ details_coming = TextMobject("Details coming...")
+ details_coming.next_to(title.get_corner(DR), DOWN)
+ details_coming.set_color(LIGHT_GREY)
+
+ physics = TextMobject("Physics")
+ physics.scale(title_scale_value)
+ arrow = Arrow(LEFT, RIGHT)
+ group = VGroup(physics, arrow, title.target)
+ group.arrange(RIGHT)
+ physics.align_to(title.target, UP)
+ group.to_edge(UP)
+
+ rot_square = Square()
+ rot_square.fade(1)
+ rot_square.add_updater(lambda m, dt: m.rotate(dt))
+ heat = TextMobject("Heat")
+ heat.scale(title_scale_value)
+ heat.move_to(physics[0][-1], DR)
+
+ def update_heat_colors(heat):
+ vertices = rot_square.get_vertices()
+ letters = heat.family_members_with_points()
+ for letter, vertex in zip(letters, vertices):
+ alpha = (normalize(vertex)[0] + 1) / 2
+ letter.set_color(interpolate_color(
+ YELLOW, RED, alpha,
+ ))
+ heat.add_updater(update_heat_colors)
+
image = ImageMobject("Joseph Fourier")
image.set_height(5)
image.next_to(title, DOWN, MED_LARGE_BUFF)
@@ -17,6 +49,35 @@ class FourierSeriesIntro(Scene):
name = TextMobject("Joseph", "Fourier")
name.next_to(image, DOWN)
+ # self.play(FadeInFromDown(title))
self.add(title)
- self.add(image)
- self.add(name)
+ self.play(
+ FadeInFromDown(image),
+ TransformFromCopy(
+ title.get_part_by_tex("Fourier"),
+ name.get_part_by_tex("Fourier"),
+ path_arc=-45 * DEGREES,
+ ),
+ FadeIn(name.get_part_by_tex("Joseph")),
+ )
+ self.play(Write(details_coming, run_time=1))
+ self.play(LaggedStartMap(FadeOut, details_coming[0], run_time=1))
+ self.wait()
+ self.play(
+ FadeInFrom(physics, RIGHT),
+ GrowArrow(arrow),
+ MoveToTarget(title)
+ )
+ self.wait()
+ self.add(rot_square)
+ self.play(
+ FadeOutAndShift(physics, UP),
+ FadeInFromDown(heat, DOWN),
+ )
+ self.wait(10)
+
+
+class PartTwoOfTour(TourOfDifferentialEquations):
+ CONFIG = {
+ "zoomed_thumbnail_index": 1,
+ }