mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
tweaking some diffyq content
This commit is contained in:
parent
61bb4944fa
commit
d6876b995d
6 changed files with 1446 additions and 126 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@ cairo_test.py
|
|||
mayavi_test.py
|
||||
random_scenes/
|
||||
files/
|
||||
assets/
|
||||
ben_playground.py
|
||||
ben_cairo_test.py
|
||||
.floo
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
from manimlib.imports import *
|
||||
from active_projects.diffyq.part2.fourier_series import FourierOfName
|
||||
|
||||
name_color_pairs = [
|
||||
|
||||
]
|
||||
|
||||
circle_counts = [
|
||||
# 10,
|
||||
# 25,
|
||||
100,
|
||||
]
|
||||
|
||||
if __name__ == "__main__":
|
||||
for name, color in name_color_pairs:
|
||||
for n_circles in circle_counts:
|
||||
try:
|
||||
first_name = name.split(" ")[0]
|
||||
scene = FourierOfName(
|
||||
name_text=name,
|
||||
name_color=color,
|
||||
n_circles=n_circles,
|
||||
file_writer_config={
|
||||
"write_to_movie": True,
|
||||
"output_directory": os.path.join(
|
||||
"patron_fourier_names",
|
||||
first_name,
|
||||
),
|
||||
"file_name": "{}_Fouierified_{}_Separate_paths".format(
|
||||
first_name,
|
||||
n_circles
|
||||
),
|
||||
},
|
||||
camera_config={
|
||||
"frame_rate": 24,
|
||||
},
|
||||
)
|
||||
except:
|
||||
pass
|
|
@ -2012,11 +2012,18 @@ class ManyStepsFromDifferentStartingPoints(TakeManyTinySteps):
|
|||
class Thumbnail(IntroduceVectorField):
|
||||
CONFIG = {
|
||||
"vector_field_config": {
|
||||
"delta_x": 0.5,
|
||||
"delta_y": 0.5,
|
||||
# "delta_x": 0.5,
|
||||
# "delta_y": 0.5,
|
||||
# "max_magnitude": 5,
|
||||
# "length_func": lambda norm: 0.5 * sigmoid(norm),
|
||||
"delta_x": 1,
|
||||
"delta_y": 1,
|
||||
"max_magnitude": 5,
|
||||
"length_func": lambda norm: 0.5 * sigmoid(norm),
|
||||
}
|
||||
"length_func": lambda norm: 0.9 * sigmoid(norm),
|
||||
},
|
||||
"big_pendulum_config": {
|
||||
"damping": 0.4,
|
||||
},
|
||||
}
|
||||
|
||||
def construct(self):
|
||||
|
@ -2027,7 +2034,7 @@ class Thumbnail(IntroduceVectorField):
|
|||
field = self.vector_field
|
||||
field.set_stroke(width=5)
|
||||
for vector in field:
|
||||
vector.set_stroke(width=3)
|
||||
vector.set_stroke(width=8)
|
||||
vector.tip.set_stroke(width=0)
|
||||
vector.tip.scale(1.5, about_point=vector.get_last_point())
|
||||
vector.set_opacity(1)
|
||||
|
@ -2063,17 +2070,43 @@ class Thumbnail(IntroduceVectorField):
|
|||
new_mob.set_stroke(width=0)
|
||||
black_parts.add(new_mob)
|
||||
|
||||
for vect in field:
|
||||
for mob in title.family_members_with_points():
|
||||
for p in [vect.get_start(), vect.get_end()]:
|
||||
x, y = p[:2]
|
||||
x0, y0 = mob.get_corner(DL)[:2]
|
||||
x1, y1 = mob.get_corner(UR)[:2]
|
||||
if x0 < x < x1 and y0 < y < y1:
|
||||
vect.set_opacity(0.25)
|
||||
vect.tip.set_stroke(width=0)
|
||||
# for vect in field:
|
||||
# for mob in title.family_members_with_points():
|
||||
# for p in [vect.get_start(), vect.get_end()]:
|
||||
# x, y = p[:2]
|
||||
# x0, y0 = mob.get_corner(DL)[:2]
|
||||
# x1, y1 = mob.get_corner(UR)[:2]
|
||||
# if x0 < x < x1 and y0 < y < y1:
|
||||
# vect.set_opacity(0.25)
|
||||
# vect.tip.set_stroke(width=0)
|
||||
|
||||
self.add(self.plane)
|
||||
self.add(field)
|
||||
self.add(black_parts)
|
||||
self.add(title)
|
||||
# self.add(black_parts)
|
||||
# self.add(title)
|
||||
|
||||
self.add_line(self.plane)
|
||||
|
||||
def add_line(self, axes):
|
||||
func = self.vector_field_func
|
||||
|
||||
line = VMobject()
|
||||
line.start_new_path(axes.c2p(-TAU, 3.5))
|
||||
|
||||
dt = 0.1
|
||||
t = 0
|
||||
total_time = 40
|
||||
|
||||
while t < total_time:
|
||||
t += dt
|
||||
last_point = line.get_last_point()
|
||||
new_point = last_point + dt * func(last_point)
|
||||
if new_point[0] > FRAME_WIDTH / 2:
|
||||
new_point = last_point + FRAME_WIDTH * LEFT
|
||||
line.start_new_path(new_point)
|
||||
else:
|
||||
line.add_smooth_curve_to(new_point)
|
||||
|
||||
line.set_stroke(WHITE, 6)
|
||||
line.make_smooth()
|
||||
self.add(line)
|
||||
|
|
|
@ -379,6 +379,7 @@ class FourierOfName(FourierOfPiSymbol):
|
|||
"name_text": "Abc",
|
||||
"time_per_symbol": 5,
|
||||
"slow_factor": 1 / 5,
|
||||
"parametric_function_step_size": 0.01,
|
||||
}
|
||||
|
||||
def construct(self):
|
||||
|
@ -389,31 +390,49 @@ class FourierOfName(FourierOfPiSymbol):
|
|||
if name.get_height() > max_height:
|
||||
name.set_height(max_height)
|
||||
|
||||
vectors = VGroup(VectorizedPoint())
|
||||
circles = VGroup(VectorizedPoint())
|
||||
for path in name.family_members_with_points():
|
||||
for subpath in path.get_subpaths():
|
||||
sp_mob = VMobject()
|
||||
sp_mob.set_points(subpath)
|
||||
coefs = self.get_coefficients_of_path(sp_mob)
|
||||
new_circles = self.get_circles(
|
||||
new_vectors = self.get_rotating_vectors(
|
||||
coefficients=coefs
|
||||
)
|
||||
new_circles = self.get_circles(new_vectors)
|
||||
self.set_decreasing_stroke_widths(new_circles)
|
||||
drawn_path = self.get_drawn_path(new_circles)
|
||||
|
||||
drawn_path = self.get_drawn_path(new_vectors)
|
||||
drawn_path.clear_updaters()
|
||||
drawn_path.set_stroke(self.name_color, 3)
|
||||
|
||||
new_circles.suspend_updating()
|
||||
self.play(ReplacementTransform(circles, new_circles))
|
||||
new_circles.resume_updating()
|
||||
circles = new_circles
|
||||
static_vectors = VMobject().become(new_vectors)
|
||||
static_circles = VMobject().become(new_circles)
|
||||
# static_circles = new_circles.deepcopy()
|
||||
# static_vectors.clear_updaters()
|
||||
# static_circles.clear_updaters()
|
||||
|
||||
self.play(
|
||||
Transform(vectors, static_vectors, remover=True),
|
||||
Transform(circles, static_circles, remover=True),
|
||||
)
|
||||
|
||||
self.add(new_vectors, new_circles)
|
||||
self.vector_clock.set_value(0)
|
||||
self.play(
|
||||
ShowCreation(drawn_path),
|
||||
rate_func=linear,
|
||||
run_time=self.time_per_symbol
|
||||
)
|
||||
circles.suspend_updating()
|
||||
self.play(FadeOut(circles))
|
||||
self.remove(new_vectors, new_circles)
|
||||
self.add(static_vectors, static_circles)
|
||||
|
||||
vectors = static_vectors
|
||||
circles = static_circles
|
||||
self.play(
|
||||
FadeOut(vectors)
|
||||
)
|
||||
self.wait(3)
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -45,7 +45,7 @@ def stage_scenes(module_name):
|
|||
animation_dir = os.path.join(
|
||||
os.path.expanduser('~'),
|
||||
"Dropbox (3Blue1Brown)/3Blue1Brown Team Folder/videos",
|
||||
"diffyq", "part4", "1440p60"
|
||||
"diffyq", "part5", "1440p60"
|
||||
)
|
||||
#
|
||||
files = os.listdir(animation_dir)
|
||||
|
|
Loading…
Add table
Reference in a new issue