mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Changes to Fourier series for name animations
This commit is contained in:
parent
81715adb05
commit
f31cf2e30f
1 changed files with 17 additions and 17 deletions
|
@ -18,17 +18,16 @@ class FourierCirclesScene(Scene):
|
||||||
"vector_config": {
|
"vector_config": {
|
||||||
"buff": 0,
|
"buff": 0,
|
||||||
"max_tip_length_to_length_ratio": 0.35,
|
"max_tip_length_to_length_ratio": 0.35,
|
||||||
"tip_length": 0.15,
|
"fill_opacity": 0.75,
|
||||||
"max_stroke_width_to_length_ratio": 10,
|
|
||||||
"stroke_width": 2,
|
|
||||||
},
|
},
|
||||||
"circle_config": {
|
"circle_config": {
|
||||||
"stroke_width": 1,
|
"stroke_width": 1,
|
||||||
|
"stroke_opacity": 0.75,
|
||||||
},
|
},
|
||||||
"base_frequency": 1,
|
"base_frequency": 1,
|
||||||
"slow_factor": 0.25,
|
"slow_factor": 0.25,
|
||||||
"center_point": ORIGIN,
|
"center_point": ORIGIN,
|
||||||
"parametric_function_step_size": 0.001,
|
"parametric_function_step_size": 0.01,
|
||||||
"drawn_path_color": YELLOW,
|
"drawn_path_color": YELLOW,
|
||||||
"drawn_path_stroke_width": 2,
|
"drawn_path_stroke_width": 2,
|
||||||
}
|
}
|
||||||
|
@ -144,9 +143,7 @@ class FourierCirclesScene(Scene):
|
||||||
|
|
||||||
path = ParametricCurve(
|
path = ParametricCurve(
|
||||||
lambda t: center + reduce(op.add, [
|
lambda t: center + reduce(op.add, [
|
||||||
complex_to_R3(
|
complex_to_R3(coef * np.exp(TAU * 1j * freq * t))
|
||||||
coef * np.exp(TAU * 1j * freq * t)
|
|
||||||
)
|
|
||||||
for coef, freq in zip(coefs, freqs)
|
for coef, freq in zip(coefs, freqs)
|
||||||
]),
|
]),
|
||||||
t_min=0,
|
t_min=0,
|
||||||
|
@ -381,7 +378,7 @@ class FourierOfTexPaths(FourierOfPiSymbol, MovingCameraScene):
|
||||||
"animated_name": "Abc",
|
"animated_name": "Abc",
|
||||||
"time_per_symbol": 5,
|
"time_per_symbol": 5,
|
||||||
"slow_factor": 1 / 5,
|
"slow_factor": 1 / 5,
|
||||||
"parametric_function_step_size": 0.01,
|
"parametric_function_step_size": 0.001,
|
||||||
}
|
}
|
||||||
|
|
||||||
def construct(self):
|
def construct(self):
|
||||||
|
@ -395,28 +392,31 @@ class FourierOfTexPaths(FourierOfPiSymbol, MovingCameraScene):
|
||||||
frame = self.camera.frame
|
frame = self.camera.frame
|
||||||
frame.save_state()
|
frame.save_state()
|
||||||
|
|
||||||
vectors = VGroup(VectorizedPoint())
|
vectors = None
|
||||||
circles = VGroup(VectorizedPoint())
|
circles = None
|
||||||
for path in name.family_members_with_points():
|
for path in name.family_members_with_points():
|
||||||
for subpath in path.get_subpaths():
|
for subpath in path.get_subpaths():
|
||||||
sp_mob = VMobject()
|
sp_mob = VMobject()
|
||||||
sp_mob.set_points(subpath)
|
sp_mob.set_points(subpath)
|
||||||
|
sp_mob.set_color("#2561d9")
|
||||||
coefs = self.get_coefficients_of_path(sp_mob)
|
coefs = self.get_coefficients_of_path(sp_mob)
|
||||||
new_vectors = self.get_rotating_vectors(
|
new_vectors = self.get_rotating_vectors(coefficients=coefs)
|
||||||
coefficients=coefs
|
|
||||||
)
|
|
||||||
new_circles = self.get_circles(new_vectors)
|
new_circles = self.get_circles(new_vectors)
|
||||||
self.set_decreasing_stroke_widths(new_circles)
|
self.set_decreasing_stroke_widths(new_circles)
|
||||||
|
|
||||||
drawn_path = self.get_drawn_path(new_vectors)
|
drawn_path = self.get_drawn_path(new_vectors)
|
||||||
drawn_path.clear_updaters()
|
drawn_path.clear_updaters()
|
||||||
drawn_path.set_stroke(self.name_color, 3)
|
drawn_path.set_stroke(self.name_color, 3)
|
||||||
|
drawn_path.set_fill(opacity=0)
|
||||||
|
|
||||||
static_vectors = VMobject().become(new_vectors)
|
static_vectors = VMobject().become(new_vectors)
|
||||||
static_circles = VMobject().become(new_circles)
|
static_circles = VMobject().become(new_circles)
|
||||||
# static_circles = new_circles.deepcopy()
|
|
||||||
# static_vectors.clear_updaters()
|
if vectors is None:
|
||||||
# static_circles.clear_updaters()
|
vectors = static_vectors.copy()
|
||||||
|
circles = static_circles.copy()
|
||||||
|
vectors.scale(0)
|
||||||
|
circles.scale(0)
|
||||||
|
|
||||||
self.play(
|
self.play(
|
||||||
Transform(vectors, static_vectors, remover=True),
|
Transform(vectors, static_vectors, remover=True),
|
||||||
|
@ -425,7 +425,7 @@ class FourierOfTexPaths(FourierOfPiSymbol, MovingCameraScene):
|
||||||
frame.move_to, path,
|
frame.move_to, path,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.add(new_vectors, new_circles)
|
self.add(drawn_path, new_vectors, new_circles)
|
||||||
self.vector_clock.set_value(0)
|
self.vector_clock.set_value(0)
|
||||||
self.play(
|
self.play(
|
||||||
ShowCreation(drawn_path),
|
ShowCreation(drawn_path),
|
||||||
|
|
Loading…
Add table
Reference in a new issue