mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Modernize Python 2 for Python 3
This commit is contained in:
parent
a5adb90ae8
commit
151a270913
123 changed files with 785 additions and 707 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
*.pyc
|
*.pyc
|
||||||
|
*.bak
|
||||||
.DS_Store
|
.DS_Store
|
||||||
homeless.py
|
homeless.py
|
||||||
playground.py
|
playground.py
|
||||||
|
|
|
@ -88,7 +88,7 @@ class NumberlineTransformationScene(ZoomedScene):
|
||||||
def setup_titles(self):
|
def setup_titles(self):
|
||||||
input_title, output_title = self.titles = VGroup(*[
|
input_title, output_title = self.titles = VGroup(*[
|
||||||
TextMobject(word)
|
TextMobject(word)
|
||||||
for word in "Inputs", "Outputs"
|
for word in ("Inputs", "Outputs")
|
||||||
])
|
])
|
||||||
vects = [UP, DOWN]
|
vects = [UP, DOWN]
|
||||||
for title, line, vect in zip(self.titles, self.number_lines, vects):
|
for title, line, vect in zip(self.titles, self.number_lines, vects):
|
||||||
|
@ -450,7 +450,7 @@ class WriteOpeningWords(Scene):
|
||||||
"any new topic, it will take some hard work to understand,"
|
"any new topic, it will take some hard work to understand,"
|
||||||
words1, words2 = [
|
words1, words2 = [
|
||||||
TextMobject("\\Large", *rs.split(" "))
|
TextMobject("\\Large", *rs.split(" "))
|
||||||
for rs in raw_string1, raw_string2
|
for rs in (raw_string1, raw_string2)
|
||||||
]
|
]
|
||||||
words1.next_to(words2, UP, aligned_edge=LEFT, buff=LARGE_BUFF)
|
words1.next_to(words2, UP, aligned_edge=LEFT, buff=LARGE_BUFF)
|
||||||
words = VGroup(*it.chain(words1, words2))
|
words = VGroup(*it.chain(words1, words2))
|
||||||
|
@ -2471,7 +2471,7 @@ class ThinkAboutWithRepeatedApplication(IntroduceContinuedFractionPuzzle):
|
||||||
line[1],
|
line[1],
|
||||||
line[2][:4],
|
line[2][:4],
|
||||||
)
|
)
|
||||||
for line in lines[1], new_line
|
for line in (lines[1], new_line)
|
||||||
]
|
]
|
||||||
anims = [ReplacementTransform(
|
anims = [ReplacementTransform(
|
||||||
mover.copy().fade(1), target, path_arc=30 * DEGREES
|
mover.copy().fade(1), target, path_arc=30 * DEGREES
|
||||||
|
@ -2617,7 +2617,7 @@ class ShowRepeatedApplication(Scene):
|
||||||
|
|
||||||
rects = VGroup(*[
|
rects = VGroup(*[
|
||||||
SurroundingRectangle(mob)
|
SurroundingRectangle(mob)
|
||||||
for mob in line[0], line[1:-1], line[-1]
|
for mob in (line[0], line[1:-1], line[-1])
|
||||||
])
|
])
|
||||||
rects.set_stroke(BLUE, 2)
|
rects.set_stroke(BLUE, 2)
|
||||||
|
|
||||||
|
@ -2886,7 +2886,7 @@ class RepeatedApplicationGraphically(GraphOnePlusOneOverX, PiCreatureScene):
|
||||||
y_point = self.coords_to_point(0, new_output)
|
y_point = self.coords_to_point(0, new_output)
|
||||||
lines = VGroup(*[
|
lines = VGroup(*[
|
||||||
Line(dot.get_center(), point)
|
Line(dot.get_center(), point)
|
||||||
for point in x_point, y_point
|
for point in (x_point, y_point)
|
||||||
])
|
])
|
||||||
lines.set_color(YELLOW)
|
lines.set_color(YELLOW)
|
||||||
self.play(ShowCreationThenDestruction(
|
self.play(ShowCreationThenDestruction(
|
||||||
|
@ -3001,7 +3001,7 @@ class AnalyzeFunctionWithTransformations(NumberlineTransformationScene):
|
||||||
for point in sample_points
|
for point in sample_points
|
||||||
if np.linalg.norm(point - input_zero_point) > 0.3
|
if np.linalg.norm(point - input_zero_point) > 0.3
|
||||||
])
|
])
|
||||||
for func in point_func, alt_point_func
|
for func in (point_func, alt_point_func)
|
||||||
]
|
]
|
||||||
for group in arrows, alt_arrows:
|
for group in arrows, alt_arrows:
|
||||||
group.set_stroke(WHITE, 0.5)
|
group.set_stroke(WHITE, 0.5)
|
||||||
|
@ -3608,7 +3608,7 @@ class ManyInfiniteExpressions(Scene):
|
||||||
lag_ratio=0.1,
|
lag_ratio=0.1,
|
||||||
run_time=8,
|
run_time=8,
|
||||||
)
|
)
|
||||||
for group in frac, radical, power_tower
|
for group in (frac, radical, power_tower)
|
||||||
])
|
])
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
DEFAULT_SCALAR_FIELD_COLORS = [BLUE_E, GREEN, YELLOW, RED]
|
DEFAULT_SCALAR_FIELD_COLORS = [BLUE_E, GREEN, YELLOW, RED]
|
||||||
|
@ -153,7 +154,7 @@ def get_color_field_image_file(scalar_func,
|
||||||
file_name = "%d.png" % func_hash
|
file_name = "%d.png" % func_hash
|
||||||
full_path = os.path.join(RASTER_IMAGE_DIR, file_name)
|
full_path = os.path.join(RASTER_IMAGE_DIR, file_name)
|
||||||
if not os.path.exists(full_path):
|
if not os.path.exists(full_path):
|
||||||
print "Rendering color field image " + str(func_hash)
|
print("Rendering color field image " + str(func_hash))
|
||||||
rgb_gradient_func = get_rgb_gradient_function(
|
rgb_gradient_func = get_rgb_gradient_function(
|
||||||
min_value=min_value,
|
min_value=min_value,
|
||||||
max_value=max_value,
|
max_value=max_value,
|
||||||
|
@ -885,7 +886,7 @@ class CylinderModel(Scene):
|
||||||
path_arc=0,
|
path_arc=0,
|
||||||
n_arc_anchors=100,
|
n_arc_anchors=100,
|
||||||
).next_to(ORIGIN, vect, buff=2)
|
).next_to(ORIGIN, vect, buff=2)
|
||||||
for vect in LEFT, RIGHT
|
for vect in (LEFT, RIGHT)
|
||||||
])
|
])
|
||||||
# This line is a bit of a hack
|
# This line is a bit of a hack
|
||||||
h_line = Line(LEFT, RIGHT, color=WHITE)
|
h_line = Line(LEFT, RIGHT, color=WHITE)
|
||||||
|
@ -986,7 +987,7 @@ class ElectricField(CylinderModel, MovingCameraScene):
|
||||||
)
|
)
|
||||||
protons, electrons = groups = [
|
protons, electrons = groups = [
|
||||||
VGroup(*[method(radius=0.2) for x in range(20)])
|
VGroup(*[method(radius=0.2) for x in range(20)])
|
||||||
for method in get_proton, get_electron
|
for method in (get_proton, get_electron)
|
||||||
]
|
]
|
||||||
for group in groups:
|
for group in groups:
|
||||||
group.arrange_submobjects(RIGHT, buff=MED_SMALL_BUFF)
|
group.arrange_submobjects(RIGHT, buff=MED_SMALL_BUFF)
|
||||||
|
@ -1495,7 +1496,7 @@ class IntroduceVectorField(Scene):
|
||||||
fill_opacity=1,
|
fill_opacity=1,
|
||||||
fill_color=color
|
fill_color=color
|
||||||
)
|
)
|
||||||
for color in BLUE, RED
|
for color in (BLUE, RED)
|
||||||
])
|
])
|
||||||
magnet.arrange_submobjects(RIGHT, buff=0)
|
magnet.arrange_submobjects(RIGHT, buff=0)
|
||||||
for char, vect in ("S", LEFT), ("N", RIGHT):
|
for char, vect in ("S", LEFT), ("N", RIGHT):
|
||||||
|
@ -1778,7 +1779,7 @@ class DefineDivergence(ChangingElectricField):
|
||||||
for particle in particles
|
for particle in particles
|
||||||
if u * particle.charge > 0
|
if u * particle.charge > 0
|
||||||
]
|
]
|
||||||
for u in +1, -1
|
for u in (+1, -1)
|
||||||
]
|
]
|
||||||
pair_of_vector_circle_groups = VGroup()
|
pair_of_vector_circle_groups = VGroup()
|
||||||
for point_set in self.positive_points, self.negative_points:
|
for point_set in self.positive_points, self.negative_points:
|
||||||
|
@ -2081,7 +2082,7 @@ class DivergenceAsNewFunction(Scene):
|
||||||
VGroup(mob.copy().fade(1)),
|
VGroup(mob.copy().fade(1)),
|
||||||
VGroup(out_x, out_y),
|
VGroup(out_x, out_y),
|
||||||
)
|
)
|
||||||
for mob in in_x, in_y
|
for mob in (in_x, in_y)
|
||||||
])
|
])
|
||||||
out_vect = get_out_vect()
|
out_vect = get_out_vect()
|
||||||
VGroup(out_x, out_y).match_style(out_vect)
|
VGroup(out_x, out_y).match_style(out_vect)
|
||||||
|
@ -2197,7 +2198,7 @@ class DivergenceAsNewFunction(Scene):
|
||||||
ContinualUpdateFromFunc(
|
ContinualUpdateFromFunc(
|
||||||
mob, lambda m: m.set_fill(None, 0)
|
mob, lambda m: m.set_fill(None, 0)
|
||||||
)
|
)
|
||||||
for mob in out_x, out_y
|
for mob in (out_x, out_y)
|
||||||
])
|
])
|
||||||
self.add_foreground_mobjects(div_tex)
|
self.add_foreground_mobjects(div_tex)
|
||||||
self.play(
|
self.play(
|
||||||
|
@ -3112,7 +3113,7 @@ class ShowTwoPopulations(Scene):
|
||||||
FadeIn(labels),
|
FadeIn(labels),
|
||||||
*[
|
*[
|
||||||
UpdateFromAlphaFunc(count, lambda m, a: m.set_fill(opacity=a))
|
UpdateFromAlphaFunc(count, lambda m, a: m.set_fill(opacity=a))
|
||||||
for count in num_foxes, num_rabbits
|
for count in (num_foxes, num_rabbits)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3211,7 +3212,7 @@ class PhaseSpaceOfPopulationModel(ShowTwoPopulations, PiCreatureScene, MovingCam
|
||||||
method().scale_to_fit_height(0.75),
|
method().scale_to_fit_height(0.75),
|
||||||
TextMobject("Population"),
|
TextMobject("Population"),
|
||||||
).arrange_submobjects(RIGHT, buff=MED_SMALL_BUFF)
|
).arrange_submobjects(RIGHT, buff=MED_SMALL_BUFF)
|
||||||
for method in self.get_rabbit, self.get_fox
|
for method in (self.get_rabbit, self.get_fox)
|
||||||
])
|
])
|
||||||
for axis, label, vect in zip(axes, axes_labels, [RIGHT, UP]):
|
for axis, label, vect in zip(axes, axes_labels, [RIGHT, UP]):
|
||||||
label.next_to(
|
label.next_to(
|
||||||
|
@ -3256,7 +3257,7 @@ class PhaseSpaceOfPopulationModel(ShowTwoPopulations, PiCreatureScene, MovingCam
|
||||||
coord_pair_update = ContinualUpdateFromFunc(
|
coord_pair_update = ContinualUpdateFromFunc(
|
||||||
coord_pair, lambda m: m.next_to(dot, UR, SMALL_BUFF)
|
coord_pair, lambda m: m.next_to(dot, UR, SMALL_BUFF)
|
||||||
)
|
)
|
||||||
pop_sizes_updates = [get_pop_size_update(i) for i in 0, 1]
|
pop_sizes_updates = [get_pop_size_update(i) for i in (0, 1)]
|
||||||
|
|
||||||
phase_space = TextMobject("``Phase space''")
|
phase_space = TextMobject("``Phase space''")
|
||||||
phase_space.set_color(YELLOW)
|
phase_space.set_color(YELLOW)
|
||||||
|
@ -3642,7 +3643,7 @@ class NablaNotation(PiCreatureScene, MovingCameraScene):
|
||||||
F_vector.copy(),
|
F_vector.copy(),
|
||||||
TexMobject("=")
|
TexMobject("=")
|
||||||
)
|
)
|
||||||
for tex in "\\cdot", "\\times"
|
for tex in ("\\cdot", "\\times")
|
||||||
])
|
])
|
||||||
colors = [BLUE, YELLOW]
|
colors = [BLUE, YELLOW]
|
||||||
for lhs, color in zip(lhs_groups, colors):
|
for lhs, color in zip(lhs_groups, colors):
|
||||||
|
|
|
@ -416,7 +416,7 @@ class SetupSimpleSystemOfEquations(LinearTransformationScene):
|
||||||
matrix_mobject = system.matrix_mobject
|
matrix_mobject = system.matrix_mobject
|
||||||
columns = VGroup(*[
|
columns = VGroup(*[
|
||||||
VGroup(*matrix_mobject.mob_matrix[:, i])
|
VGroup(*matrix_mobject.mob_matrix[:, i])
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
])
|
])
|
||||||
|
|
||||||
matrix = np.array(self.matrix)
|
matrix = np.array(self.matrix)
|
||||||
|
@ -742,11 +742,11 @@ class ThinkOfPuzzleAsLinearCombination(SetupSimpleSystemOfEquations):
|
||||||
|
|
||||||
columns = VGroup(*[
|
columns = VGroup(*[
|
||||||
VGroup(*matrix.mob_matrix[:, i].flatten())
|
VGroup(*matrix.mob_matrix[:, i].flatten())
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
])
|
])
|
||||||
column_arrays = VGroup(*[
|
column_arrays = VGroup(*[
|
||||||
MobjectMatrix(matrix.deepcopy().mob_matrix[:, i])
|
MobjectMatrix(matrix.deepcopy().mob_matrix[:, i])
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
])
|
])
|
||||||
for column_array in column_arrays:
|
for column_array in column_arrays:
|
||||||
column_array.match_height(output_vect)
|
column_array.match_height(output_vect)
|
||||||
|
@ -1913,7 +1913,7 @@ class TransformingAreasYCoord(LinearTransformationScene):
|
||||||
min_num_quads=3,
|
min_num_quads=3,
|
||||||
max_num_quads=3,
|
max_num_quads=3,
|
||||||
)
|
)
|
||||||
for vect in DOWN, RIGHT
|
for vect in (DOWN, RIGHT)
|
||||||
])
|
])
|
||||||
for brace, tex, color in zip(braces, "xy", [X_COLOR, Y_COLOR]):
|
for brace, tex, color in zip(braces, "xy", [X_COLOR, Y_COLOR]):
|
||||||
brace.label = brace.get_tex(tex, buff=SMALL_BUFF)
|
brace.label = brace.get_tex(tex, buff=SMALL_BUFF)
|
||||||
|
|
|
@ -108,7 +108,7 @@ class WorkOutNumerically(Scene):
|
||||||
LaggedStart(
|
LaggedStart(
|
||||||
ReplacementTransform,
|
ReplacementTransform,
|
||||||
matrix_numbers,
|
matrix_numbers,
|
||||||
lambda m: (m, numbers_iter.next()),
|
lambda m: (m, next(numbers_iter)),
|
||||||
path_arc=TAU / 6
|
path_arc=TAU / 6
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -139,7 +139,7 @@ class WorkOutNumerically(Scene):
|
||||||
self.play(FadeIn(empty_det_tex))
|
self.play(FadeIn(empty_det_tex))
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ReplacementTransform(M.copy(), matrix)
|
ReplacementTransform(M.copy(), matrix)
|
||||||
for M in self.M1, self.M2
|
for M in (self.M1, self.M2)
|
||||||
])
|
])
|
||||||
self.play(LaggedStart(FadeIn, group[1:]))
|
self.play(LaggedStart(FadeIn, group[1:]))
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
|
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
|
||||||
class FractionMobject(VGroup):
|
class FractionMobject(VGroup):
|
||||||
|
|
|
@ -1634,7 +1634,7 @@ class MusicExample(SampleSpaceScene, PiCreatureScene):
|
||||||
randy = self.pi_creature
|
randy = self.pi_creature
|
||||||
friends = VGroup(*[
|
friends = VGroup(*[
|
||||||
PiCreature(mode = "happy", color = color).flip()
|
PiCreature(mode = "happy", color = color).flip()
|
||||||
for color in BLUE_B, GREY_BROWN, MAROON_E
|
for color in (BLUE_B, GREY_BROWN, MAROON_E)
|
||||||
])
|
])
|
||||||
friends.scale(0.6)
|
friends.scale(0.6)
|
||||||
friends.arrange_submobjects(RIGHT)
|
friends.arrange_submobjects(RIGHT)
|
||||||
|
|
|
@ -672,7 +672,7 @@ class ShowRestrictedSpace(Scene):
|
||||||
words.to_edge(UP)
|
words.to_edge(UP)
|
||||||
arrows = [
|
arrows = [
|
||||||
Arrow(words.get_bottom(), movers.target[i].get_top())
|
Arrow(words.get_bottom(), movers.target[i].get_top())
|
||||||
for i in 0, -1
|
for i in (0, -1)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.play(FadeOut(to_fade))
|
self.play(FadeOut(to_fade))
|
||||||
|
@ -1354,7 +1354,7 @@ class CompareNumbersInBothExamples(Scene):
|
||||||
TexMobject(
|
TexMobject(
|
||||||
"P(", "\\text{%s}"%s, ")", "= 1/1{,}000}"
|
"P(", "\\text{%s}"%s, ")", "= 1/1{,}000}"
|
||||||
)
|
)
|
||||||
for s in "Sick", "Powers"
|
for s in ("Sick", "Powers")
|
||||||
])
|
])
|
||||||
likelihoods = VGroup(*[
|
likelihoods = VGroup(*[
|
||||||
TexMobject(
|
TexMobject(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
from active_projects.eop.reusable_imports import *
|
from active_projects.eop.reusable_imports import *
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ class ShuffleThroughAllSequences(Scene):
|
||||||
|
|
||||||
nb_frames = self.run_time * self.fps
|
nb_frames = self.run_time * self.fps
|
||||||
nb_relevant_coins = int(np.log2(nb_frames)) + 1
|
nb_relevant_coins = int(np.log2(nb_frames)) + 1
|
||||||
print "relevant coins:", nb_relevant_coins
|
print("relevant coins:", nb_relevant_coins)
|
||||||
nb_idle_coins = self.nb_coins - nb_relevant_coins
|
nb_idle_coins = self.nb_coins - nb_relevant_coins
|
||||||
|
|
||||||
idle_heads = CoinSequence(nb_idle_coins * ["H"],
|
idle_heads = CoinSequence(nb_idle_coins * ["H"],
|
||||||
|
@ -55,7 +56,7 @@ class ShuffleThroughAllSequences(Scene):
|
||||||
self.update_frame()
|
self.update_frame()
|
||||||
self.add_frames(self.get_frame())
|
self.add_frames(self.get_frame())
|
||||||
last_coin_seq = coin_seq
|
last_coin_seq = coin_seq
|
||||||
print float(i)/2**nb_relevant_coins
|
print(float(i)/2**nb_relevant_coins)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ class ExperienceProblemSolver(PiCreatureScene):
|
||||||
last_row.copy(), VGroup(*mobs),
|
last_row.copy(), VGroup(*mobs),
|
||||||
remover = True
|
remover = True
|
||||||
)
|
)
|
||||||
for mobs in curr_row[1:], curr_row[:-1]
|
for mobs in (curr_row[1:], curr_row[:-1])
|
||||||
])
|
])
|
||||||
self.add(curr_row)
|
self.add(curr_row)
|
||||||
self.wait(3)
|
self.wait(3)
|
||||||
|
@ -1776,7 +1776,7 @@ class IntroducePascalsTriangle(Scene):
|
||||||
last_row.copy(), VGroup(*mobs),
|
last_row.copy(), VGroup(*mobs),
|
||||||
remover = True
|
remover = True
|
||||||
)
|
)
|
||||||
for mobs in curr_row[1:], curr_row[:-1]
|
for mobs in (curr_row[1:], curr_row[:-1])
|
||||||
])
|
])
|
||||||
self.add(curr_row)
|
self.add(curr_row)
|
||||||
self.wait()
|
self.wait()
|
||||||
|
@ -2115,7 +2115,7 @@ class StacksApproachBellCurve(Scene):
|
||||||
|
|
||||||
self.play(*[
|
self.play(*[
|
||||||
MoveToTarget(mob, submobject_mode = "lagged_start")
|
MoveToTarget(mob, submobject_mode = "lagged_start")
|
||||||
for mob in bars_copy, numbers, numbers_copy
|
for mob in (bars_copy, numbers, numbers_copy)
|
||||||
])
|
])
|
||||||
self.remove(numbers, numbers_copy)
|
self.remove(numbers, numbers_copy)
|
||||||
numbers = VGroup(numbers[0])
|
numbers = VGroup(numbers[0])
|
||||||
|
@ -2407,7 +2407,7 @@ class ChooseThreeFromFive(InitialFiveChooseThreeExample, PiCreatureScene):
|
||||||
self.wait()
|
self.wait()
|
||||||
word_arrow_groups.submobjects = [
|
word_arrow_groups.submobjects = [
|
||||||
word_arrow_groups[j]
|
word_arrow_groups[j]
|
||||||
for j in 1, 2, 0
|
for j in (1, 2, 0)
|
||||||
]
|
]
|
||||||
self.play(*map(FadeOut, [line, odm_words]))
|
self.play(*map(FadeOut, [line, odm_words]))
|
||||||
|
|
||||||
|
@ -2457,7 +2457,7 @@ class ChooseThreeFromFive(InitialFiveChooseThreeExample, PiCreatureScene):
|
||||||
def get_names(self, people):
|
def get_names(self, people):
|
||||||
names = VGroup(*[
|
names = VGroup(*[
|
||||||
TextMobject(name + ",")
|
TextMobject(name + ",")
|
||||||
for name in "Ali", "Ben", "Cam", "Denis", "Evan"
|
for name in ("Ali", "Ben", "Cam", "Denis", "Evan")
|
||||||
])
|
])
|
||||||
for name, pi in zip(names, people):
|
for name, pi in zip(names, people):
|
||||||
name[-1].set_fill(opacity = 0)
|
name[-1].set_fill(opacity = 0)
|
||||||
|
@ -2668,7 +2668,7 @@ class StudentsGetConfused(PiCreatureScene):
|
||||||
def create_pi_creatures(self):
|
def create_pi_creatures(self):
|
||||||
pis = VGroup(*[
|
pis = VGroup(*[
|
||||||
Randolph(color = color)
|
Randolph(color = color)
|
||||||
for color in BLUE_D, BLUE_B
|
for color in (BLUE_D, BLUE_B)
|
||||||
])
|
])
|
||||||
pis[1].flip()
|
pis[1].flip()
|
||||||
pis.arrange_submobjects(RIGHT, buff = 5)
|
pis.arrange_submobjects(RIGHT, buff = 5)
|
||||||
|
|
|
@ -219,7 +219,7 @@ class MeaningOfIndependence(SampleSpaceScene):
|
||||||
self.sample_space.get_corner(vect+RIGHT),
|
self.sample_space.get_corner(vect+RIGHT),
|
||||||
0.7
|
0.7
|
||||||
)
|
)
|
||||||
for vect in UP, DOWN
|
for vect in (UP, DOWN)
|
||||||
])
|
])
|
||||||
line.set_stroke(RED, 8)
|
line.set_stroke(RED, 8)
|
||||||
word = TextMobject("Independence")
|
word = TextMobject("Independence")
|
||||||
|
@ -939,7 +939,7 @@ class ThousandPossibleQuizzes(Scene):
|
||||||
include_qs = False,
|
include_qs = False,
|
||||||
buff = SMALL_BUFF
|
buff = SMALL_BUFF
|
||||||
)
|
)
|
||||||
for b in True, False
|
for b in (True, False)
|
||||||
])
|
])
|
||||||
question = VGroup(
|
question = VGroup(
|
||||||
TextMobject("Where are"), sg1,
|
TextMobject("Where are"), sg1,
|
||||||
|
@ -1499,7 +1499,7 @@ class ShowAllEightConditionals(Scene):
|
||||||
"P(", filler_tex, "|", filler_tex, ")",
|
"P(", filler_tex, "|", filler_tex, ")",
|
||||||
)
|
)
|
||||||
sub_bool_lists = [
|
sub_bool_lists = [
|
||||||
bool_list[:n] for n in 3, 1, 2, 1, 3, 2
|
bool_list[:n] for n in (3, 1, 2, 1, 3, 2)
|
||||||
]
|
]
|
||||||
parts = equation.get_parts_by_tex(filler_tex)
|
parts = equation.get_parts_by_tex(filler_tex)
|
||||||
for part, sub_list in zip(parts, sub_bool_lists):
|
for part, sub_list in zip(parts, sub_bool_lists):
|
||||||
|
@ -2319,7 +2319,7 @@ class NameBinomial(Scene):
|
||||||
flip_indices = self.flip_indices
|
flip_indices = self.flip_indices
|
||||||
flipped_arrows, faded_crosses, full_checks = [
|
flipped_arrows, faded_crosses, full_checks = [
|
||||||
VGroup(*[group[i] for i in flip_indices])
|
VGroup(*[group[i] for i in flip_indices])
|
||||||
for group in arrows, crosses, checkmarks
|
for group in (arrows, crosses, checkmarks)
|
||||||
]
|
]
|
||||||
faded_checkmarks = VGroup(*filter(
|
faded_checkmarks = VGroup(*filter(
|
||||||
lambda m : m not in full_checks,
|
lambda m : m not in full_checks,
|
||||||
|
@ -2543,7 +2543,7 @@ class CycleThroughPatterns(NameBinomial):
|
||||||
getattr(new_pattern, attr),
|
getattr(new_pattern, attr),
|
||||||
path_arc = np.pi
|
path_arc = np.pi
|
||||||
)
|
)
|
||||||
for attr in "boys", "girls"
|
for attr in ("boys", "girls")
|
||||||
])
|
])
|
||||||
|
|
||||||
####
|
####
|
||||||
|
@ -3079,7 +3079,7 @@ class CorrectForDependence(NameBinomial):
|
||||||
for i in range(len(group))
|
for i in range(len(group))
|
||||||
if i in indices
|
if i in indices
|
||||||
])
|
])
|
||||||
for group in self.checkmarks, self.arrows, self.crosses
|
for group in (self.checkmarks, self.arrows, self.crosses)
|
||||||
]
|
]
|
||||||
for arrow in arrows:
|
for arrow in arrows:
|
||||||
arrow.target = arrow.deepcopy()
|
arrow.target = arrow.deepcopy()
|
||||||
|
@ -3276,7 +3276,7 @@ class CompareTwoSituations(PiCreatureScene):
|
||||||
randy = self.randy
|
randy = self.randy
|
||||||
top_left, top_right = screens = [
|
top_left, top_right = screens = [
|
||||||
ScreenRectangle(height = 3).to_corner(vect)
|
ScreenRectangle(height = 3).to_corner(vect)
|
||||||
for vect in UP+LEFT, UP+RIGHT
|
for vect in (UP+LEFT, UP+RIGHT)
|
||||||
]
|
]
|
||||||
arrow = DoubleArrow(*screens, buff = SMALL_BUFF)
|
arrow = DoubleArrow(*screens, buff = SMALL_BUFF)
|
||||||
arrow.set_color(BLUE)
|
arrow.set_color(BLUE)
|
||||||
|
@ -3404,7 +3404,7 @@ class SkepticalOfDistributions(TeacherStudentsScene):
|
||||||
k_range = range(11)
|
k_range = range(11)
|
||||||
dists = [
|
dists = [
|
||||||
get_binomial_distribution(10, p)
|
get_binomial_distribution(10, p)
|
||||||
for p in 0.2, 0.8, 0.5
|
for p in (0.2, 0.8, 0.5)
|
||||||
]
|
]
|
||||||
values_list = [
|
values_list = [
|
||||||
map(dist, k_range)
|
map(dist, k_range)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
from once_useful_constructs.combinatorics import *
|
from once_useful_constructs.combinatorics import *
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ class BuildNewPascalRow(Transform):
|
||||||
# align with original (copy got centered on screen)
|
# align with original (copy got centered on screen)
|
||||||
c1 = new_pt.coords_to_mobs[0][0].get_center()
|
c1 = new_pt.coords_to_mobs[0][0].get_center()
|
||||||
c2 = mobject.coords_to_mobs[0][0].get_center()
|
c2 = mobject.coords_to_mobs[0][0].get_center()
|
||||||
print c1, c2
|
print(c1, c2)
|
||||||
v = c2 - c1
|
v = c2 - c1
|
||||||
new_pt.shift(v)
|
new_pt.shift(v)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import itertools as it
|
import itertools as it
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -160,7 +161,7 @@ class Succession(Animation):
|
||||||
"Rounding error not near alpha=1 in Succession.update_mobject," +
|
"Rounding error not near alpha=1 in Succession.update_mobject," +
|
||||||
"instead alpha = %f" % alpha
|
"instead alpha = %f" % alpha
|
||||||
)
|
)
|
||||||
print self.critical_alphas, alpha
|
print(self.critical_alphas, alpha)
|
||||||
i = self.num_anims - 1
|
i = self.num_anims - 1
|
||||||
|
|
||||||
# At this point, we should have self.critical_alphas[i] <= alpha <= self.critical_alphas[i +1]
|
# At this point, we should have self.critical_alphas[i] <= alpha <= self.critical_alphas[i +1]
|
||||||
|
|
|
@ -21,6 +21,7 @@ from utils.config_ops import digest_config
|
||||||
from utils.rate_functions import squish_rate_func
|
from utils.rate_functions import squish_rate_func
|
||||||
from utils.rate_functions import there_and_back
|
from utils.rate_functions import there_and_back
|
||||||
from utils.rate_functions import wiggle
|
from utils.rate_functions import wiggle
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
|
||||||
class FocusOn(Transform):
|
class FocusOn(Transform):
|
||||||
|
@ -226,7 +227,7 @@ class Vibrate(Animation):
|
||||||
)
|
)
|
||||||
for mob, start in zip(*families):
|
for mob, start in zip(*families):
|
||||||
mob.points = np.apply_along_axis(
|
mob.points = np.apply_along_axis(
|
||||||
lambda (x, y, z): (x, y + self.wave_function(x, time), z),
|
lambda x_y_z: (x_y_z[0], x_y_z[1] + self.wave_function(x_y_z[0], time), x_y_z[2]),
|
||||||
1, start.points
|
1, start.points
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ class ApplyMethod(Transform):
|
||||||
"Whoops, looks like you accidentally invoked " +
|
"Whoops, looks like you accidentally invoked " +
|
||||||
"the method you want to animate"
|
"the method you want to animate"
|
||||||
)
|
)
|
||||||
assert(isinstance(method.im_self, Mobject))
|
assert(isinstance(method.__self__, Mobject))
|
||||||
args = list(args) # So that args.pop() works
|
args = list(args) # So that args.pop() works
|
||||||
if "method_kwargs" in kwargs:
|
if "method_kwargs" in kwargs:
|
||||||
method_kwargs = kwargs["method_kwargs"]
|
method_kwargs = kwargs["method_kwargs"]
|
||||||
|
@ -124,9 +124,9 @@ class ApplyMethod(Transform):
|
||||||
method_kwargs = args.pop()
|
method_kwargs = args.pop()
|
||||||
else:
|
else:
|
||||||
method_kwargs = {}
|
method_kwargs = {}
|
||||||
target = method.im_self.copy()
|
target = method.__self__.copy()
|
||||||
method.im_func(target, *args, **method_kwargs)
|
method.__func__(target, *args, **method_kwargs)
|
||||||
Transform.__init__(self, method.im_self, target, **kwargs)
|
Transform.__init__(self, method.__self__, target, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class ApplyPointwiseFunction(ApplyMethod):
|
class ApplyPointwiseFunction(ApplyMethod):
|
||||||
|
@ -198,7 +198,7 @@ class ComplexFunction(ApplyPointwiseFunction):
|
||||||
)
|
)
|
||||||
ApplyPointwiseFunction.__init__(
|
ApplyPointwiseFunction.__init__(
|
||||||
self,
|
self,
|
||||||
lambda (x, y, z): complex_to_R3(function(complex(x, y))),
|
lambda x_y_z: complex_to_R3(function(complex(x_y_z[0], x_y_z[1]))),
|
||||||
instantiate(mobject),
|
instantiate(mobject),
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,85 +12,86 @@ addressible by changing this file.
|
||||||
Note: One should NOT import from this file for main library code, it is meant only
|
Note: One should NOT import from this file for main library code, it is meant only
|
||||||
as a convenience for scripts creating scenes for videos.
|
as a convenience for scripts creating scenes for videos.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from constants import *
|
from .constants import *
|
||||||
|
|
||||||
from animation.animation import *
|
from .animation.animation import *
|
||||||
from animation.composition import *
|
from .animation.composition import *
|
||||||
from animation.creation import *
|
from .animation.creation import *
|
||||||
from animation.indication import *
|
from .animation.indication import *
|
||||||
from animation.movement import *
|
from .animation.movement import *
|
||||||
from animation.numbers import *
|
from .animation.numbers import *
|
||||||
from animation.rotation import *
|
from .animation.rotation import *
|
||||||
from animation.specialized import *
|
from .animation.specialized import *
|
||||||
from animation.transform import *
|
from .animation.transform import *
|
||||||
from animation.update import *
|
from .animation.update import *
|
||||||
|
|
||||||
from camera.camera import *
|
from .camera.camera import *
|
||||||
from camera.mapping_camera import *
|
from .camera.mapping_camera import *
|
||||||
from camera.moving_camera import *
|
from .camera.moving_camera import *
|
||||||
from camera.three_d_camera import *
|
from .camera.three_d_camera import *
|
||||||
|
|
||||||
from continual_animation.continual_animation import *
|
from .continual_animation.continual_animation import *
|
||||||
from continual_animation.from_animation import *
|
from .continual_animation.from_animation import *
|
||||||
from continual_animation.numbers import *
|
from .continual_animation.numbers import *
|
||||||
from continual_animation.update import *
|
from .continual_animation.update import *
|
||||||
|
|
||||||
from mobject.frame import *
|
from .mobject.frame import *
|
||||||
from mobject.functions import *
|
from .mobject.functions import *
|
||||||
from mobject.geometry import *
|
from .mobject.geometry import *
|
||||||
from mobject.matrix import *
|
from .mobject.matrix import *
|
||||||
from mobject.mobject import *
|
from .mobject.mobject import *
|
||||||
from mobject.number_line import *
|
from .mobject.number_line import *
|
||||||
from mobject.numbers import *
|
from .mobject.numbers import *
|
||||||
from mobject.probability import *
|
from .mobject.probability import *
|
||||||
from mobject.shape_matchers import *
|
from .mobject.shape_matchers import *
|
||||||
from mobject.svg.brace import *
|
from .mobject.svg.brace import *
|
||||||
from mobject.svg.drawings import *
|
from .mobject.svg.drawings import *
|
||||||
from mobject.svg.svg_mobject import *
|
from .mobject.svg.svg_mobject import *
|
||||||
from mobject.svg.tex_mobject import *
|
from .mobject.svg.tex_mobject import *
|
||||||
from mobject.three_dimensions import *
|
from .mobject.three_dimensions import *
|
||||||
from mobject.types.image_mobject import *
|
from .mobject.types.image_mobject import *
|
||||||
from mobject.types.point_cloud_mobject import *
|
from .mobject.types.point_cloud_mobject import *
|
||||||
from mobject.types.vectorized_mobject import *
|
from .mobject.types.vectorized_mobject import *
|
||||||
from mobject.value_tracker import *
|
from .mobject.value_tracker import *
|
||||||
|
|
||||||
from for_3b1b_videos.common_scenes import *
|
from .for_3b1b_videos.common_scenes import *
|
||||||
from for_3b1b_videos.pi_creature import *
|
from .for_3b1b_videos.pi_creature import *
|
||||||
from for_3b1b_videos.pi_creature_animations import *
|
from .for_3b1b_videos.pi_creature_animations import *
|
||||||
from for_3b1b_videos.pi_creature_scene import *
|
from .for_3b1b_videos.pi_creature_scene import *
|
||||||
|
|
||||||
from once_useful_constructs.arithmetic import *
|
from .once_useful_constructs.arithmetic import *
|
||||||
from once_useful_constructs.combinatorics import *
|
from .once_useful_constructs.combinatorics import *
|
||||||
from once_useful_constructs.complex_transformation_scene import *
|
from .once_useful_constructs.complex_transformation_scene import *
|
||||||
from once_useful_constructs.counting import *
|
from .once_useful_constructs.counting import *
|
||||||
from once_useful_constructs.fractals import *
|
from .once_useful_constructs.fractals import *
|
||||||
from once_useful_constructs.graph_theory import *
|
from .once_useful_constructs.graph_theory import *
|
||||||
from once_useful_constructs.light import *
|
from .once_useful_constructs.light import *
|
||||||
|
|
||||||
from scene.graph_scene import *
|
from .scene.graph_scene import *
|
||||||
from scene.moving_camera_scene import *
|
from .scene.moving_camera_scene import *
|
||||||
from scene.reconfigurable_scene import *
|
from .scene.reconfigurable_scene import *
|
||||||
from scene.scene import *
|
from .scene.scene import *
|
||||||
from scene.sample_space_scene import *
|
from .scene.sample_space_scene import *
|
||||||
from scene.graph_scene import *
|
from .scene.graph_scene import *
|
||||||
from scene.scene_from_video import *
|
from .scene.scene_from_video import *
|
||||||
from scene.three_d_scene import *
|
from .scene.three_d_scene import *
|
||||||
from scene.vector_space_scene import *
|
from .scene.vector_space_scene import *
|
||||||
from scene.zoomed_scene import *
|
from .scene.zoomed_scene import *
|
||||||
|
|
||||||
from utils.bezier import *
|
from .utils.bezier import *
|
||||||
from utils.color import *
|
from .utils.color import *
|
||||||
from utils.config_ops import *
|
from .utils.config_ops import *
|
||||||
from utils.images import *
|
from .utils.images import *
|
||||||
from utils.iterables import *
|
from .utils.iterables import *
|
||||||
from utils.output_directory_getters import *
|
from .utils.output_directory_getters import *
|
||||||
from utils.paths import *
|
from .utils.paths import *
|
||||||
from utils.rate_functions import *
|
from .utils.rate_functions import *
|
||||||
from utils.simple_functions import *
|
from .utils.simple_functions import *
|
||||||
from utils.sounds import *
|
from .utils.sounds import *
|
||||||
from utils.space_ops import *
|
from .utils.space_ops import *
|
||||||
from utils.strings import *
|
from .utils.strings import *
|
||||||
|
|
||||||
# Non manim libraries that are also nice to have without thinking
|
# Non manim libraries that are also nice to have without thinking
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
import itertools as it
|
import itertools as it
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import operator as op
|
import operator as op
|
||||||
|
@ -24,6 +25,7 @@ from utils.iterables import list_difference_update
|
||||||
from utils.iterables import remove_list_redundancies
|
from utils.iterables import remove_list_redundancies
|
||||||
from utils.simple_functions import fdiv
|
from utils.simple_functions import fdiv
|
||||||
from utils.space_ops import angle_of_vector
|
from utils.space_ops import angle_of_vector
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
|
||||||
class Camera(object):
|
class Camera(object):
|
||||||
|
@ -173,14 +175,14 @@ class Camera(object):
|
||||||
pixel coordinates), and each output is expected to be an RGBA array of 4 floats.
|
pixel coordinates), and each output is expected to be an RGBA array of 4 floats.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print "Starting set_background; for reference, the current time is ", time.strftime("%H:%M:%S")
|
print("Starting set_background; for reference, the current time is ", time.strftime("%H:%M:%S"))
|
||||||
coords = self.get_coords_of_all_pixels()
|
coords = self.get_coords_of_all_pixels()
|
||||||
new_background = np.apply_along_axis(
|
new_background = np.apply_along_axis(
|
||||||
coords_to_colors_func,
|
coords_to_colors_func,
|
||||||
2,
|
2,
|
||||||
coords
|
coords
|
||||||
)
|
)
|
||||||
print "Ending set_background; for reference, the current time is ", time.strftime("%H:%M:%S")
|
print("Ending set_background; for reference, the current time is ", time.strftime("%H:%M:%S"))
|
||||||
|
|
||||||
return self.convert_pixel_array(new_background, convert_from_floats=True)
|
return self.convert_pixel_array(new_background, convert_from_floats=True)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from big_ol_pile_of_manim_imports import *
|
from __future__ import absolute_import
|
||||||
|
from .big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
# To watch one of these scenes, run the following:
|
# To watch one of these scenes, run the following:
|
||||||
# python extract_scene.py file_name <SceneName> -p
|
# python extract_scene.py file_name <SceneName> -p
|
||||||
|
@ -27,7 +28,7 @@ class WarpSquare(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
square = Square()
|
square = Square()
|
||||||
self.play(ApplyPointwiseFunction(
|
self.play(ApplyPointwiseFunction(
|
||||||
lambda (x, y, z): complex_to_R3(np.exp(complex(x, y))),
|
lambda x_y_z: complex_to_R3(np.exp(complex(x_y_z[0], x_y_z[1]))),
|
||||||
square
|
square
|
||||||
))
|
))
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import absolute_import
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import imp
|
import imp
|
||||||
|
@ -9,11 +11,11 @@ import os
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from constants import *
|
from .constants import *
|
||||||
|
|
||||||
from scene.scene import Scene
|
from .scene.scene import Scene
|
||||||
from utils.sounds import play_error_sound
|
from .utils.sounds import play_error_sound
|
||||||
from utils.sounds import play_finish_sound
|
from .utils.sounds import play_finish_sound
|
||||||
|
|
||||||
HELP_MESSAGE = """
|
HELP_MESSAGE = """
|
||||||
Usage:
|
Usage:
|
||||||
|
@ -74,7 +76,7 @@ def get_configuration():
|
||||||
args.output_name)
|
args.output_name)
|
||||||
expected_ext = '.png' if args.show_last_frame else '.mp4'
|
expected_ext = '.png' if args.show_last_frame else '.mp4'
|
||||||
if output_name_ext not in ['', expected_ext]:
|
if output_name_ext not in ['', expected_ext]:
|
||||||
print "WARNING: The output will be to (doubly-dotted) %s%s" % output_name_root % expected_ext
|
print("WARNING: The output will be to (doubly-dotted) %s%s" % output_name_root % expected_ext)
|
||||||
output_name = args.output_name
|
output_name = args.output_name
|
||||||
else:
|
else:
|
||||||
# If anyone wants .mp4.mp4 and is surprised to only get .mp4, or such... Well, too bad.
|
# If anyone wants .mp4.mp4 and is surprised to only get .mp4, or such... Well, too bad.
|
||||||
|
@ -261,7 +263,7 @@ def main():
|
||||||
|
|
||||||
scene_kwargs["name"] = config["output_name"]
|
scene_kwargs["name"] = config["output_name"]
|
||||||
if config["save_pngs"]:
|
if config["save_pngs"]:
|
||||||
print "We are going to save a PNG sequence as well..."
|
print("We are going to save a PNG sequence as well...")
|
||||||
scene_kwargs["save_pngs"] = True
|
scene_kwargs["save_pngs"] = True
|
||||||
scene_kwargs["pngs_mode"] = config["saved_image_mode"]
|
scene_kwargs["pngs_mode"] = config["saved_image_mode"]
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ class PiCreature(SVGMobject):
|
||||||
body = self.body
|
body = self.body
|
||||||
return VGroup(*[
|
return VGroup(*[
|
||||||
body.copy().pointwise_become_partial(body, *alpha_range)
|
body.copy().pointwise_become_partial(body, *alpha_range)
|
||||||
for alpha_range in self.right_arm_range, self.left_arm_range
|
for alpha_range in (self.right_arm_range, self.left_arm_range)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import itertools as it
|
import itertools as it
|
||||||
|
@ -21,6 +22,7 @@ from utils.paths import straight_path
|
||||||
from utils.space_ops import angle_of_vector
|
from utils.space_ops import angle_of_vector
|
||||||
from utils.space_ops import complex_to_R3
|
from utils.space_ops import complex_to_R3
|
||||||
from utils.space_ops import rotation_matrix
|
from utils.space_ops import rotation_matrix
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
|
||||||
# TODO: Explain array_attrs
|
# TODO: Explain array_attrs
|
||||||
|
@ -224,7 +226,7 @@ class Mobject(Container):
|
||||||
|
|
||||||
def apply_complex_function(self, function, **kwargs):
|
def apply_complex_function(self, function, **kwargs):
|
||||||
return self.apply_function(
|
return self.apply_function(
|
||||||
lambda (x, y, z): complex_to_R3(function(complex(x, y))),
|
lambda x_y_z: complex_to_R3(function(complex(x_y_z[0], x_y_z[1]))),
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -807,7 +809,7 @@ class Mobject(Container):
|
||||||
|
|
||||||
def print_submobject_family(self, n_tabs=0):
|
def print_submobject_family(self, n_tabs=0):
|
||||||
"""For debugging purposes"""
|
"""For debugging purposes"""
|
||||||
print "\t" * n_tabs, self, id(self)
|
print("\t" * n_tabs, self, id(self))
|
||||||
for submob in self.submobjects:
|
for submob in self.submobjects:
|
||||||
submob.print_submobject_family(n_tabs + 1)
|
submob.print_submobject_family(n_tabs + 1)
|
||||||
|
|
||||||
|
@ -843,7 +845,7 @@ class Mobject(Container):
|
||||||
# push it into its submobject list
|
# push it into its submobject list
|
||||||
self_has_points, mob_has_points = [
|
self_has_points, mob_has_points = [
|
||||||
mob.get_num_points() > 0
|
mob.get_num_points() > 0
|
||||||
for mob in self, mobject
|
for mob in (self, mobject)
|
||||||
]
|
]
|
||||||
if self_has_points and not mob_has_points:
|
if self_has_points and not mob_has_points:
|
||||||
mobject.null_point_align(self)
|
mobject.null_point_align(self)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import operator as op
|
||||||
|
|
||||||
from mobject.svg.tex_mobject import SingleStringTexMobject
|
from mobject.svg.tex_mobject import SingleStringTexMobject
|
||||||
from mobject.types.vectorized_mobject import VMobject
|
from mobject.types.vectorized_mobject import VMobject
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
|
||||||
class DecimalNumber(VMobject):
|
class DecimalNumber(VMobject):
|
||||||
|
|
|
@ -143,7 +143,7 @@ class SVGMobject(VMobject):
|
||||||
float(circle_element.getAttribute(key))
|
float(circle_element.getAttribute(key))
|
||||||
if circle_element.hasAttribute(key)
|
if circle_element.hasAttribute(key)
|
||||||
else 0.0
|
else 0.0
|
||||||
for key in "cx", "cy", "r"
|
for key in ("cx", "cy", "r")
|
||||||
]
|
]
|
||||||
return Circle(radius=r).shift(x * RIGHT + y * DOWN)
|
return Circle(radius=r).shift(x * RIGHT + y * DOWN)
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ class SVGMobject(VMobject):
|
||||||
float(circle_element.getAttribute(key))
|
float(circle_element.getAttribute(key))
|
||||||
if circle_element.hasAttribute(key)
|
if circle_element.hasAttribute(key)
|
||||||
else 0.0
|
else 0.0
|
||||||
for key in "cx", "cy", "rx", "ry"
|
for key in ("cx", "cy", "rx", "ry")
|
||||||
]
|
]
|
||||||
return Circle().scale(rx * RIGHT + ry * UP).shift(x * RIGHT + y * DOWN)
|
return Circle().scale(rx * RIGHT + ry * UP).shift(x * RIGHT + y * DOWN)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
from constants import *
|
from constants import *
|
||||||
|
|
||||||
from svg_mobject import SVGMobject
|
from .svg_mobject import SVGMobject
|
||||||
from svg_mobject import VMobjectFromSVGPathstring
|
from .svg_mobject import VMobjectFromSVGPathstring
|
||||||
from utils.config_ops import digest_config
|
from utils.config_ops import digest_config
|
||||||
from utils.strings import split_string_list_to_isolate_substring
|
from utils.strings import split_string_list_to_isolate_substring
|
||||||
from utils.tex_file_writing import tex_to_svg_file
|
from utils.tex_file_writing import tex_to_svg_file
|
||||||
|
@ -10,6 +11,7 @@ from mobject.types.vectorized_mobject import VGroup
|
||||||
from mobject.types.vectorized_mobject import VectorizedPoint
|
from mobject.types.vectorized_mobject import VectorizedPoint
|
||||||
|
|
||||||
import operator as op
|
import operator as op
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
TEX_MOB_SCALE_FACTOR = 0.05
|
TEX_MOB_SCALE_FACTOR = 0.05
|
||||||
|
|
||||||
|
@ -92,7 +94,7 @@ class SingleStringTexMobject(SVGMobject):
|
||||||
lambda s: s[0] in "(){}[]|.\\",
|
lambda s: s[0] in "(){}[]|.\\",
|
||||||
tex.split(substr)[1:]
|
tex.split(substr)[1:]
|
||||||
))
|
))
|
||||||
for substr in "\\left", "\\right"
|
for substr in ("\\left", "\\right")
|
||||||
]
|
]
|
||||||
if num_lefts != num_rights:
|
if num_lefts != num_rights:
|
||||||
tex = tex.replace("\\left", "\\big")
|
tex = tex.replace("\\left", "\\big")
|
||||||
|
|
|
@ -164,7 +164,7 @@ class PMobject(Mobject):
|
||||||
def pointwise_become_partial(self, mobject, a, b):
|
def pointwise_become_partial(self, mobject, a, b):
|
||||||
lower_index, upper_index = [
|
lower_index, upper_index = [
|
||||||
int(x * mobject.get_num_points())
|
int(x * mobject.get_num_points())
|
||||||
for x in a, b
|
for x in (a, b)
|
||||||
]
|
]
|
||||||
for attr in self.get_array_attrs():
|
for attr in self.get_array_attrs():
|
||||||
full_array = getattr(mobject, attr)
|
full_array = getattr(mobject, attr)
|
||||||
|
|
|
@ -209,7 +209,7 @@ class VMobject(Mobject):
|
||||||
points = np.array(points)
|
points = np.array(points)
|
||||||
self.set_anchors_and_handles(points, *[
|
self.set_anchors_and_handles(points, *[
|
||||||
interpolate(points[:-1], points[1:], alpha)
|
interpolate(points[:-1], points[1:], alpha)
|
||||||
for alpha in 1. / 3, 2. / 3
|
for alpha in (1. / 3, 2. / 3)
|
||||||
])
|
])
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
@ -60,16 +61,18 @@ def rev_to_rgba(alpha):
|
||||||
def rev_to_color(alpha):
|
def rev_to_color(alpha):
|
||||||
return rgba_to_color(rev_to_rgba(alpha))
|
return rgba_to_color(rev_to_rgba(alpha))
|
||||||
|
|
||||||
def point_to_rev((x, y), allow_origin = False):
|
def point_to_rev(xxx_todo_changeme6, allow_origin = False):
|
||||||
# Warning: np.arctan2 would happily discontinuously returns the value 0 for (0, 0), due to
|
# Warning: np.arctan2 would happily discontinuously returns the value 0 for (0, 0), due to
|
||||||
# design choices in the underlying atan2 library call, but for our purposes, this is
|
# design choices in the underlying atan2 library call, but for our purposes, this is
|
||||||
# illegitimate, and all winding number calculations must be set up to avoid this
|
# illegitimate, and all winding number calculations must be set up to avoid this
|
||||||
|
(x, y) = xxx_todo_changeme6
|
||||||
if not(allow_origin) and (x, y) == (0, 0):
|
if not(allow_origin) and (x, y) == (0, 0):
|
||||||
print "Error! Angle of (0, 0) computed!"
|
print("Error! Angle of (0, 0) computed!")
|
||||||
return
|
return
|
||||||
return fdiv(np.arctan2(y, x), TAU)
|
return fdiv(np.arctan2(y, x), TAU)
|
||||||
|
|
||||||
def point_to_size((x, y)):
|
def point_to_size(xxx_todo_changeme7):
|
||||||
|
(x, y) = xxx_todo_changeme7
|
||||||
return np.sqrt(x**2 + y**2)
|
return np.sqrt(x**2 + y**2)
|
||||||
|
|
||||||
# rescaled_size goes from 0 to 1 as size goes from 0 to infinity
|
# rescaled_size goes from 0 to 1 as size goes from 0 to infinity
|
||||||
|
@ -137,8 +140,8 @@ class EquationSolver1d(GraphScene, ZoomedScene):
|
||||||
if self.show_target_line:
|
if self.show_target_line:
|
||||||
self.play(FadeOut(target_line_label)) # Reduce clutter
|
self.play(FadeOut(target_line_label)) # Reduce clutter
|
||||||
|
|
||||||
print "For reference, graphOrigin: ", self.coords_to_point(0, 0)
|
print("For reference, graphOrigin: ", self.coords_to_point(0, 0))
|
||||||
print "targetYPoint: ", self.coords_to_point(0, self.targetY)
|
print("targetYPoint: ", self.coords_to_point(0, self.targetY))
|
||||||
|
|
||||||
# This is a mess right now (first major animation coded),
|
# This is a mess right now (first major animation coded),
|
||||||
# but it works; can be refactored later or never
|
# but it works; can be refactored later or never
|
||||||
|
@ -439,10 +442,11 @@ def complex_to_pair(c):
|
||||||
return np.array((c.real, c.imag))
|
return np.array((c.real, c.imag))
|
||||||
|
|
||||||
def plane_func_from_complex_func(f):
|
def plane_func_from_complex_func(f):
|
||||||
return lambda (x, y) : complex_to_pair(f(complex(x,y)))
|
return lambda x_y4 : complex_to_pair(f(complex(x_y4[0],x_y4[1])))
|
||||||
|
|
||||||
def point3d_func_from_plane_func(f):
|
def point3d_func_from_plane_func(f):
|
||||||
def g((x, y, z)):
|
def g(xxx_todo_changeme):
|
||||||
|
(x, y, z) = xxx_todo_changeme
|
||||||
f_val = f((x, y))
|
f_val = f((x, y))
|
||||||
return np.array((f_val[0], f_val[1], 0))
|
return np.array((f_val[0], f_val[1], 0))
|
||||||
return g
|
return g
|
||||||
|
@ -450,7 +454,8 @@ def point3d_func_from_plane_func(f):
|
||||||
def point3d_func_from_complex_func(f):
|
def point3d_func_from_complex_func(f):
|
||||||
return point3d_func_from_plane_func(plane_func_from_complex_func(f))
|
return point3d_func_from_plane_func(plane_func_from_complex_func(f))
|
||||||
|
|
||||||
def plane_zeta((x, y)):
|
def plane_zeta(xxx_todo_changeme8):
|
||||||
|
(x, y) = xxx_todo_changeme8
|
||||||
CLAMP_SIZE = 1000
|
CLAMP_SIZE = 1000
|
||||||
z = complex(x, y)
|
z = complex(x, y)
|
||||||
try:
|
try:
|
||||||
|
@ -461,7 +466,8 @@ def plane_zeta((x, y)):
|
||||||
answer = answer/abs(answer) * CLAMP_SIZE
|
answer = answer/abs(answer) * CLAMP_SIZE
|
||||||
return (float(answer.real), float(answer.imag))
|
return (float(answer.real), float(answer.imag))
|
||||||
|
|
||||||
def rescaled_plane_zeta((x, y)):
|
def rescaled_plane_zeta(xxx_todo_changeme9):
|
||||||
|
(x, y) = xxx_todo_changeme9
|
||||||
return plane_zeta((x/FRAME_X_RADIUS, 8*y))
|
return plane_zeta((x/FRAME_X_RADIUS, 8*y))
|
||||||
|
|
||||||
# Returns a function from 2-ples to 2-ples
|
# Returns a function from 2-ples to 2-ples
|
||||||
|
@ -476,13 +482,13 @@ def plane_func_by_wind_spec(*specs):
|
||||||
elif len(p) == 2:
|
elif len(p) == 2:
|
||||||
return (p[0], p[1], 1)
|
return (p[0], p[1], 1)
|
||||||
else:
|
else:
|
||||||
print "Error in plane_func_by_wind_spec embiggen!"
|
print("Error in plane_func_by_wind_spec embiggen!")
|
||||||
specs = map(embiggen, specs)
|
specs = map(embiggen, specs)
|
||||||
|
|
||||||
pos_specs = filter(lambda (x, y, z) : z > 0, specs)
|
pos_specs = filter(lambda x_y_z : x_y_z[2] > 0, specs)
|
||||||
neg_specs = filter(lambda (x, y, z) : z < 0, specs)
|
neg_specs = filter(lambda x_y_z1 : x_y_z1[2] < 0, specs)
|
||||||
|
|
||||||
neg_specs_made_pos = map (lambda (x, y, z) : (x, y, -z), neg_specs)
|
neg_specs_made_pos = map (lambda x_y_z2 : (x_y_z2[0], x_y_z2[1], -x_y_z2[2]), neg_specs)
|
||||||
|
|
||||||
def poly(c, root_specs):
|
def poly(c, root_specs):
|
||||||
return np.prod([(c - complex(x, y))**z for (x, y, z) in root_specs])
|
return np.prod([(c - complex(x, y))**z for (x, y, z) in root_specs])
|
||||||
|
@ -651,8 +657,8 @@ class ColorMappedByFuncScene(Scene):
|
||||||
self.input_to_pos_func = lambda p : p
|
self.input_to_pos_func = lambda p : p
|
||||||
self.pos_to_color_func = self.func
|
self.pos_to_color_func = self.func
|
||||||
|
|
||||||
self.pixel_pos_to_color_func = lambda (x, y) : self.pos_to_color_func(
|
self.pixel_pos_to_color_func = lambda x_y3 : self.pos_to_color_func(
|
||||||
self.num_plane.point_to_coords_cheap(np.array([x, y, 0]))
|
self.num_plane.point_to_coords_cheap(np.array([x_y3[0], x_y3[1], 0]))
|
||||||
)
|
)
|
||||||
|
|
||||||
jitter_val = 0.1
|
jitter_val = 0.1
|
||||||
|
@ -661,7 +667,7 @@ class ColorMappedByFuncScene(Scene):
|
||||||
def mini_hasher(p):
|
def mini_hasher(p):
|
||||||
rgba = point_to_rgba(self.pixel_pos_to_color_func(p))
|
rgba = point_to_rgba(self.pixel_pos_to_color_func(p))
|
||||||
if rgba[3] != 1.0:
|
if rgba[3] != 1.0:
|
||||||
print "Warning! point_to_rgba assigns fractional alpha", rgba[3]
|
print("Warning! point_to_rgba assigns fractional alpha", rgba[3])
|
||||||
return tuple(rgba)
|
return tuple(rgba)
|
||||||
to_hash = tuple(mini_hasher(p) for p in func_hash_points)
|
to_hash = tuple(mini_hasher(p) for p in func_hash_points)
|
||||||
func_hash = hash(to_hash)
|
func_hash = hash(to_hash)
|
||||||
|
@ -674,18 +680,18 @@ class ColorMappedByFuncScene(Scene):
|
||||||
)
|
)
|
||||||
self.in_background_pass = not os.path.exists(self.background_image_file)
|
self.in_background_pass = not os.path.exists(self.background_image_file)
|
||||||
|
|
||||||
print "Background file: " + self.background_image_file
|
print("Background file: " + self.background_image_file)
|
||||||
if self.in_background_pass:
|
if self.in_background_pass:
|
||||||
print "The background file does not exist yet; this will be a background creation + video pass"
|
print("The background file does not exist yet; this will be a background creation + video pass")
|
||||||
else:
|
else:
|
||||||
print "The background file already exists; this will only be a video pass"
|
print("The background file already exists; this will only be a video pass")
|
||||||
|
|
||||||
def construct(self):
|
def construct(self):
|
||||||
if self.in_background_pass:
|
if self.in_background_pass:
|
||||||
self.camera.set_background_from_func(
|
self.camera.set_background_from_func(
|
||||||
lambda (x, y): point_to_rgba(
|
lambda x_y: point_to_rgba(
|
||||||
self.pixel_pos_to_color_func(
|
self.pixel_pos_to_color_func(
|
||||||
(x, y)
|
(x_y[0], x_y[1])
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -863,7 +869,8 @@ class PiWalkerCircle(PiWalker):
|
||||||
self.walk_coords = [r * np.array((np.cos(i * TAU/N), np.sin(i * TAU/N))) for i in range(N)]
|
self.walk_coords = [r * np.array((np.cos(i * TAU/N), np.sin(i * TAU/N))) for i in range(N)]
|
||||||
PiWalker.setup(self)
|
PiWalker.setup(self)
|
||||||
|
|
||||||
def split_interval((a, b)):
|
def split_interval(xxx_todo_changeme10):
|
||||||
|
(a, b) = xxx_todo_changeme10
|
||||||
mid = (a + b)/2.0
|
mid = (a + b)/2.0
|
||||||
return ((a, mid), (mid, b))
|
return ((a, mid), (mid, b))
|
||||||
|
|
||||||
|
@ -915,7 +922,7 @@ class RectangleData():
|
||||||
elif dim == 1:
|
elif dim == 1:
|
||||||
return_data = [RectangleData(x_interval, new_interval) for new_interval in split_interval(y_interval)[::-1]]
|
return_data = [RectangleData(x_interval, new_interval) for new_interval in split_interval(y_interval)[::-1]]
|
||||||
else:
|
else:
|
||||||
print "RectangleData.splits_on_dim passed illegitimate dimension!"
|
print("RectangleData.splits_on_dim passed illegitimate dimension!")
|
||||||
|
|
||||||
return tuple(return_data)
|
return tuple(return_data)
|
||||||
|
|
||||||
|
@ -928,7 +935,7 @@ class RectangleData():
|
||||||
elif dim == 1:
|
elif dim == 1:
|
||||||
sides = (self.get_left(), self.get_right())
|
sides = (self.get_left(), self.get_right())
|
||||||
else:
|
else:
|
||||||
print "RectangleData.split_line_on_dim passed illegitimate dimension!"
|
print("RectangleData.split_line_on_dim passed illegitimate dimension!")
|
||||||
|
|
||||||
return tuple([mid(x, y) for (x, y) in sides])
|
return tuple([mid(x, y) for (x, y) in sides])
|
||||||
|
|
||||||
|
@ -973,10 +980,10 @@ class EquationSolver2dNode(object):
|
||||||
|
|
||||||
def play_in_bfs(self, scene, border_anim):
|
def play_in_bfs(self, scene, border_anim):
|
||||||
bfs_nodes = self.hacky_bfs()
|
bfs_nodes = self.hacky_bfs()
|
||||||
print "Number of nodes: ", len(bfs_nodes)
|
print("Number of nodes: ", len(bfs_nodes))
|
||||||
|
|
||||||
if len(bfs_nodes) < 1:
|
if len(bfs_nodes) < 1:
|
||||||
print "Less than 1 node! Aborting!"
|
print("Less than 1 node! Aborting!")
|
||||||
return
|
return
|
||||||
|
|
||||||
scene.play(bfs_nodes[0].first_anim, border_anim)
|
scene.play(bfs_nodes[0].first_anim, border_anim)
|
||||||
|
@ -1029,7 +1036,7 @@ class EquationSolver2d(ColorMappedObjectsScene):
|
||||||
|
|
||||||
def construct(self):
|
def construct(self):
|
||||||
if self.num_iterations == 0:
|
if self.num_iterations == 0:
|
||||||
print "You forgot to set num_iterations (maybe you meant to subclass something other than EquationSolver2d directly?)"
|
print("You forgot to set num_iterations (maybe you meant to subclass something other than EquationSolver2d directly?)")
|
||||||
return
|
return
|
||||||
|
|
||||||
ColorMappedObjectsScene.construct(self)
|
ColorMappedObjectsScene.construct(self)
|
||||||
|
@ -1071,7 +1078,7 @@ class EquationSolver2d(ColorMappedObjectsScene):
|
||||||
def Animate2dSolver(cur_depth, rect, dim_to_split,
|
def Animate2dSolver(cur_depth, rect, dim_to_split,
|
||||||
sides_to_draw = [0, 1, 2, 3],
|
sides_to_draw = [0, 1, 2, 3],
|
||||||
manual_wind_override = None):
|
manual_wind_override = None):
|
||||||
print "Solver at depth: " + str(cur_depth)
|
print("Solver at depth: " + str(cur_depth))
|
||||||
|
|
||||||
if cur_depth >= self.num_iterations:
|
if cur_depth >= self.num_iterations:
|
||||||
return EquationSolver2dNode(empty_animation)
|
return EquationSolver2dNode(empty_animation)
|
||||||
|
@ -1195,7 +1202,7 @@ class EquationSolver2d(ColorMappedObjectsScene):
|
||||||
|
|
||||||
rect = RectangleData(x_interval, y_interval)
|
rect = RectangleData(x_interval, y_interval)
|
||||||
|
|
||||||
print "Starting to compute anim"
|
print("Starting to compute anim")
|
||||||
|
|
||||||
node = Animate2dSolver(
|
node = Animate2dSolver(
|
||||||
cur_depth = 0,
|
cur_depth = 0,
|
||||||
|
@ -1205,7 +1212,7 @@ class EquationSolver2d(ColorMappedObjectsScene):
|
||||||
manual_wind_override = self.manual_wind_override
|
manual_wind_override = self.manual_wind_override
|
||||||
)
|
)
|
||||||
|
|
||||||
print "Done computing anim"
|
print("Done computing anim")
|
||||||
|
|
||||||
if self.display_in_parallel:
|
if self.display_in_parallel:
|
||||||
anim = node.display_in_parallel()
|
anim = node.display_in_parallel()
|
||||||
|
@ -1241,14 +1248,14 @@ class EquationSolver2d(ColorMappedObjectsScene):
|
||||||
rate_func = rect_rate
|
rate_func = rect_rate
|
||||||
)
|
)
|
||||||
|
|
||||||
print "About to do the big Play; for reference, the current time is ", time.strftime("%H:%M:%S")
|
print("About to do the big Play; for reference, the current time is ", time.strftime("%H:%M:%S"))
|
||||||
|
|
||||||
if self.use_separate_plays:
|
if self.use_separate_plays:
|
||||||
node.play_in_bfs(self, border_anim)
|
node.play_in_bfs(self, border_anim)
|
||||||
else:
|
else:
|
||||||
self.play(anim, border_anim)
|
self.play(anim, border_anim)
|
||||||
|
|
||||||
print "All done; for reference, the current time is ", time.strftime("%H:%M:%S")
|
print("All done; for reference, the current time is ", time.strftime("%H:%M:%S"))
|
||||||
|
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
|
@ -1712,7 +1719,7 @@ class Initial2dFuncSceneBase(Scene):
|
||||||
}
|
}
|
||||||
|
|
||||||
def show_planes(self):
|
def show_planes(self):
|
||||||
print "Error! Unimplemented (pure virtual) show_planes"
|
print("Error! Unimplemented (pure virtual) show_planes")
|
||||||
|
|
||||||
def shared_construct(self):
|
def shared_construct(self):
|
||||||
points = [LEFT + DOWN, RIGHT + DOWN, LEFT + UP, RIGHT + UP]
|
points = [LEFT + DOWN, RIGHT + DOWN, LEFT + UP, RIGHT + UP]
|
||||||
|
@ -2414,7 +2421,7 @@ class BorderOf2dRegionScene(Scene):
|
||||||
border = Polygon(*points, color = negative_color, stroke_width = border_stroke_width)
|
border = Polygon(*points, color = negative_color, stroke_width = border_stroke_width)
|
||||||
self.play(ShowCreation(border))
|
self.play(ShowCreation(border))
|
||||||
|
|
||||||
big_loop_no_zeros_func = lambda (x, y) : complex_to_pair(np.exp(complex(10, y * np.pi)))
|
big_loop_no_zeros_func = lambda x_y5 : complex_to_pair(np.exp(complex(10, x_y5[1] * np.pi)))
|
||||||
|
|
||||||
class BigLoopNoZeros(ColorMappedObjectsScene):
|
class BigLoopNoZeros(ColorMappedObjectsScene):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
|
@ -2539,7 +2546,8 @@ class TinyLoopOfBasicallySameColor(PureColorMap):
|
||||||
self.play(ShowCreation(circle))
|
self.play(ShowCreation(circle))
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
def uhOhFunc((x, y)):
|
def uhOhFunc(xxx_todo_changeme11):
|
||||||
|
(x, y) = xxx_todo_changeme11
|
||||||
x = -np.clip(x, -5, 5)/5
|
x = -np.clip(x, -5, 5)/5
|
||||||
y = -np.clip(y, -3, 3)/3
|
y = -np.clip(y, -3, 3)/3
|
||||||
|
|
||||||
|
@ -2648,7 +2656,8 @@ class UhOhSalientStill(ColorMappedObjectsScene):
|
||||||
|
|
||||||
# Random test scenes and test functions go here:
|
# Random test scenes and test functions go here:
|
||||||
|
|
||||||
def rect_to_circle((x, y, z)):
|
def rect_to_circle(xxx_todo_changeme12):
|
||||||
|
(x, y, z) = xxx_todo_changeme12
|
||||||
size = np.sqrt(x**2 + y**2)
|
size = np.sqrt(x**2 + y**2)
|
||||||
max_abs_size = max(abs(x), abs(y))
|
max_abs_size = max(abs(x), abs(y))
|
||||||
return fdiv(np.array((x, y, z)) * max_abs_size, size)
|
return fdiv(np.array((x, y, z)) * max_abs_size, size)
|
||||||
|
@ -2725,7 +2734,7 @@ class SpecifiedWinder(PiWalker):
|
||||||
cur_pos += (self.step_size, 0)
|
cur_pos += (self.step_size, 0)
|
||||||
mid_rev = rev_func(cur_pos)
|
mid_rev = rev_func(cur_pos)
|
||||||
|
|
||||||
print "Reached ", cur_pos, ", with rev ", mid_rev - start_rev
|
print("Reached ", cur_pos, ", with rev ", mid_rev - start_rev)
|
||||||
mid_pos = cur_pos.copy()
|
mid_pos = cur_pos.copy()
|
||||||
|
|
||||||
end_rev = mid_rev
|
end_rev = mid_rev
|
||||||
|
@ -2735,10 +2744,10 @@ class SpecifiedWinder(PiWalker):
|
||||||
|
|
||||||
end_pos = cur_pos.copy()
|
end_pos = cur_pos.copy()
|
||||||
|
|
||||||
print "Reached ", cur_pos, ", with rev ", end_rev - mid_rev
|
print("Reached ", cur_pos, ", with rev ", end_rev - mid_rev)
|
||||||
|
|
||||||
self.walk_coords = [start_pos, mid_pos, end_pos]
|
self.walk_coords = [start_pos, mid_pos, end_pos]
|
||||||
print "Walk coords: ", self.walk_coords
|
print("Walk coords: ", self.walk_coords)
|
||||||
PiWalker.setup(self)
|
PiWalker.setup(self)
|
||||||
|
|
||||||
class OneFifthTwoFifthWinder(SpecifiedWinder):
|
class OneFifthTwoFifthWinder(SpecifiedWinder):
|
||||||
|
|
|
@ -236,7 +236,7 @@ class Introduce1DFunctionCase(Scene):
|
||||||
axes.coords_to_point(x, 0),
|
axes.coords_to_point(x, 0),
|
||||||
axes.coords_to_point(x, f_graph.underlying_function(solution)),
|
axes.coords_to_point(x, f_graph.underlying_function(solution)),
|
||||||
)
|
)
|
||||||
for x in axes.x_min, axes.x_max, solution
|
for x in (axes.x_min, axes.x_max, solution)
|
||||||
]
|
]
|
||||||
|
|
||||||
equation = TexMobject("f(x)", "=", "g(x)")
|
equation = TexMobject("f(x)", "=", "g(x)")
|
||||||
|
@ -1408,7 +1408,7 @@ class Rearrange2DEquation(AltTeacherStudentsScene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
f_tex, g_tex, h_tex = [
|
f_tex, g_tex, h_tex = [
|
||||||
"%s(\\text{2d point})"%char
|
"%s(\\text{2d point})"%char
|
||||||
for char in "f", "g", "h"
|
for char in ("f", "g", "h")
|
||||||
]
|
]
|
||||||
zero_tex = "\\vec{\\textbf{0}}"
|
zero_tex = "\\vec{\\textbf{0}}"
|
||||||
equations = VGroup(
|
equations = VGroup(
|
||||||
|
@ -2100,7 +2100,7 @@ class PathContainingZero(InputOutputScene, PiCreatureScene):
|
||||||
morty.change, "pondering",
|
morty.change, "pondering",
|
||||||
*[
|
*[
|
||||||
ShowCreation(mob, rate_func = bezier([0, 0, 1, 1]))
|
ShowCreation(mob, rate_func = bezier([0, 0, 1, 1]))
|
||||||
for mob in path, out_path
|
for mob in (path, out_path)
|
||||||
],
|
],
|
||||||
run_time = 5
|
run_time = 5
|
||||||
)
|
)
|
||||||
|
@ -2272,7 +2272,7 @@ class TransitionFromPathsToBoundaries(ColorMappedObjectsScene):
|
||||||
def get_squares_and_joint_rect(self):
|
def get_squares_and_joint_rect(self):
|
||||||
squares = VGroup(*[
|
squares = VGroup(*[
|
||||||
Square(side_length = 4).next_to(ORIGIN, vect, buff = 0)
|
Square(side_length = 4).next_to(ORIGIN, vect, buff = 0)
|
||||||
for vect in LEFT, RIGHT
|
for vect in (LEFT, RIGHT)
|
||||||
])
|
])
|
||||||
joint_rect = SurroundingRectangle(squares, buff = 0)
|
joint_rect = SurroundingRectangle(squares, buff = 0)
|
||||||
for mob in it.chain(squares, [joint_rect]):
|
for mob in it.chain(squares, [joint_rect]):
|
||||||
|
@ -2293,7 +2293,7 @@ class TransitionFromPathsToBoundaries(ColorMappedObjectsScene):
|
||||||
rev = (get_output_rev() - self.start_rev)%1
|
rev = (get_output_rev() - self.start_rev)%1
|
||||||
possible_windings = [
|
possible_windings = [
|
||||||
np.floor(self.curr_winding)+k+rev
|
np.floor(self.curr_winding)+k+rev
|
||||||
for k in -1, 0, 1
|
for k in (-1, 0, 1)
|
||||||
]
|
]
|
||||||
i = np.argmin([abs(pw - self.curr_winding) for pw in possible_windings])
|
i = np.argmin([abs(pw - self.curr_winding) for pw in possible_windings])
|
||||||
self.curr_winding = possible_windings[i]
|
self.curr_winding = possible_windings[i]
|
||||||
|
@ -2369,7 +2369,7 @@ class BreakDownLoopWithNonzeroWinding(TransitionFromPathsToBoundaries):
|
||||||
both_cannot_be_zero.to_edge(UP)
|
both_cannot_be_zero.to_edge(UP)
|
||||||
arrows = VGroup(*[
|
arrows = VGroup(*[
|
||||||
Arrow(both_cannot_be_zero.get_bottom(), var.get_top(), buff = SMALL_BUFF)
|
Arrow(both_cannot_be_zero.get_bottom(), var.get_top(), buff = SMALL_BUFF)
|
||||||
for var in x, y
|
for var in (x, y)
|
||||||
])
|
])
|
||||||
|
|
||||||
self.position_dot(joint_rect.points[0])
|
self.position_dot(joint_rect.points[0])
|
||||||
|
@ -2579,7 +2579,7 @@ class PolynomialTerms(MonomialTerm):
|
||||||
background_image_file = self.input_coloring.background_image_file ,
|
background_image_file = self.input_coloring.background_image_file ,
|
||||||
stroke_width = 4,
|
stroke_width = 4,
|
||||||
)
|
)
|
||||||
for u in -1, 1
|
for u in (-1, 1)
|
||||||
]
|
]
|
||||||
out_line = line.copy()
|
out_line = line.copy()
|
||||||
update_out_line = UpdateFromFunc(
|
update_out_line = UpdateFromFunc(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
from once_useful_constructs.light import *
|
from once_useful_constructs.light import *
|
||||||
|
@ -147,7 +148,7 @@ class LightIndicator(VMobject):
|
||||||
|
|
||||||
def continual_update(self):
|
def continual_update(self):
|
||||||
if self.light_source == None:
|
if self.light_source == None:
|
||||||
print "Indicator cannot update, reason: no light source found"
|
print("Indicator cannot update, reason: no light source found")
|
||||||
self.set_intensity(self.measured_intensity())
|
self.set_intensity(self.measured_intensity())
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,9 +177,9 @@ class ContinualLightIndicatorUpdate(ContinualAnimation):
|
||||||
|
|
||||||
def copy_func(f):
|
def copy_func(f):
|
||||||
"""Based on http://stackoverflow.com/a/6528148/190597 (Glenn Maynard)"""
|
"""Based on http://stackoverflow.com/a/6528148/190597 (Glenn Maynard)"""
|
||||||
g = types.FunctionType(f.func_code, f.func_globals, name=f.func_name,
|
g = types.FunctionType(f.__code__, f.__globals__, name=f.__name__,
|
||||||
argdefs=f.func_defaults,
|
argdefs=f.__defaults__,
|
||||||
closure=f.func_closure)
|
closure=f.__closure__)
|
||||||
g = functools.update_wrapper(g, f)
|
g = functools.update_wrapper(g, f)
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
@ -2552,7 +2553,7 @@ class InscribedAngleScene(ThreeDScene):
|
||||||
show_animation = (onscreen_old or onscreen_1 or onscreen_2)
|
show_animation = (onscreen_old or onscreen_1 or onscreen_2)
|
||||||
|
|
||||||
if show_animation:
|
if show_animation:
|
||||||
print "animating (", i, ",", step, ")"
|
print("animating (", i, ",", step, ")")
|
||||||
self.play(
|
self.play(
|
||||||
ApplyMethod(ls1.move_source_to,ls_new_loc1, run_time = run_time),
|
ApplyMethod(ls1.move_source_to,ls_new_loc1, run_time = run_time),
|
||||||
ApplyMethod(ls2.move_source_to,ls_new_loc2, run_time = run_time),
|
ApplyMethod(ls2.move_source_to,ls_new_loc2, run_time = run_time),
|
||||||
|
@ -3333,7 +3334,7 @@ class PondScene(ThreeDScene):
|
||||||
show_animation = (onscreen_old or onscreen_1 or onscreen_2)
|
show_animation = (onscreen_old or onscreen_1 or onscreen_2)
|
||||||
|
|
||||||
if show_animation or animate:
|
if show_animation or animate:
|
||||||
print "animating (", i, ",", step, ")"
|
print("animating (", i, ",", step, ")")
|
||||||
self.play(
|
self.play(
|
||||||
ApplyMethod(ls1.move_source_to,ls_new_loc1, run_time = run_time),
|
ApplyMethod(ls1.move_source_to,ls_new_loc1, run_time = run_time),
|
||||||
ApplyMethod(ls2.move_source_to,ls_new_loc2, run_time = run_time),
|
ApplyMethod(ls2.move_source_to,ls_new_loc2, run_time = run_time),
|
||||||
|
@ -3671,7 +3672,7 @@ class PondScene(ThreeDScene):
|
||||||
self.play(FadeOut(self.inner_lake))
|
self.play(FadeOut(self.inner_lake))
|
||||||
|
|
||||||
for n in range(3,max_it + 1):
|
for n in range(3,max_it + 1):
|
||||||
print "working on n = ", n, "..."
|
print("working on n = ", n, "...")
|
||||||
new_lake = self.outer_lake.copy().scale(2,about_point = self.obs_dot.get_center())
|
new_lake = self.outer_lake.copy().scale(2,about_point = self.obs_dot.get_center())
|
||||||
for (i,ls) in enumerate(self.light_sources_array[:2**n]):
|
for (i,ls) in enumerate(self.light_sources_array[:2**n]):
|
||||||
#print i
|
#print i
|
||||||
|
@ -3702,14 +3703,14 @@ class PondScene(ThreeDScene):
|
||||||
onscreen_2 = np.all(np.abs(pos2[:2]) < 10 * 2**2)
|
onscreen_2 = np.all(np.abs(pos2[:2]) < 10 * 2**2)
|
||||||
|
|
||||||
if onscreen_old or onscreen_1:
|
if onscreen_old or onscreen_1:
|
||||||
print "anim1 for step", n, "part", i
|
print("anim1 for step", n, "part", i)
|
||||||
print "------------------ moving from", ls_old_loc[:2], "to", pos1[:2]
|
print("------------------ moving from", ls_old_loc[:2], "to", pos1[:2])
|
||||||
shift_list.append(ApplyMethod(ls1.move_source_to, pos1, run_time = STEP_RUN_TIME))
|
shift_list.append(ApplyMethod(ls1.move_source_to, pos1, run_time = STEP_RUN_TIME))
|
||||||
else:
|
else:
|
||||||
ls1.move_source_to(pos1)
|
ls1.move_source_to(pos1)
|
||||||
if onscreen_old or onscreen_2:
|
if onscreen_old or onscreen_2:
|
||||||
print "anim2 for step", n, "part", i
|
print("anim2 for step", n, "part", i)
|
||||||
print "------------------ moving from", ls_old_loc[:2], "to", pos2[:2]
|
print("------------------ moving from", ls_old_loc[:2], "to", pos2[:2])
|
||||||
shift_list.append(ApplyMethod(ls2.move_source_to, pos2, run_time = STEP_RUN_TIME))
|
shift_list.append(ApplyMethod(ls2.move_source_to, pos2, run_time = STEP_RUN_TIME))
|
||||||
else:
|
else:
|
||||||
ls2.move_source_to(pos2)
|
ls2.move_source_to(pos2)
|
||||||
|
@ -3718,7 +3719,7 @@ class PondScene(ThreeDScene):
|
||||||
#print shift_list
|
#print shift_list
|
||||||
|
|
||||||
self.play(*shift_list)
|
self.play(*shift_list)
|
||||||
print "...done"
|
print("...done")
|
||||||
|
|
||||||
|
|
||||||
#self.revert_to_original_skipping_status()
|
#self.revert_to_original_skipping_status()
|
||||||
|
@ -3745,9 +3746,9 @@ class PondScene(ThreeDScene):
|
||||||
label_direction = UP,
|
label_direction = UP,
|
||||||
).shift(origin_point - self.number_line.number_to_point(0)) # .shift(scale * 2.5 * DOWN)
|
).shift(origin_point - self.number_line.number_to_point(0)) # .shift(scale * 2.5 * DOWN)
|
||||||
|
|
||||||
print "scale ", scale
|
print("scale ", scale)
|
||||||
print "number line at", self.number_line.get_center()
|
print("number line at", self.number_line.get_center())
|
||||||
print "should be at", origin_point, "or", OBSERVER_POINT
|
print("should be at", origin_point, "or", OBSERVER_POINT)
|
||||||
|
|
||||||
self.number_line.tick_marks.fade(1)
|
self.number_line.tick_marks.fade(1)
|
||||||
self.number_line_labels = self.number_line.get_number_mobjects()
|
self.number_line_labels = self.number_line.get_number_mobjects()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
from once_useful_constructs.light import *
|
from once_useful_constructs.light import *
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ class LightIndicator(Mobject):
|
||||||
|
|
||||||
def continual_update(self):
|
def continual_update(self):
|
||||||
if self.light_source == None:
|
if self.light_source == None:
|
||||||
print "Indicator cannot update, reason: no light source found"
|
print("Indicator cannot update, reason: no light source found")
|
||||||
self.set_intensity(self.measured_intensity())
|
self.set_intensity(self.measured_intensity())
|
||||||
|
|
||||||
class UpdateLightIndicator(AnimationGroup):
|
class UpdateLightIndicator(AnimationGroup):
|
||||||
|
@ -152,9 +153,9 @@ class ContinualLightIndicatorUpdate(ContinualAnimation):
|
||||||
|
|
||||||
def copy_func(f):
|
def copy_func(f):
|
||||||
"""Based on http://stackoverflow.com/a/6528148/190597 (Glenn Maynard)"""
|
"""Based on http://stackoverflow.com/a/6528148/190597 (Glenn Maynard)"""
|
||||||
g = types.FunctionType(f.func_code, f.func_globals, name=f.func_name,
|
g = types.FunctionType(f.__code__, f.__globals__, name=f.__name__,
|
||||||
argdefs=f.func_defaults,
|
argdefs=f.__defaults__,
|
||||||
closure=f.func_closure)
|
closure=f.__closure__)
|
||||||
g = functools.update_wrapper(g, f)
|
g = functools.update_wrapper(g, f)
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
@ -348,7 +349,7 @@ class IntroScene(PiCreatureScene):
|
||||||
rect_label_anims = []
|
rect_label_anims = []
|
||||||
|
|
||||||
for i, t1, t2 in zip(it.count(1), [0]+series_terms, series_terms):
|
for i, t1, t2 in zip(it.count(1), [0]+series_terms, series_terms):
|
||||||
color = slab_colors.next()
|
color = next(slab_colors)
|
||||||
line = Line(*map(number_line.number_to_point, [t1, t2]))
|
line = Line(*map(number_line.number_to_point, [t1, t2]))
|
||||||
rect = Rectangle(
|
rect = Rectangle(
|
||||||
stroke_width = 0,
|
stroke_width = 0,
|
||||||
|
@ -2115,7 +2116,7 @@ class TwoLightSourcesScene(ManipulateLightsourceSetups):
|
||||||
buff = SMALL_BUFF,
|
buff = SMALL_BUFF,
|
||||||
color = WHITE,
|
color = WHITE,
|
||||||
)
|
)
|
||||||
for ls in lsA, lsB, lsC
|
for ls in (lsA, lsB, lsC)
|
||||||
])
|
])
|
||||||
|
|
||||||
#Lines
|
#Lines
|
||||||
|
@ -3813,7 +3814,7 @@ class ThinkBackToHowAmazingThisIs(ThreeDScene):
|
||||||
Dot(number_line.number_to_point(u*x))
|
Dot(number_line.number_to_point(u*x))
|
||||||
for x in range(1, int(self.x_radius), 2)
|
for x in range(1, int(self.x_radius), 2)
|
||||||
])
|
])
|
||||||
for u in 1, -1
|
for u in (1, -1)
|
||||||
]
|
]
|
||||||
dot_pairs = it.starmap(VGroup, zip(positive_dots, negative_dots))
|
dot_pairs = it.starmap(VGroup, zip(positive_dots, negative_dots))
|
||||||
|
|
||||||
|
@ -3843,7 +3844,7 @@ class ThinkBackToHowAmazingThisIs(ThreeDScene):
|
||||||
TexMobject("+").next_to(
|
TexMobject("+").next_to(
|
||||||
number_line.number_to_point(u*n), UP, buff = 1.25,
|
number_line.number_to_point(u*n), UP, buff = 1.25,
|
||||||
)
|
)
|
||||||
for u in -1, 1
|
for u in (-1, 1)
|
||||||
])
|
])
|
||||||
for n in range(0, self.max_shown_n, 2)
|
for n in range(0, self.max_shown_n, 2)
|
||||||
])
|
])
|
||||||
|
@ -3890,7 +3891,7 @@ class ThinkBackToHowAmazingThisIs(ThreeDScene):
|
||||||
circle = everything.copy()
|
circle = everything.copy()
|
||||||
circle.move_to(ORIGIN)
|
circle.move_to(ORIGIN)
|
||||||
circle.apply_function(
|
circle.apply_function(
|
||||||
lambda (x, y, z) : complex_to_R3(7*np.exp(complex(0, 0.0315*x)))
|
lambda x_y_z : complex_to_R3(7*np.exp(complex(0, 0.0315*x_y_z[0])))
|
||||||
)
|
)
|
||||||
circle.rotate(-TAU/4, about_point = ORIGIN)
|
circle.rotate(-TAU/4, about_point = ORIGIN)
|
||||||
circle.center()
|
circle.center()
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
from tqdm import tqdm as ProgressDisplay
|
from tqdm import tqdm as ProgressDisplay
|
||||||
|
|
||||||
from waves import *
|
from .waves import *
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
#force_skipping
|
#force_skipping
|
||||||
#revert_to_original_skipping_status
|
#revert_to_original_skipping_status
|
||||||
|
@ -193,7 +195,7 @@ class PhotonsThroughPerpendicularFilters(PhotonPassesCompletelyOrNotAtAll):
|
||||||
em_wave = self.em_wave.copy(),
|
em_wave = self.em_wave.copy(),
|
||||||
run_time = 1,
|
run_time = 1,
|
||||||
)
|
)
|
||||||
for x in -2, 2, 10
|
for x in (-2, 2, 10)
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_probability_text(self, prob = 0):
|
def get_probability_text(self, prob = 0):
|
||||||
|
@ -590,7 +592,7 @@ class ShowVariousFilterPairsWithPhotonsOverTime(PhotonsThroughPerpendicularFilte
|
||||||
"filter_x_coordinates" : [-2, 2, 2, 2, 2],
|
"filter_x_coordinates" : [-2, 2, 2, 2, 2],
|
||||||
"pol_filter_configs" : [
|
"pol_filter_configs" : [
|
||||||
{"filter_angle" : angle}
|
{"filter_angle" : angle}
|
||||||
for angle in 0, 0, np.pi/2, np.pi/4, np.pi/8
|
for angle in (0, 0, np.pi/2, np.pi/4, np.pi/8)
|
||||||
],
|
],
|
||||||
"apply_filter" : False,
|
"apply_filter" : False,
|
||||||
}
|
}
|
||||||
|
@ -838,7 +840,7 @@ class ShowVariousFilterPairs(ShowVariousFilterPairsWithPhotonsOverTime):
|
||||||
n = self.n_lines
|
n = self.n_lines
|
||||||
start, end = [
|
start, end = [
|
||||||
(f.point_from_proportion(0.75) if f is not None else None)
|
(f.point_from_proportion(0.75) if f is not None else None)
|
||||||
for f in filter1, filter2
|
for f in (filter1, filter2)
|
||||||
]
|
]
|
||||||
if start is None:
|
if start is None:
|
||||||
start = end + self.line_start_length*LEFT
|
start = end + self.line_start_length*LEFT
|
||||||
|
@ -878,7 +880,7 @@ class ShowVariousFilterPairsFrom0To45(ShowVariousFilterPairs):
|
||||||
|
|
||||||
cosines = VGroup(*[
|
cosines = VGroup(*[
|
||||||
TexMobject("\\cos^2(%s^\\circ)"%str(x))
|
TexMobject("\\cos^2(%s^\\circ)"%str(x))
|
||||||
for x in 45, 22.5
|
for x in (45, 22.5)
|
||||||
])
|
])
|
||||||
cosines.scale(0.8)
|
cosines.scale(0.8)
|
||||||
# cosines.set_color(BLUE)
|
# cosines.set_color(BLUE)
|
||||||
|
@ -896,7 +898,7 @@ class ForgetPreviousActions(ShowVariousFilterPairs):
|
||||||
"filter_x_coordinates" : [-6, -2, 2, 2, 2],
|
"filter_x_coordinates" : [-6, -2, 2, 2, 2],
|
||||||
"pol_filter_configs" : [
|
"pol_filter_configs" : [
|
||||||
{"filter_angle" : angle}
|
{"filter_angle" : angle}
|
||||||
for angle in np.pi/4, 0, np.pi/4, np.pi/3, np.pi/6
|
for angle in (np.pi/4, 0, np.pi/4, np.pi/3, np.pi/6)
|
||||||
],
|
],
|
||||||
"start_theta" : -0.6*np.pi,
|
"start_theta" : -0.6*np.pi,
|
||||||
"EMWave_config" : {
|
"EMWave_config" : {
|
||||||
|
@ -1393,7 +1395,7 @@ class VennDiagramProofByContradiction(Scene):
|
||||||
"%s \\\\"%start,
|
"%s \\\\"%start,
|
||||||
"through", char + "$\\! \\uparrow$"
|
"through", char + "$\\! \\uparrow$"
|
||||||
).set_color_by_tex(char, circle.get_color())
|
).set_color_by_tex(char, circle.get_color())
|
||||||
for start in "Would pass", "Pass"
|
for start in ("Would pass", "Pass")
|
||||||
]
|
]
|
||||||
for mob in label, alt_label:
|
for mob in label, alt_label:
|
||||||
mob[-1][-1].rotate_in_place(-angle)
|
mob[-1][-1].rotate_in_place(-angle)
|
||||||
|
@ -1976,7 +1978,7 @@ class VennDiagramProofByContradiction(Scene):
|
||||||
fill_opacity = 0.5,
|
fill_opacity = 0.5,
|
||||||
fill_color = YELLOW,
|
fill_color = YELLOW,
|
||||||
)
|
)
|
||||||
for s in "in_A_out_B", "in_A_in_B_out_C", "in_A_out_C", "in_A_in_B"
|
for s in ("in_A_out_B", "in_A_in_B_out_C", "in_A_out_C", "in_A_in_B")
|
||||||
])
|
])
|
||||||
|
|
||||||
in_A_out_B.scale(2.59)
|
in_A_out_B.scale(2.59)
|
||||||
|
@ -2383,7 +2385,7 @@ class NoFirstMeasurementPreferenceBasedOnDirection(ShowVariousFilterPairs):
|
||||||
"filter_x_coordinates" : [0, 0, 0],
|
"filter_x_coordinates" : [0, 0, 0],
|
||||||
"pol_filter_configs" : [
|
"pol_filter_configs" : [
|
||||||
{"filter_angle" : angle}
|
{"filter_angle" : angle}
|
||||||
for angle in 0, np.pi/8, np.pi/4
|
for angle in (0, np.pi/8, np.pi/4)
|
||||||
],
|
],
|
||||||
"lines_depth" : 1.2,
|
"lines_depth" : 1.2,
|
||||||
"lines_shift_vect" : SMALL_BUFF*OUT,
|
"lines_shift_vect" : SMALL_BUFF*OUT,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
class Jewel(VMobject):
|
class Jewel(VMobject):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
|
@ -943,7 +944,7 @@ class WalkEquatorPostTransform(GraphScene):
|
||||||
curve.x_collision_points[i]
|
curve.x_collision_points[i]
|
||||||
for curve in gerat_arc_images
|
for curve in gerat_arc_images
|
||||||
]
|
]
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
]))
|
]))
|
||||||
full_curve = VMobject(close_new_points = True)
|
full_curve = VMobject(close_new_points = True)
|
||||||
full_curve.set_points_smoothly(points + [points[0]])
|
full_curve.set_points_smoothly(points + [points[0]])
|
||||||
|
@ -1818,7 +1819,7 @@ class ChoicesInNecklaceCutting(ReconfigurableScene):
|
||||||
for group in groups:
|
for group in groups:
|
||||||
group.target_points = [
|
group.target_points = [
|
||||||
group.get_center() + self.thief_box_offset*vect
|
group.get_center() + self.thief_box_offset*vect
|
||||||
for vect in UP, DOWN
|
for vect in (UP, DOWN)
|
||||||
]
|
]
|
||||||
|
|
||||||
return groups
|
return groups
|
||||||
|
@ -1835,7 +1836,7 @@ class ChoicesInNecklaceCutting(ReconfigurableScene):
|
||||||
|
|
||||||
boxes = VGroup(*[
|
boxes = VGroup(*[
|
||||||
box.copy().shift(self.thief_box_offset*vect)
|
box.copy().shift(self.thief_box_offset*vect)
|
||||||
for vect in UP, DOWN
|
for vect in (UP, DOWN)
|
||||||
])
|
])
|
||||||
labels = VGroup(*[
|
labels = VGroup(*[
|
||||||
TextMobject(
|
TextMobject(
|
||||||
|
@ -2083,7 +2084,7 @@ class NecklaceDivisionSphereAssociation(ChoicesInNecklaceCutting):
|
||||||
TexMobject(
|
TexMobject(
|
||||||
char, "=", sign, "\\sqrt{\\frac{1}{%d}}"%denom
|
char, "=", sign, "\\sqrt{\\frac{1}{%d}}"%denom
|
||||||
)
|
)
|
||||||
for sign in "+", "-"
|
for sign in ("+", "-")
|
||||||
]
|
]
|
||||||
for choice, color in zip(choices, [GREEN, RED]):
|
for choice, color in zip(choices, [GREEN, RED]):
|
||||||
# choice[0].set_color(brace.label.get_color())
|
# choice[0].set_color(brace.label.get_color())
|
||||||
|
@ -2216,7 +2217,7 @@ class TotalLengthOfEachJewelEquals(NecklaceDivisionSphereAssociation, ThreeDScen
|
||||||
lambda segment: segment.get_color() == color,
|
lambda segment: segment.get_color() == color,
|
||||||
segment_group
|
segment_group
|
||||||
))
|
))
|
||||||
for segment_group in top_segments, bottom_segments
|
for segment_group in (top_segments, bottom_segments)
|
||||||
]
|
]
|
||||||
labels = VGroup()
|
labels = VGroup()
|
||||||
for i, group in enumerate(monochrome_groups):
|
for i, group in enumerate(monochrome_groups):
|
||||||
|
@ -2304,7 +2305,7 @@ class ShowFunctionDiagram(TotalLengthOfEachJewelEquals, ReconfigurableScene):
|
||||||
skip_animations = True,
|
skip_animations = True,
|
||||||
thief_number = x
|
thief_number = x
|
||||||
)
|
)
|
||||||
for x in 1, 2
|
for x in (1, 2)
|
||||||
]
|
]
|
||||||
t1_plane, t2_plane = planes = VGroup(*[
|
t1_plane, t2_plane = planes = VGroup(*[
|
||||||
VGroup(*plane_class.get_top_level_mobjects())
|
VGroup(*plane_class.get_top_level_mobjects())
|
||||||
|
|
|
@ -353,7 +353,7 @@ class TransitionAwayFromSlide(PathSlidingScene):
|
||||||
arrow = Arrow(ORIGIN, 2*RIGHT)
|
arrow = Arrow(ORIGIN, 2*RIGHT)
|
||||||
arrows = Mobject(*[
|
arrows = Mobject(*[
|
||||||
arrow.copy().shift(vect)
|
arrow.copy().shift(vect)
|
||||||
for vect in 3*LEFT, ORIGIN, 3*RIGHT
|
for vect in (3*LEFT, ORIGIN, 3*RIGHT)
|
||||||
])
|
])
|
||||||
arrows.shift(FRAME_WIDTH*RIGHT)
|
arrows.shift(FRAME_WIDTH*RIGHT)
|
||||||
self.add(arrows)
|
self.add(arrows)
|
||||||
|
|
|
@ -36,7 +36,7 @@ class CycloidScene(Scene):
|
||||||
def grow_parts(self):
|
def grow_parts(self):
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ShowCreation(mob)
|
ShowCreation(mob)
|
||||||
for mob in self.circle, self.ceiling
|
for mob in (self.circle, self.ceiling)
|
||||||
])
|
])
|
||||||
|
|
||||||
def generate_cycloid(self):
|
def generate_cycloid(self):
|
||||||
|
@ -295,7 +295,7 @@ class LeviSolution(CycloidScene):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
Transform(mob, d_mob)
|
Transform(mob, d_mob)
|
||||||
for mob in brace, diameter_word
|
for mob in (brace, diameter_word)
|
||||||
])
|
])
|
||||||
self.remove(brace, diameter_word)
|
self.remove(brace, diameter_word)
|
||||||
self.add(d_mob)
|
self.add(d_mob)
|
||||||
|
|
|
@ -255,7 +255,7 @@ class NewtonVsJohann(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
newton, johann = [
|
newton, johann = [
|
||||||
ImageMobject(name, invert = False).scale(0.5)
|
ImageMobject(name, invert = False).scale(0.5)
|
||||||
for name in "Newton", "Johann_Bernoulli2"
|
for name in ("Newton", "Johann_Bernoulli2")
|
||||||
]
|
]
|
||||||
greater_than = TexMobject(">")
|
greater_than = TexMobject(">")
|
||||||
newton.next_to(greater_than, RIGHT)
|
newton.next_to(greater_than, RIGHT)
|
||||||
|
@ -277,7 +277,7 @@ class JohannThinksOfFermat(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
johann, fermat = [
|
johann, fermat = [
|
||||||
ImageMobject(name, invert = False)
|
ImageMobject(name, invert = False)
|
||||||
for name in "Johann_Bernoulli2", "Pierre_de_Fermat"
|
for name in ("Johann_Bernoulli2", "Pierre_de_Fermat")
|
||||||
]
|
]
|
||||||
johann.scale(0.2)
|
johann.scale(0.2)
|
||||||
johann.to_corner(DOWN+LEFT)
|
johann.to_corner(DOWN+LEFT)
|
||||||
|
|
|
@ -69,7 +69,7 @@ class MultilayeredGlass(PhotonScene, ZoomedScene):
|
||||||
)
|
)
|
||||||
top_rgb, bottom_rgb = [
|
top_rgb, bottom_rgb = [
|
||||||
np.array(Color(color).get_rgb())
|
np.array(Color(color).get_rgb())
|
||||||
for color in self.top_color, self.bottom_color
|
for color in (self.top_color, self.bottom_color)
|
||||||
]
|
]
|
||||||
epsilon = 1./(self.num_discrete_layers-1)
|
epsilon = 1./(self.num_discrete_layers-1)
|
||||||
self.layer_colors = [
|
self.layer_colors = [
|
||||||
|
@ -239,7 +239,7 @@ class MultilayeredGlass(PhotonScene, ZoomedScene):
|
||||||
def show_snells(self, index, frame):
|
def show_snells(self, index, frame):
|
||||||
left_text, right_text = [
|
left_text, right_text = [
|
||||||
"\\dfrac{\\sin(\\theta_%d)}{\\phantom{\\sqrt{y_1}}}"%x
|
"\\dfrac{\\sin(\\theta_%d)}{\\phantom{\\sqrt{y_1}}}"%x
|
||||||
for x in index, index+1
|
for x in (index, index+1)
|
||||||
]
|
]
|
||||||
left, equals, right = TexMobject(
|
left, equals, right = TexMobject(
|
||||||
[left_text, "=", right_text]
|
[left_text, "=", right_text]
|
||||||
|
@ -251,7 +251,7 @@ class MultilayeredGlass(PhotonScene, ZoomedScene):
|
||||||
TexMobject(
|
TexMobject(
|
||||||
text, size = "\\Large"
|
text, size = "\\Large"
|
||||||
).next_to(numerator, DOWN)
|
).next_to(numerator, DOWN)
|
||||||
for text in "v_%d"%x, "\\sqrt{y_%d}"%x
|
for text in ("v_%d"%x, "\\sqrt{y_%d}"%x)
|
||||||
]
|
]
|
||||||
vs.append(v)
|
vs.append(v)
|
||||||
sqrt_ys.append(sqrt_y)
|
sqrt_ys.append(sqrt_y)
|
||||||
|
@ -259,7 +259,7 @@ class MultilayeredGlass(PhotonScene, ZoomedScene):
|
||||||
Mobject(
|
Mobject(
|
||||||
left.copy(), mobs[0], equals.copy(), right.copy(), mobs[1]
|
left.copy(), mobs[0], equals.copy(), right.copy(), mobs[1]
|
||||||
).replace(frame)
|
).replace(frame)
|
||||||
for mobs in vs, sqrt_ys
|
for mobs in (vs, sqrt_ys)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.add(start)
|
self.add(start)
|
||||||
|
|
|
@ -499,7 +499,7 @@ class GeometryOfGlassSituation(ShowMultiplePathsInWater):
|
||||||
new_graph.reverse_points()
|
new_graph.reverse_points()
|
||||||
pairs_for_end_transform = [
|
pairs_for_end_transform = [
|
||||||
(mob, mob.copy())
|
(mob, mob.copy())
|
||||||
for mob in top_line, bottom_line, left_brace, x_mob
|
for mob in (top_line, bottom_line, left_brace, x_mob)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.add(glass, point_a, point_b, A, B)
|
self.add(glass, point_a, point_b, A, B)
|
||||||
|
@ -636,7 +636,7 @@ class SpringSetup(ShowMultiplePathsInWater):
|
||||||
Spring(self.start_point, r.get_top()),
|
Spring(self.start_point, r.get_top()),
|
||||||
Spring(self.end_point, r.get_bottom())
|
Spring(self.end_point, r.get_bottom())
|
||||||
)
|
)
|
||||||
for r in ring, ring.copy().shift(self.ring_shift_val)
|
for r in (ring, ring.copy().shift(self.ring_shift_val))
|
||||||
]
|
]
|
||||||
|
|
||||||
def add_rod_and_ring(self, rod, ring):
|
def add_rod_and_ring(self, rod, ring):
|
||||||
|
@ -663,7 +663,7 @@ class SpringSetup(ShowMultiplePathsInWater):
|
||||||
def add_springs(self):
|
def add_springs(self):
|
||||||
colors = iter([BLACK, BLUE_E])
|
colors = iter([BLACK, BLUE_E])
|
||||||
for spring in self.start_springs.split():
|
for spring in self.start_springs.split():
|
||||||
circle = Circle(color = colors.next())
|
circle = Circle(color = next(colors))
|
||||||
circle.reverse_points()
|
circle.reverse_points()
|
||||||
circle.scale(spring.loop_radius)
|
circle.scale(spring.loop_radius)
|
||||||
circle.shift(spring.points[0])
|
circle.shift(spring.points[0])
|
||||||
|
@ -725,7 +725,7 @@ class SpringSetup(ShowMultiplePathsInWater):
|
||||||
arc = Arc(angle, radius = 0.5).rotate(np.pi/2)
|
arc = Arc(angle, radius = 0.5).rotate(np.pi/2)
|
||||||
if point is self.end_point:
|
if point is self.end_point:
|
||||||
arc.rotate(np.pi)
|
arc.rotate(np.pi)
|
||||||
theta = TexMobject("\\theta_%d"%counter.next())
|
theta = TexMobject("\\theta_%d"%next(counter))
|
||||||
theta.scale(0.5)
|
theta.scale(0.5)
|
||||||
theta.shift(2*arc.get_center())
|
theta.shift(2*arc.get_center())
|
||||||
arc.shift(ring_center)
|
arc.shift(ring_center)
|
||||||
|
@ -765,7 +765,7 @@ class SpringSetup(ShowMultiplePathsInWater):
|
||||||
frac1, sin1, equals, frac2, sin2 = equation.split()
|
frac1, sin1, equals, frac2, sin2 = equation.split()
|
||||||
v_air, v_water = [
|
v_air, v_water = [
|
||||||
TexMobject("v_{\\text{%s}}"%s, size = "\\Large")
|
TexMobject("v_{\\text{%s}}"%s, size = "\\Large")
|
||||||
for s in "air", "water"
|
for s in ("air", "water")
|
||||||
]
|
]
|
||||||
v_air.next_to(Point(frac1.get_center()), DOWN)
|
v_air.next_to(Point(frac1.get_center()), DOWN)
|
||||||
v_water.next_to(Point(frac2.get_center()), DOWN)
|
v_water.next_to(Point(frac2.get_center()), DOWN)
|
||||||
|
@ -773,7 +773,7 @@ class SpringSetup(ShowMultiplePathsInWater):
|
||||||
frac2.add(v_water)
|
frac2.add(v_water)
|
||||||
f1, f2 = [
|
f1, f2 = [
|
||||||
TexMobject("F_%d"%d, size = "\\Large")
|
TexMobject("F_%d"%d, size = "\\Large")
|
||||||
for d in 1, 2
|
for d in (1, 2)
|
||||||
]
|
]
|
||||||
f1.next_to(sin1, LEFT)
|
f1.next_to(sin1, LEFT)
|
||||||
f2.next_to(equals, RIGHT)
|
f2.next_to(equals, RIGHT)
|
||||||
|
@ -875,7 +875,7 @@ class StateSnellsLaw(PhotonScene):
|
||||||
if point is point_b:
|
if point is point_b:
|
||||||
arc.rotate(np.pi)
|
arc.rotate(np.pi)
|
||||||
line.reverse_points()
|
line.reverse_points()
|
||||||
theta = TexMobject("\\theta_%d"%counter.next())
|
theta = TexMobject("\\theta_%d"%next(counter))
|
||||||
theta.scale(0.5)
|
theta.scale(0.5)
|
||||||
theta.shift(2*arc.get_center())
|
theta.shift(2*arc.get_center())
|
||||||
arc.shift(midpoint)
|
arc.shift(midpoint)
|
||||||
|
|
|
@ -7,7 +7,8 @@ from brachistochrone.curves import Cycloid
|
||||||
class PhysicalIntuition(Scene):
|
class PhysicalIntuition(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
n_terms = 4
|
n_terms = 4
|
||||||
def func((x, y, ignore)):
|
def func(xxx_todo_changeme):
|
||||||
|
(x, y, ignore) = xxx_todo_changeme
|
||||||
z = complex(x, y)
|
z = complex(x, y)
|
||||||
if (np.abs(x%1 - 0.5)<0.01 and y < 0.01) or np.abs(z)<0.01:
|
if (np.abs(x%1 - 0.5)<0.01 and y < 0.01) or np.abs(z)<0.01:
|
||||||
return ORIGIN
|
return ORIGIN
|
||||||
|
@ -87,7 +88,7 @@ class TimeLine(Scene):
|
||||||
for point, event in zip(centers[1:], dated_events):
|
for point, event in zip(centers[1:], dated_events):
|
||||||
self.play(ApplyMethod(
|
self.play(ApplyMethod(
|
||||||
timeline.shift, -point.get_center(),
|
timeline.shift, -point.get_center(),
|
||||||
run_time = run_times.next()
|
run_time = next(run_times)
|
||||||
))
|
))
|
||||||
picture = ImageMobject(event["picture"], invert = False)
|
picture = ImageMobject(event["picture"], invert = False)
|
||||||
picture.scale_to_fit_width(2)
|
picture.scale_to_fit_width(2)
|
||||||
|
|
|
@ -23,7 +23,7 @@ class MultilayeredScene(Scene):
|
||||||
height = float(self.total_glass_height)/n_layers
|
height = float(self.total_glass_height)/n_layers
|
||||||
rgb_pair = [
|
rgb_pair = [
|
||||||
np.array(Color(color).get_rgb())
|
np.array(Color(color).get_rgb())
|
||||||
for color in self.top_color, self.bottom_color
|
for color in (self.top_color, self.bottom_color)
|
||||||
]
|
]
|
||||||
rgb_range = [
|
rgb_range = [
|
||||||
interpolate(*rgb_pair+[x])
|
interpolate(*rgb_pair+[x])
|
||||||
|
@ -253,7 +253,7 @@ class ShowLayerVariables(MultilayeredScene, PhotonScene):
|
||||||
)
|
)
|
||||||
for mob, start in zip(mobs, starts)
|
for mob, start in zip(mobs, starts)
|
||||||
]
|
]
|
||||||
for mobs in start_ys, braces
|
for mobs in (start_ys, braces)
|
||||||
]))
|
]))
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ from copy import deepcopy
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
DEFAULT_PLANE_CONFIG = {
|
DEFAULT_PLANE_CONFIG = {
|
||||||
"stroke_width" : 2*DEFAULT_POINT_THICKNESS
|
"stroke_width" : 2*DEFAULT_POINT_THICKNESS
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools as it
|
import itertools as it
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
|
@ -140,7 +140,7 @@ class ListOfAttributes(Scene):
|
||||||
fill_opacity = 1,
|
fill_opacity = 1,
|
||||||
stroke_width = 0,
|
stroke_width = 0,
|
||||||
)
|
)
|
||||||
for word in "government", "bank"
|
for word in ("government", "bank")
|
||||||
]
|
]
|
||||||
attributes = VGroup(digital, *buildings)
|
attributes = VGroup(digital, *buildings)
|
||||||
attributes.arrange_submobjects(RIGHT, buff = LARGE_BUFF)
|
attributes.arrange_submobjects(RIGHT, buff = LARGE_BUFF)
|
||||||
|
@ -809,7 +809,7 @@ class IntroduceLedgerSystem(LedgerScene):
|
||||||
self.wait()
|
self.wait()
|
||||||
debtor_cash, creditor_cash = [
|
debtor_cash, creditor_cash = [
|
||||||
VGroup(*it.chain(*[pi.cash for pi in group]))
|
VGroup(*it.chain(*[pi.cash for pi in group]))
|
||||||
for group in debtors, creditors
|
for group in (debtors, creditors)
|
||||||
]
|
]
|
||||||
self.play(FadeIn(debtor_cash))
|
self.play(FadeIn(debtor_cash))
|
||||||
self.play(
|
self.play(
|
||||||
|
@ -1691,7 +1691,7 @@ class LedgerWithInitialBuyIn(SignedLedgerScene):
|
||||||
def point_out_charlie_is_broke(self):
|
def point_out_charlie_is_broke(self):
|
||||||
charlie_lines = VGroup(*[
|
charlie_lines = VGroup(*[
|
||||||
VGroup(*self.ledger.content[i][1:5])
|
VGroup(*self.ledger.content[i][1:5])
|
||||||
for i in 3, 5, 6, 7
|
for i in (3, 5, 6, 7)
|
||||||
])
|
])
|
||||||
rects = VGroup(*[
|
rects = VGroup(*[
|
||||||
SurroundingRectangle(line)
|
SurroundingRectangle(line)
|
||||||
|
@ -1722,11 +1722,11 @@ class LedgerWithInitialBuyIn(SignedLedgerScene):
|
||||||
def running_balance(self):
|
def running_balance(self):
|
||||||
charlie_lines = VGroup(*[
|
charlie_lines = VGroup(*[
|
||||||
VGroup(*self.ledger.content[i][1:5])
|
VGroup(*self.ledger.content[i][1:5])
|
||||||
for i in 3, 5, 6, 7
|
for i in (3, 5, 6, 7)
|
||||||
])
|
])
|
||||||
signatures = VGroup(*[
|
signatures = VGroup(*[
|
||||||
self.ledger.content[i][5]
|
self.ledger.content[i][5]
|
||||||
for i in 5, 6, 7
|
for i in (5, 6, 7)
|
||||||
])
|
])
|
||||||
rect = Rectangle(color = WHITE)
|
rect = Rectangle(color = WHITE)
|
||||||
rect.set_fill(BLACK, 0.8)
|
rect.set_fill(BLACK, 0.8)
|
||||||
|
@ -2770,7 +2770,7 @@ class IntroduceNonceOnTrasactions(LedgerScene):
|
||||||
self.play(LaggedStart(
|
self.play(LaggedStart(
|
||||||
ReplacementTransform,
|
ReplacementTransform,
|
||||||
VGroup(*[point.copy() for x in range(256)]),
|
VGroup(*[point.copy() for x in range(256)]),
|
||||||
lambda m : (m, bit_iter.next()),
|
lambda m : (m, next(bit_iter)),
|
||||||
))
|
))
|
||||||
self.remove(*self.get_mobjects_from_last_animation())
|
self.remove(*self.get_mobjects_from_last_animation())
|
||||||
self.add(digest)
|
self.add(digest)
|
||||||
|
@ -3181,7 +3181,7 @@ class IntroduceBlockChain(Scene):
|
||||||
Line(
|
Line(
|
||||||
rect.get_left(), rect.get_right()
|
rect.get_left(), rect.get_right()
|
||||||
).shift(0.3*rect.get_height()*vect)
|
).shift(0.3*rect.get_height()*vect)
|
||||||
for vect in UP, DOWN
|
for vect in (UP, DOWN)
|
||||||
]
|
]
|
||||||
|
|
||||||
payments = VGroup()
|
payments = VGroup()
|
||||||
|
@ -4674,7 +4674,7 @@ class CompareBlockTimes(Scene):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
LaggedStart(FadeIn, VGroup(*group[1:]))
|
LaggedStart(FadeIn, VGroup(*group[1:]))
|
||||||
for group in examples, logos
|
for group in (examples, logos)
|
||||||
])
|
])
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
|
|
||||||
|
@ -804,7 +805,7 @@ class ShowAllSteadyStateVelocities(SimpleVelocityGraph):
|
||||||
)
|
)
|
||||||
self.add(dot)
|
self.add(dot)
|
||||||
self.add(label)
|
self.add(label)
|
||||||
print index_str, self.velocities[-1], self.friction
|
print(index_str, self.velocities[-1], self.friction)
|
||||||
|
|
||||||
class Test(Scene):
|
class Test(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
|
@ -871,7 +872,7 @@ class Test(Scene):
|
||||||
run_time = 3,
|
run_time = 3,
|
||||||
))
|
))
|
||||||
|
|
||||||
print arc1.angle, arc2.angle
|
print(arc1.angle, arc2.angle)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -932,7 +932,7 @@ class AddCircleSymmetries(CircleSymmetries):
|
||||||
for term, arc in zip(equation[::2], arcs):
|
for term, arc in zip(equation[::2], arcs):
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(mob.scale_in_place, 1.2, rate_func = there_and_back)
|
ApplyMethod(mob.scale_in_place, 1.2, rate_func = there_and_back)
|
||||||
for mob in term, arc
|
for mob in (term, arc)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
|
@ -1001,7 +1001,7 @@ class AddCubeSymmetries(GroupOfCubeSymmetries):
|
||||||
start_angle = np.pi/12+a, angle = 5*np.pi/6,
|
start_angle = np.pi/12+a, angle = 5*np.pi/6,
|
||||||
color = YELLOW
|
color = YELLOW
|
||||||
).add_tip()
|
).add_tip()
|
||||||
for a in 0, np.pi
|
for a in (0, np.pi)
|
||||||
])
|
])
|
||||||
arrows.scale_to_fit_height(1.5*cube.get_height())
|
arrows.scale_to_fit_height(1.5*cube.get_height())
|
||||||
z_to_axis = z_to_vector(axis)
|
z_to_axis = z_to_vector(axis)
|
||||||
|
@ -1843,7 +1843,7 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals):
|
||||||
self.number_line.number_to_point(num),
|
self.number_line.number_to_point(num),
|
||||||
self.shadow_line.number_to_point(num)
|
self.shadow_line.number_to_point(num)
|
||||||
)
|
)
|
||||||
for num in 3, 0.5
|
for num in (3, 0.5)
|
||||||
]
|
]
|
||||||
three_mob = filter(
|
three_mob = filter(
|
||||||
lambda m : m.get_tex_string() == "3",
|
lambda m : m.get_tex_string() == "3",
|
||||||
|
@ -1927,7 +1927,7 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals):
|
||||||
self.number_line.number_to_point(num),
|
self.number_line.number_to_point(num),
|
||||||
self.shadow_line.number_to_point(num)
|
self.shadow_line.number_to_point(num)
|
||||||
)
|
)
|
||||||
for num in 0.33, 1
|
for num in (0.33, 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.play(
|
self.play(
|
||||||
|
@ -1965,7 +1965,7 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals):
|
||||||
def compose_actions(self, num1, num2):
|
def compose_actions(self, num1, num2):
|
||||||
words = VGroup(*[
|
words = VGroup(*[
|
||||||
TextMobject("(%s by %s)"%(word, str(num)))
|
TextMobject("(%s by %s)"%(word, str(num)))
|
||||||
for num in num1, num2, num1*num2
|
for num in (num1, num2, num1*num2)
|
||||||
for word in ["Stretch" if num > 1 else "Squish"]
|
for word in ["Stretch" if num > 1 else "Squish"]
|
||||||
])
|
])
|
||||||
words.submobjects.insert(2, TexMobject("="))
|
words.submobjects.insert(2, TexMobject("="))
|
||||||
|
@ -2727,7 +2727,7 @@ class ExponentsAsHomomorphism(Scene):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
line.restore
|
line.restore
|
||||||
for line in self.top_line, self.bottom_line
|
for line in (self.top_line, self.bottom_line)
|
||||||
])
|
])
|
||||||
|
|
||||||
def get_stretch_anim(self, bottom_line, x):
|
def get_stretch_anim(self, bottom_line, x):
|
||||||
|
@ -3334,7 +3334,7 @@ class ExpTransformation(ComplexTransformationScene):
|
||||||
self.prepare_for_transformation(self.plane)
|
self.prepare_for_transformation(self.plane)
|
||||||
final_plane = self.plane.copy().apply_complex_function(np.exp)
|
final_plane = self.plane.copy().apply_complex_function(np.exp)
|
||||||
cylinder = self.plane.copy().apply_function(
|
cylinder = self.plane.copy().apply_function(
|
||||||
lambda (x, y, z) : np.array([x, np.sin(y), -np.cos(y)])
|
lambda x_y_z : np.array([x_y_z[0], np.sin(x_y_z[1]), -np.cos(x_y_z[1])])
|
||||||
)
|
)
|
||||||
title = TexMobject("x \\to e^x")
|
title = TexMobject("x \\to e^x")
|
||||||
title.add_background_rectangle()
|
title.add_background_rectangle()
|
||||||
|
|
|
@ -385,7 +385,7 @@ class PreviewFrame(Scene):
|
||||||
|
|
||||||
colors = iter(color_gradient([BLUE, YELLOW], 3))
|
colors = iter(color_gradient([BLUE, YELLOW], 3))
|
||||||
titles = [
|
titles = [
|
||||||
TextMobject("Chapter %d:"%d, s).to_edge(UP).set_color(colors.next())
|
TextMobject("Chapter %d:"%d, s).to_edge(UP).set_color(next(colors))
|
||||||
for d, s in [
|
for d, s in [
|
||||||
(3, "Derivative formulas through geometry"),
|
(3, "Derivative formulas through geometry"),
|
||||||
(4, "Chain rule, product rule, etc."),
|
(4, "Chain rule, product rule, etc."),
|
||||||
|
@ -483,7 +483,7 @@ class ProductRuleDiagram(Scene):
|
||||||
self.play(MoveToTarget(fg_group))
|
self.play(MoveToTarget(fg_group))
|
||||||
self.play(*[
|
self.play(*[
|
||||||
mob.restore
|
mob.restore
|
||||||
for mob in df_brace, df_label, dg_brace, dg_label
|
for mob in (df_brace, df_label, dg_brace, dg_label)
|
||||||
] + [
|
] + [
|
||||||
ReplacementTransform(d_rect.line, d_rect)
|
ReplacementTransform(d_rect.line, d_rect)
|
||||||
for d_rect in d_rects
|
for d_rect in d_rects
|
||||||
|
@ -521,11 +521,11 @@ class ProductRuleDiagram(Scene):
|
||||||
(g_label, "g"),
|
(g_label, "g"),
|
||||||
(df_label, "df"),
|
(df_label, "df"),
|
||||||
]
|
]
|
||||||
for alpha in [alpha_iter.next()]
|
for alpha in [next(alpha_iter)]
|
||||||
]+[
|
]+[
|
||||||
Write(VGroup(*it.chain(*[
|
Write(VGroup(*it.chain(*[
|
||||||
deriv.get_parts_by_tex(tex, substring = False)
|
deriv.get_parts_by_tex(tex, substring = False)
|
||||||
for tex in "d(", ")", "=", "\\cdot", "+"
|
for tex in ("d(", ")", "=", "\\cdot", "+")
|
||||||
])))
|
])))
|
||||||
], run_time = 3)
|
], run_time = 3)
|
||||||
self.wait()
|
self.wait()
|
||||||
|
@ -820,7 +820,7 @@ class ApproximateOneRing(CircleScene, ReconfigurableScene):
|
||||||
self.unwrapped_ring, vect, buff = SMALL_BUFF,
|
self.unwrapped_ring, vect, buff = SMALL_BUFF,
|
||||||
min_num_quads = 2,
|
min_num_quads = 2,
|
||||||
)
|
)
|
||||||
for vect in UP, LEFT
|
for vect in (UP, LEFT)
|
||||||
]
|
]
|
||||||
top_brace.scale_in_place(self.ring.R/(self.ring.R+self.dR))
|
top_brace.scale_in_place(self.ring.R/(self.ring.R+self.dR))
|
||||||
side_brace.set_stroke(WHITE, 0.5)
|
side_brace.set_stroke(WHITE, 0.5)
|
||||||
|
@ -1041,7 +1041,7 @@ class GraphRectangles(CircleScene, GraphScene):
|
||||||
color = YELLOW,
|
color = YELLOW,
|
||||||
tip_length = 0.15
|
tip_length = 0.15
|
||||||
)
|
)
|
||||||
for tick in r_ticks[0], r_ticks[-1]
|
for tick in (r_ticks[0], r_ticks[-1])
|
||||||
])
|
])
|
||||||
first_tick = r_ticks[0].copy()
|
first_tick = r_ticks[0].copy()
|
||||||
moving_arrow = arrows[0].copy()
|
moving_arrow = arrows[0].copy()
|
||||||
|
@ -1094,7 +1094,7 @@ class GraphRectangles(CircleScene, GraphScene):
|
||||||
start_color = self.rings[0].get_fill_color(),
|
start_color = self.rings[0].get_fill_color(),
|
||||||
end_color = self.rings[-1].get_fill_color(),
|
end_color = self.rings[-1].get_fill_color(),
|
||||||
)
|
)
|
||||||
for g in graph, flat_graph
|
for g in (graph, flat_graph)
|
||||||
]
|
]
|
||||||
self.graph, self.flat_rects = graph, flat_rects
|
self.graph, self.flat_rects = graph, flat_rects
|
||||||
|
|
||||||
|
@ -1303,7 +1303,7 @@ class GraphRectangles(CircleScene, GraphScene):
|
||||||
def compute_area_under_graph(self):
|
def compute_area_under_graph(self):
|
||||||
formula, formula_with_R = formulas = [
|
formula, formula_with_R = formulas = [
|
||||||
self.get_area_formula(R)
|
self.get_area_formula(R)
|
||||||
for R in "3", "R"
|
for R in ("3", "R")
|
||||||
]
|
]
|
||||||
for mob in formulas:
|
for mob in formulas:
|
||||||
mob.to_corner(UP+RIGHT, buff = MED_SMALL_BUFF)
|
mob.to_corner(UP+RIGHT, buff = MED_SMALL_BUFF)
|
||||||
|
@ -2038,7 +2038,7 @@ class AreaUnderParabola(GraphScene):
|
||||||
FRAME_HEIGHT*UP, ORIGIN,
|
FRAME_HEIGHT*UP, ORIGIN,
|
||||||
color = RED
|
color = RED
|
||||||
).move_to(self.coords_to_point(x, 0), DOWN)
|
).move_to(self.coords_to_point(x, 0), DOWN)
|
||||||
for x in 0, self.default_right_x
|
for x in (0, self.default_right_x)
|
||||||
])
|
])
|
||||||
|
|
||||||
self.play(
|
self.play(
|
||||||
|
@ -2345,7 +2345,7 @@ class PlayingTowardsDADX(AreaUnderParabola, ReconfigurableScene):
|
||||||
deriv_equation.get_part_by_tex(tex),
|
deriv_equation.get_part_by_tex(tex),
|
||||||
run_time = 2,
|
run_time = 2,
|
||||||
)
|
)
|
||||||
for tex in "dA", "approx", f_tex, "dx"
|
for tex in ("dA", "approx", f_tex, "dx")
|
||||||
] + [
|
] + [
|
||||||
Write(deriv_equation.get_part_by_tex("over"))
|
Write(deriv_equation.get_part_by_tex("over"))
|
||||||
])
|
])
|
||||||
|
|
|
@ -254,11 +254,11 @@ class Pendulum(ReconfigurableScene):
|
||||||
self.height_tex_R = height_tex_R
|
self.height_tex_R = height_tex_R
|
||||||
self.cosine = VGroup(*[
|
self.cosine = VGroup(*[
|
||||||
height_tex.get_part_by_tex(tex)
|
height_tex.get_part_by_tex(tex)
|
||||||
for tex in "cos", "theta", ")"
|
for tex in ("cos", "theta", ")")
|
||||||
])
|
])
|
||||||
self.one_minus = VGroup(*[
|
self.one_minus = VGroup(*[
|
||||||
height_tex.get_part_by_tex(tex)
|
height_tex.get_part_by_tex(tex)
|
||||||
for tex in "\\big(1-", "\\big)"
|
for tex in ("\\big(1-", "\\big)")
|
||||||
])
|
])
|
||||||
|
|
||||||
def get_angry_at_cosine(self):
|
def get_angry_at_cosine(self):
|
||||||
|
@ -500,9 +500,9 @@ class ExampleApproximationWithCos(ExampleApproximationWithSine):
|
||||||
line_class = DashedLine,
|
line_class = DashedLine,
|
||||||
color = YELLOW
|
color = YELLOW
|
||||||
)
|
)
|
||||||
for u in -1, 1
|
for u in (-1, 1)
|
||||||
])
|
])
|
||||||
for dx in 0.01, 0.7
|
for dx in (0.01, 0.7)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.play(*map(ShowCreation, v_lines), run_time = 2)
|
self.play(*map(ShowCreation, v_lines), run_time = 2)
|
||||||
|
@ -1101,7 +1101,7 @@ class ReflectOnQuadraticApproximation(TeacherStudentsScene):
|
||||||
"\\cos(", s, ")", "\\approx",
|
"\\cos(", s, ")", "\\approx",
|
||||||
"1 - \\frac{1}{2}", "(", s, ")", "^2"
|
"1 - \\frac{1}{2}", "(", s, ")", "^2"
|
||||||
).next_to(self.get_students(), UP, 2)
|
).next_to(self.get_students(), UP, 2)
|
||||||
for s in "x", "0.1",
|
for s in ("x", "0.1",)
|
||||||
]
|
]
|
||||||
approx_rhs = TexMobject("=", "0.995")
|
approx_rhs = TexMobject("=", "0.995")
|
||||||
approx_rhs.next_to(approx_at_point, RIGHT)
|
approx_rhs.next_to(approx_at_point, RIGHT)
|
||||||
|
@ -1612,7 +1612,7 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation):
|
||||||
|
|
||||||
possibly_added_anims = []
|
possibly_added_anims = []
|
||||||
try:
|
try:
|
||||||
possibly_added_anims.append(added_anims_iter.next())
|
possibly_added_anims.append(next(added_anims_iter))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -1779,7 +1779,7 @@ class HigherTermsDontMessUpLowerTerms(Scene):
|
||||||
polynomial.shift(2*LEFT + UP)
|
polynomial.shift(2*LEFT + UP)
|
||||||
c0, c2, c4 = [
|
c0, c2, c4 = [
|
||||||
polynomial.get_part_by_tex(tex)
|
polynomial.get_part_by_tex(tex)
|
||||||
for tex in c0_tex, c2_tex, c4_tex
|
for tex in (c0_tex, c2_tex, c4_tex)
|
||||||
]
|
]
|
||||||
for term, color in zip([c0, c2, c4], self.colors):
|
for term, color in zip([c0, c2, c4], self.colors):
|
||||||
term.set_color(color)
|
term.set_color(color)
|
||||||
|
@ -2046,7 +2046,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations):
|
||||||
)
|
)
|
||||||
outer_v_lines = VGroup(*[
|
outer_v_lines = VGroup(*[
|
||||||
center_v_line.copy().shift(vect)
|
center_v_line.copy().shift(vect)
|
||||||
for vect in LEFT, RIGHT
|
for vect in (LEFT, RIGHT)
|
||||||
])
|
])
|
||||||
outer_v_lines.set_color(GREEN)
|
outer_v_lines.set_color(GREEN)
|
||||||
dot = Dot(color = YELLOW)
|
dot = Dot(color = YELLOW)
|
||||||
|
@ -2101,7 +2101,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations):
|
||||||
"-\\cos", "\\sin", "\\cos"
|
"-\\cos", "\\sin", "\\cos"
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
for arg in "x", "0"
|
for arg in ("x", "0")
|
||||||
]
|
]
|
||||||
arrows = VGroup(*[
|
arrows = VGroup(*[
|
||||||
Arrow(
|
Arrow(
|
||||||
|
@ -2268,7 +2268,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations):
|
||||||
("\\frac{d^4 f}{dx^4}", "(", arg, ")"),
|
("\\frac{d^4 f}{dx^4}", "(", arg, ")"),
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
for arg in "x", "0", "a"
|
for arg in ("x", "0", "a")
|
||||||
]
|
]
|
||||||
derivs_at_x.arrange_submobjects(DOWN, buff = MED_LARGE_BUFF)
|
derivs_at_x.arrange_submobjects(DOWN, buff = MED_LARGE_BUFF)
|
||||||
derivs_at_x.scale_to_fit_height(FRAME_HEIGHT - MED_LARGE_BUFF)
|
derivs_at_x.scale_to_fit_height(FRAME_HEIGHT - MED_LARGE_BUFF)
|
||||||
|
@ -2513,7 +2513,7 @@ class ExpPolynomial(TranslationOfInformation, ExampleApproximationWithExp):
|
||||||
TexMobject("e^%s"%s).set_color(c)
|
TexMobject("e^%s"%s).set_color(c)
|
||||||
for c in self.colors
|
for c in self.colors
|
||||||
])
|
])
|
||||||
for s in "x", "0"
|
for s in ("x", "0")
|
||||||
]
|
]
|
||||||
derivs_at_x.submobjects[0] = self.e_to_x.target
|
derivs_at_x.submobjects[0] = self.e_to_x.target
|
||||||
arrows = VGroup(*[
|
arrows = VGroup(*[
|
||||||
|
@ -2698,7 +2698,7 @@ class SecondTermIntuition(AreaIsDerivative):
|
||||||
new_t_max = target,
|
new_t_max = target,
|
||||||
run_time = 3,
|
run_time = 3,
|
||||||
)
|
)
|
||||||
self.func_name = func_name
|
self.__name__ = func_name
|
||||||
|
|
||||||
def write_derivative(self):
|
def write_derivative(self):
|
||||||
deriv = TexMobject("\\frac{df_{\\text{area}}}{dx}(x)")
|
deriv = TexMobject("\\frac{df_{\\text{area}}}{dx}(x)")
|
||||||
|
@ -2826,7 +2826,7 @@ class SecondTermIntuition(AreaIsDerivative):
|
||||||
tex_scale_factor = 0.7
|
tex_scale_factor = 0.7
|
||||||
base_line = Line(*[
|
base_line = Line(*[
|
||||||
triangle.get_corner(DOWN+vect)
|
triangle.get_corner(DOWN+vect)
|
||||||
for vect in LEFT, RIGHT
|
for vect in (LEFT, RIGHT)
|
||||||
])
|
])
|
||||||
base_line.set_color(RED)
|
base_line.set_color(RED)
|
||||||
base_label = TextMobject("Base = ", "$(x-a)$")
|
base_label = TextMobject("Base = ", "$(x-a)$")
|
||||||
|
@ -2905,7 +2905,7 @@ class SecondTermIntuition(AreaIsDerivative):
|
||||||
def walk_through_taylor_terms(self):
|
def walk_through_taylor_terms(self):
|
||||||
mini_area, mini_rect, mini_triangle = [
|
mini_area, mini_rect, mini_triangle = [
|
||||||
mob.copy()
|
mob.copy()
|
||||||
for mob in self.dark_area, self.rect, self.triangle
|
for mob in (self.dark_area, self.rect, self.triangle)
|
||||||
]
|
]
|
||||||
mini_area.set_fill(BLUE_E, opacity = 1)
|
mini_area.set_fill(BLUE_E, opacity = 1)
|
||||||
mini_area.scale_to_fit_height(1)
|
mini_area.scale_to_fit_height(1)
|
||||||
|
@ -2939,7 +2939,7 @@ class SecondTermIntuition(AreaIsDerivative):
|
||||||
part.add_to_back(BackgroundRectangle(part))
|
part.add_to_back(BackgroundRectangle(part))
|
||||||
|
|
||||||
new_func_name = TexMobject("f_{\\text{area}}(a)")
|
new_func_name = TexMobject("f_{\\text{area}}(a)")
|
||||||
new_func_name.replace(self.func_name)
|
new_func_name.replace(self.__name__)
|
||||||
|
|
||||||
self.play(FadeIn(
|
self.play(FadeIn(
|
||||||
geometric_taylor,
|
geometric_taylor,
|
||||||
|
@ -2950,7 +2950,7 @@ class SecondTermIntuition(AreaIsDerivative):
|
||||||
self.play(
|
self.play(
|
||||||
FadeIn(VGroup(*analytic_taylor[:3])),
|
FadeIn(VGroup(*analytic_taylor[:3])),
|
||||||
self.dark_area.set_fill, BLUE_E, 1,
|
self.dark_area.set_fill, BLUE_E, 1,
|
||||||
Transform(self.func_name, new_func_name)
|
Transform(self.__name__, new_func_name)
|
||||||
)
|
)
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(
|
self.play(
|
||||||
|
@ -3302,7 +3302,7 @@ class BoundedRadiusOfConvergence(CubicAndQuarticApproximations):
|
||||||
self.coords_to_point(x, 2),
|
self.coords_to_point(x, 2),
|
||||||
color = WHITE
|
color = WHITE
|
||||||
)
|
)
|
||||||
for x in -1, 1
|
for x in (-1, 1)
|
||||||
])
|
])
|
||||||
|
|
||||||
colors = list(self.colors) + [GREEN, MAROON_B, PINK]
|
colors = list(self.colors) + [GREEN, MAROON_B, PINK]
|
||||||
|
@ -3400,15 +3400,15 @@ class RadiusOfConvergenceForLnX(ExpGraphConvergence):
|
||||||
v_lines = [
|
v_lines = [
|
||||||
DashedLine(*[
|
DashedLine(*[
|
||||||
self.coords_to_point(x, y)
|
self.coords_to_point(x, y)
|
||||||
for y in -2, 2
|
for y in (-2, 2)
|
||||||
])
|
])
|
||||||
for x in 0, 1, 2
|
for x in (0, 1, 2)
|
||||||
]
|
]
|
||||||
outer_v_lines = VGroup(*v_lines[::2])
|
outer_v_lines = VGroup(*v_lines[::2])
|
||||||
center_v_line = VGroup(v_lines[1])
|
center_v_line = VGroup(v_lines[1])
|
||||||
input_v_line = Line(*[
|
input_v_line = Line(*[
|
||||||
self.coords_to_point(self.convergent_example, y)
|
self.coords_to_point(self.convergent_example, y)
|
||||||
for y in -4, 3
|
for y in (-4, 3)
|
||||||
])
|
])
|
||||||
input_v_line.set_stroke(WHITE, width = 2)
|
input_v_line.set_stroke(WHITE, width = 2)
|
||||||
|
|
||||||
|
@ -3535,7 +3535,7 @@ class RadiusOfConvergenceForLnX(ExpGraphConvergence):
|
||||||
def write_radius_of_convergence(self):
|
def write_radius_of_convergence(self):
|
||||||
line = Line(*[
|
line = Line(*[
|
||||||
self.coords_to_point(x, 0)
|
self.coords_to_point(x, 0)
|
||||||
for x in 1, 2
|
for x in (1, 2)
|
||||||
])
|
])
|
||||||
line.set_color(YELLOW)
|
line.set_color(YELLOW)
|
||||||
brace = Brace(line, DOWN)
|
brace = Brace(line, DOWN)
|
||||||
|
|
|
@ -331,7 +331,7 @@ class GraphCarTrajectory(GraphScene):
|
||||||
def introduce_graph(self, graph, origin):
|
def introduce_graph(self, graph, origin):
|
||||||
h_line, v_line = [
|
h_line, v_line = [
|
||||||
Line(origin, origin, color = color, stroke_width = 2)
|
Line(origin, origin, color = color, stroke_width = 2)
|
||||||
for color in TIME_COLOR, DISTANCE_COLOR
|
for color in (TIME_COLOR, DISTANCE_COLOR)
|
||||||
]
|
]
|
||||||
def h_update(h_line, proportion = 1):
|
def h_update(h_line, proportion = 1):
|
||||||
end = graph.point_from_proportion(proportion)
|
end = graph.point_from_proportion(proportion)
|
||||||
|
@ -931,7 +931,7 @@ class CompareTwoVerySimilarTimes(CompareTwoTimes):
|
||||||
for mob in formula
|
for mob in formula
|
||||||
if mob.get_color() == Color(color)
|
if mob.get_color() == Color(color)
|
||||||
])
|
])
|
||||||
for color in DISTANCE_COLOR, TIME_COLOR
|
for color in (DISTANCE_COLOR, TIME_COLOR)
|
||||||
]
|
]
|
||||||
ds_brace = Brace(ds_symbols, UP)
|
ds_brace = Brace(ds_symbols, UP)
|
||||||
ds_text = ds_brace.get_text("$ds$", buff = SMALL_BUFF)
|
ds_text = ds_brace.get_text("$ds$", buff = SMALL_BUFF)
|
||||||
|
@ -1086,7 +1086,7 @@ class DsOverDtGraphically(GraphCarTrajectory, ZoomedScene):
|
||||||
line_class = Line,
|
line_class = Line,
|
||||||
line_kwargs = {"color" : MAROON_B}
|
line_kwargs = {"color" : MAROON_B}
|
||||||
)
|
)
|
||||||
for time in self.end_time, self.end_time + self.dt
|
for time in (self.end_time, self.end_time + self.dt)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -1285,7 +1285,7 @@ class SecantLineToTangentLine(GraphCarTrajectory, DefineTrueDerivative):
|
||||||
def get_ds_dt_group(self, dt, animate = False):
|
def get_ds_dt_group(self, dt, animate = False):
|
||||||
points = [
|
points = [
|
||||||
self.input_to_graph_point(time, self.graph)
|
self.input_to_graph_point(time, self.graph)
|
||||||
for time in self.curr_time, self.curr_time+dt
|
for time in (self.curr_time, self.curr_time+dt)
|
||||||
]
|
]
|
||||||
dots = map(Dot, points)
|
dots = map(Dot, points)
|
||||||
for dot in dots:
|
for dot in dots:
|
||||||
|
@ -1453,7 +1453,7 @@ class SecantLineToTangentLine(GraphCarTrajectory, DefineTrueDerivative):
|
||||||
TextMobject(
|
TextMobject(
|
||||||
"$dt$", "is", "not", s
|
"$dt$", "is", "not", s
|
||||||
)
|
)
|
||||||
for s in "``infinitely small''", "0"
|
for s in ("``infinitely small''", "0")
|
||||||
]
|
]
|
||||||
for phrase in phrases:
|
for phrase in phrases:
|
||||||
phrase[0].set_color(TIME_COLOR)
|
phrase[0].set_color(TIME_COLOR)
|
||||||
|
@ -1646,7 +1646,7 @@ class TCubedExample(SecantLineToTangentLine):
|
||||||
self.play(Write(ds_dt_group, run_time = 2))
|
self.play(Write(ds_dt_group, run_time = 2))
|
||||||
self.play(
|
self.play(
|
||||||
FadeIn(lhs),
|
FadeIn(lhs),
|
||||||
*[mob.restore for mob in ds, dt]
|
*[mob.restore for mob in (ds, dt)]
|
||||||
)
|
)
|
||||||
self.play(ShowCreation(v_lines[0]))
|
self.play(ShowCreation(v_lines[0]))
|
||||||
self.wait()
|
self.wait()
|
||||||
|
@ -1690,7 +1690,7 @@ class TCubedExample(SecantLineToTangentLine):
|
||||||
"dashed_segment_length" : 0.05,
|
"dashed_segment_length" : 0.05,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
for time in self.start_time, self.start_time+self.start_dt
|
for time in (self.start_time, self.start_time+self.start_dt)
|
||||||
])
|
])
|
||||||
|
|
||||||
def brace_for_details(self):
|
def brace_for_details(self):
|
||||||
|
@ -2315,7 +2315,7 @@ class TinyMovement(ZoomedScene):
|
||||||
|
|
||||||
dots = VGroup(*[
|
dots = VGroup(*[
|
||||||
Dot(point, radius = self.distance/10)
|
Dot(point, radius = self.distance/10)
|
||||||
for point in wheel_point, target_wheel_point
|
for point in (wheel_point, target_wheel_point)
|
||||||
])
|
])
|
||||||
brace = Brace(Line(ORIGIN, RIGHT))
|
brace = Brace(Line(ORIGIN, RIGHT))
|
||||||
distance_label = TexMobject(self.distance_label)
|
distance_label = TexMobject(self.distance_label)
|
||||||
|
|
|
@ -99,7 +99,7 @@ class ContrastAbstractAndConcrete(Scene):
|
||||||
t_max = 12*np.pi,
|
t_max = 12*np.pi,
|
||||||
num_anchor_points = 100,
|
num_anchor_points = 100,
|
||||||
)
|
)
|
||||||
for denom in 12.0, 4.0
|
for denom in (12.0, 4.0)
|
||||||
]
|
]
|
||||||
for spring in compact_spring, extended_spring:
|
for spring in compact_spring, extended_spring:
|
||||||
spring.scale(0.5)
|
spring.scale(0.5)
|
||||||
|
@ -253,7 +253,7 @@ class DerivativeOfXSquaredAsGraph(GraphScene, ZoomedScene, PiCreatureScene):
|
||||||
color = RED,
|
color = RED,
|
||||||
dashed_segment_length = 0.025
|
dashed_segment_length = 0.025
|
||||||
)
|
)
|
||||||
for x in self.start_x, self.start_x+self.dx
|
for x in (self.start_x, self.start_x+self.dx)
|
||||||
]
|
]
|
||||||
|
|
||||||
df_dx = TexMobject("\\frac{df}{dx} ?")
|
df_dx = TexMobject("\\frac{df}{dx} ?")
|
||||||
|
@ -534,10 +534,10 @@ class NudgeSideLengthOfSquare(PiCreatureScene):
|
||||||
self.play(
|
self.play(
|
||||||
*[
|
*[
|
||||||
mob.restore
|
mob.restore
|
||||||
for mob in r1, r2, s
|
for mob in (r1, r2, s)
|
||||||
]+[
|
]+[
|
||||||
Write(symbol)
|
Write(symbol)
|
||||||
for symbol in equals, plus1, plus2
|
for symbol in (equals, plus1, plus2)
|
||||||
],
|
],
|
||||||
run_time = 2
|
run_time = 2
|
||||||
)
|
)
|
||||||
|
@ -612,7 +612,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene):
|
||||||
FadeOut(example_value),
|
FadeOut(example_value),
|
||||||
*[
|
*[
|
||||||
mob.restore
|
mob.restore
|
||||||
for mob in xs, dxs, text
|
for mob in (xs, dxs, text)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
self.remove(text)
|
self.remove(text)
|
||||||
|
@ -652,7 +652,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene):
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
self.play(*[
|
self.play(*[
|
||||||
mob.restore
|
mob.restore
|
||||||
for mob in self.dxs, text
|
for mob in (self.dxs, text)
|
||||||
] + [
|
] + [
|
||||||
self.pi_creature.change_mode, "erm"
|
self.pi_creature.change_mode, "erm"
|
||||||
])
|
])
|
||||||
|
@ -889,7 +889,7 @@ class NudgeSideLengthOfCube(Scene):
|
||||||
for piece in dv_pieces
|
for piece in dv_pieces
|
||||||
if piece.type == target_type
|
if piece.type == target_type
|
||||||
])
|
])
|
||||||
for target_type in "face", "bar", "corner_cube"
|
for target_type in ("face", "bar", "corner_cube")
|
||||||
]
|
]
|
||||||
|
|
||||||
def write_df_equation(self):
|
def write_df_equation(self):
|
||||||
|
@ -1023,7 +1023,7 @@ class NudgeSideLengthOfCube(Scene):
|
||||||
self.shrink_dx("Derivative is written", restore = False)
|
self.shrink_dx("Derivative is written", restore = False)
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(mob.fade, 0.7)
|
ApplyMethod(mob.fade, 0.7)
|
||||||
for mob in extra_stuff, inner_dx
|
for mob in (extra_stuff, inner_dx)
|
||||||
])
|
])
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
|
|
||||||
|
@ -1470,7 +1470,7 @@ class PowerRuleAlgebra(Scene):
|
||||||
for submob, tex in product_part_tex_pairs
|
for submob, tex in product_part_tex_pairs
|
||||||
if tex == target_tex
|
if tex == target_tex
|
||||||
])
|
])
|
||||||
for target_tex in "x", "dx"
|
for target_tex in ("x", "dx")
|
||||||
]
|
]
|
||||||
|
|
||||||
x_to_n = TexMobject("x^n")
|
x_to_n = TexMobject("x^n")
|
||||||
|
@ -1759,7 +1759,7 @@ class OneOverX(PiCreatureScene, GraphScene):
|
||||||
color = self.df_color,
|
color = self.df_color,
|
||||||
stroke_width = 2
|
stroke_width = 2
|
||||||
).move_to(rect.get_corner(UP+LEFT), LEFT)
|
).move_to(rect.get_corner(UP+LEFT), LEFT)
|
||||||
for rect in rect_group.rectangle, new_rect
|
for rect in (rect_group.rectangle, new_rect)
|
||||||
])
|
])
|
||||||
|
|
||||||
v_lines = VGroup(*[
|
v_lines = VGroup(*[
|
||||||
|
@ -1768,7 +1768,7 @@ class OneOverX(PiCreatureScene, GraphScene):
|
||||||
color = self.dx_color,
|
color = self.dx_color,
|
||||||
stroke_width = 2
|
stroke_width = 2
|
||||||
).move_to(rect.get_corner(DOWN+RIGHT), DOWN)
|
).move_to(rect.get_corner(DOWN+RIGHT), DOWN)
|
||||||
for rect in rect_group.rectangle, new_rect
|
for rect in (rect_group.rectangle, new_rect)
|
||||||
])
|
])
|
||||||
|
|
||||||
dx_brace = Brace(v_lines, UP, buff = 0)
|
dx_brace = Brace(v_lines, UP, buff = 0)
|
||||||
|
@ -1921,7 +1921,7 @@ class OneOverX(PiCreatureScene, GraphScene):
|
||||||
|
|
||||||
result.x_brace, result.recip_brace = braces = [
|
result.x_brace, result.recip_brace = braces = [
|
||||||
Brace(result.rectangle, vect)
|
Brace(result.rectangle, vect)
|
||||||
for vect in UP, RIGHT
|
for vect in (UP, RIGHT)
|
||||||
]
|
]
|
||||||
result.labels = VGroup()
|
result.labels = VGroup()
|
||||||
for brace, label in zip(braces, [x_label, one_over_x_label]):
|
for brace, label in zip(braces, [x_label, one_over_x_label]):
|
||||||
|
@ -2047,7 +2047,7 @@ class SquareRootOfX(Scene):
|
||||||
|
|
||||||
bottom_brace, right_brace = braces = VGroup(*[
|
bottom_brace, right_brace = braces = VGroup(*[
|
||||||
Brace(square, vect)
|
Brace(square, vect)
|
||||||
for vect in DOWN, RIGHT
|
for vect in (DOWN, RIGHT)
|
||||||
])
|
])
|
||||||
for brace in braces:
|
for brace in braces:
|
||||||
brace.add(brace.get_text("$\\sqrt{x}$"))
|
brace.add(brace.get_text("$\\sqrt{x}$"))
|
||||||
|
|
|
@ -211,7 +211,7 @@ class DampenedSpring(Scene):
|
||||||
num_anchor_points = 100,
|
num_anchor_points = 100,
|
||||||
color = GREY,
|
color = GREY,
|
||||||
).shift(3*LEFT)
|
).shift(3*LEFT)
|
||||||
for denom in 12.0, 2.0
|
for denom in (12.0, 2.0)
|
||||||
]
|
]
|
||||||
for spring in compact_spring, extended_spring:
|
for spring in compact_spring, extended_spring:
|
||||||
spring.scale(0.5)
|
spring.scale(0.5)
|
||||||
|
@ -441,7 +441,7 @@ class SumRule(GraphScene):
|
||||||
line.save_state()
|
line.save_state()
|
||||||
sine_lines, parabola_lines = [
|
sine_lines, parabola_lines = [
|
||||||
VGroup(example_v_lines[i], nudged_v_lines[i])
|
VGroup(example_v_lines[i], nudged_v_lines[i])
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
]
|
]
|
||||||
faders = VGroup(*filter(
|
faders = VGroup(*filter(
|
||||||
lambda line : line not in example_v_lines,
|
lambda line : line not in example_v_lines,
|
||||||
|
@ -944,7 +944,7 @@ class IntroduceProductAsArea(ReconfigurableScene):
|
||||||
line, triangle, x_mob = self.x_slider
|
line, triangle, x_mob = self.x_slider
|
||||||
dx_line = Line(*[
|
dx_line = Line(*[
|
||||||
line.number_to_point(self.x_slider.x_val + num)
|
line.number_to_point(self.x_slider.x_val + num)
|
||||||
for num in 0, self.dx,
|
for num in (0, self.dx,)
|
||||||
])
|
])
|
||||||
dx_line.set_stroke(
|
dx_line.set_stroke(
|
||||||
self.df_box_kwargs["fill_color"],
|
self.df_box_kwargs["fill_color"],
|
||||||
|
@ -1943,7 +1943,7 @@ class GeneralizeChainRule(Scene):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*it.chain(*[
|
self.play(*it.chain(*[
|
||||||
[mob.scale_in_place, 1.2, mob.set_color, YELLOW]
|
[mob.scale_in_place, 1.2, mob.set_color, YELLOW]
|
||||||
for mob in example_inner, d_example_inner
|
for mob in (example_inner, d_example_inner)
|
||||||
]), rate_func = there_and_back)
|
]), rate_func = there_and_back)
|
||||||
self.play(Transform(
|
self.play(Transform(
|
||||||
example_inner.copy(), d_example_inner,
|
example_inner.copy(), d_example_inner,
|
||||||
|
|
|
@ -100,7 +100,7 @@ class DoublingPopulation(PiCreatureScene):
|
||||||
|
|
||||||
pop_brace, mass_brace = [
|
pop_brace, mass_brace = [
|
||||||
Brace(function[0], DOWN)
|
Brace(function[0], DOWN)
|
||||||
for function in P_t, M_t
|
for function in (P_t, M_t)
|
||||||
]
|
]
|
||||||
for brace, word in (pop_brace, "size"), (mass_brace, "mass"):
|
for brace, word in (pop_brace, "size"), (mass_brace, "mass"):
|
||||||
text = brace.get_text("Population %s"%word)
|
text = brace.get_text("Population %s"%word)
|
||||||
|
@ -601,7 +601,7 @@ class FakeDiagram(TeacherStudentsScene):
|
||||||
x_min = -8,
|
x_min = -8,
|
||||||
x_max = 2 + dx
|
x_max = 2 + dx
|
||||||
)
|
)
|
||||||
for dx in 0.25, 0
|
for dx in (0.25, 0)
|
||||||
])
|
])
|
||||||
for graph in graphs:
|
for graph in graphs:
|
||||||
end_point = graph.points[-1]
|
end_point = graph.points[-1]
|
||||||
|
@ -775,7 +775,7 @@ class AnalyzeExponentRatio(PiCreatureScene):
|
||||||
]
|
]
|
||||||
words = VGroup(*[
|
words = VGroup(*[
|
||||||
TextMobject(s, " ideas")
|
TextMobject(s, " ideas")
|
||||||
for s in "Additive", "Multiplicative"
|
for s in ("Additive", "Multiplicative")
|
||||||
])
|
])
|
||||||
words[0].move_to(words[1], LEFT)
|
words[0].move_to(words[1], LEFT)
|
||||||
words.set_color(BLUE)
|
words.set_color(BLUE)
|
||||||
|
@ -812,14 +812,14 @@ class AnalyzeExponentRatio(PiCreatureScene):
|
||||||
run_time = 2,
|
run_time = 2,
|
||||||
rate_func = squish_rate_func(smooth, 0.5, 1)
|
rate_func = squish_rate_func(smooth, 0.5, 1)
|
||||||
)
|
)
|
||||||
for mob in one, lp, rp
|
for mob in (one, lp, rp)
|
||||||
] + [
|
] + [
|
||||||
ReplacementTransform(
|
ReplacementTransform(
|
||||||
mob, extracted_two_to_t,
|
mob, extracted_two_to_t,
|
||||||
path_arc = np.pi/2,
|
path_arc = np.pi/2,
|
||||||
run_time = 2,
|
run_time = 2,
|
||||||
)
|
)
|
||||||
for mob in two_to_t, VGroup(*two_to_t_two_to_dt[:2])
|
for mob in (two_to_t, VGroup(*two_to_t_two_to_dt[:2]))
|
||||||
] + [
|
] + [
|
||||||
lhs.next_to, extracted_two_to_t, LEFT
|
lhs.next_to, extracted_two_to_t, LEFT
|
||||||
])
|
])
|
||||||
|
@ -1006,7 +1006,7 @@ class CompareTwoConstantToEightConstant(PiCreatureScene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
two_deriv, eight_deriv = derivs = VGroup(*[
|
two_deriv, eight_deriv = derivs = VGroup(*[
|
||||||
self.get_derivative_expression(base)
|
self.get_derivative_expression(base)
|
||||||
for base in 2, 8
|
for base in (2, 8)
|
||||||
])
|
])
|
||||||
|
|
||||||
derivs.arrange_submobjects(
|
derivs.arrange_submobjects(
|
||||||
|
@ -1268,7 +1268,7 @@ class ApplyChainRule(TeacherStudentsScene):
|
||||||
path_arc = -np.pi,
|
path_arc = -np.pi,
|
||||||
run_time = 2
|
run_time = 2
|
||||||
)
|
)
|
||||||
for tex in "e^", "{3", "t}"
|
for tex in ("e^", "{3", "t}")
|
||||||
] + [
|
] + [
|
||||||
Write(deriv_equation.get_part_by_tex("="))
|
Write(deriv_equation.get_part_by_tex("="))
|
||||||
])
|
])
|
||||||
|
@ -1663,7 +1663,7 @@ class TemperatureOverTimeOfWarmWater(GraphScene):
|
||||||
)
|
)
|
||||||
h_line = DashedLine(*[
|
h_line = DashedLine(*[
|
||||||
self.coords_to_point(x, self.T_room)
|
self.coords_to_point(x, self.T_room)
|
||||||
for x in self.x_min, self.x_max
|
for x in (self.x_min, self.x_max)
|
||||||
])
|
])
|
||||||
T_room_label = TexMobject("T_{\\text{room}}")
|
T_room_label = TexMobject("T_{\\text{room}}")
|
||||||
T_room_label.next_to(h_line, LEFT)
|
T_room_label.next_to(h_line, LEFT)
|
||||||
|
|
|
@ -563,7 +563,7 @@ class Ladder(VMobject):
|
||||||
def generate_points(self):
|
def generate_points(self):
|
||||||
left_line, right_line = [
|
left_line, right_line = [
|
||||||
Line(ORIGIN, self.height*UP).shift(self.width*vect/2.0)
|
Line(ORIGIN, self.height*UP).shift(self.width*vect/2.0)
|
||||||
for vect in LEFT, RIGHT
|
for vect in (LEFT, RIGHT)
|
||||||
]
|
]
|
||||||
rungs = [
|
rungs = [
|
||||||
Line(
|
Line(
|
||||||
|
@ -677,7 +677,7 @@ class RelatedRatesExample(ThreeDScene):
|
||||||
|
|
||||||
down_arrow, left_arrow = [
|
down_arrow, left_arrow = [
|
||||||
Arrow(ORIGIN, vect, color = YELLOW, buff = 0)
|
Arrow(ORIGIN, vect, color = YELLOW, buff = 0)
|
||||||
for vect in DOWN, LEFT
|
for vect in (DOWN, LEFT)
|
||||||
]
|
]
|
||||||
down_arrow.shift(y_line.get_start()+MED_SMALL_BUFF*RIGHT)
|
down_arrow.shift(y_line.get_start()+MED_SMALL_BUFF*RIGHT)
|
||||||
left_arrow.shift(x_line.get_start()+SMALL_BUFF*DOWN)
|
left_arrow.shift(x_line.get_start()+SMALL_BUFF*DOWN)
|
||||||
|
@ -1302,7 +1302,7 @@ class CompareLadderAndCircle(PiCreatureScene, ThreeDScene):
|
||||||
for i, j in enumerate([1, 0, 3, 5, 4, 7])
|
for i, j in enumerate([1, 0, 3, 5, 4, 7])
|
||||||
]+[
|
]+[
|
||||||
Write(derivative[j])
|
Write(derivative[j])
|
||||||
for j in 2, 6
|
for j in (2, 6)
|
||||||
])
|
])
|
||||||
self.play(
|
self.play(
|
||||||
self.pi_creature.change_mode, "pondering",
|
self.pi_creature.change_mode, "pondering",
|
||||||
|
@ -1508,7 +1508,7 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample):
|
||||||
)
|
)
|
||||||
]+[
|
]+[
|
||||||
Write(derivative[1][j])
|
Write(derivative[1][j])
|
||||||
for j in 3, 7
|
for j in (3, 7)
|
||||||
])
|
])
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ReplacementTransform(
|
ReplacementTransform(
|
||||||
|
@ -1729,7 +1729,7 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample):
|
||||||
buff = SMALL_BUFF/self.zoom_factor,
|
buff = SMALL_BUFF/self.zoom_factor,
|
||||||
tip_length = 0.15/self.zoom_factor
|
tip_length = 0.15/self.zoom_factor
|
||||||
)
|
)
|
||||||
for mob in dot, new_dot
|
for mob in (dot, new_dot)
|
||||||
]
|
]
|
||||||
|
|
||||||
for line, tex, vect in (dy_line, "dy", RIGHT), (dx_line, "dx", UP):
|
for line, tex, vect in (dy_line, "dy", RIGHT), (dx_line, "dx", UP):
|
||||||
|
@ -2025,7 +2025,7 @@ class AlternateExample(ZoomedScene):
|
||||||
|
|
||||||
arrows = VGroup(*[
|
arrows = VGroup(*[
|
||||||
Arrow(word, part)
|
Arrow(word, part)
|
||||||
for part in lhs, rhs
|
for part in (lhs, rhs)
|
||||||
])
|
])
|
||||||
|
|
||||||
self.play(FocusOn(formula))
|
self.play(FocusOn(formula))
|
||||||
|
@ -2072,7 +2072,7 @@ class AlternateExample(ZoomedScene):
|
||||||
)
|
)
|
||||||
derivative_rects = [
|
derivative_rects = [
|
||||||
BackgroundRectangle(VGroup(*subset))
|
BackgroundRectangle(VGroup(*subset))
|
||||||
for subset in derivative[:2], derivative[2:]
|
for subset in (derivative[:2], derivative[2:])
|
||||||
]
|
]
|
||||||
derivative_rects[1].stretch(1.05, dim = 0)
|
derivative_rects[1].stretch(1.05, dim = 0)
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ class RefreshOnDerivativeDefinition(GraphScene):
|
||||||
line_class = DashedLine,
|
line_class = DashedLine,
|
||||||
color = RED
|
color = RED
|
||||||
)
|
)
|
||||||
for nudge in 0, self.start_dx
|
for nudge in (0, self.start_dx)
|
||||||
]
|
]
|
||||||
nudged_x_v_line.save_state()
|
nudged_x_v_line.save_state()
|
||||||
ss_group = self.get_secant_slope_group(
|
ss_group = self.get_secant_slope_group(
|
||||||
|
@ -343,7 +343,7 @@ class RantOpenAndClose(Scene):
|
||||||
start, "Rant on infinitesimals", "$>$",
|
start, "Rant on infinitesimals", "$>$",
|
||||||
arg_separator = ""
|
arg_separator = ""
|
||||||
)
|
)
|
||||||
for start in "$<$", "$<$/"
|
for start in ("$<$", "$<$/")
|
||||||
]
|
]
|
||||||
self.play(FadeIn(opening))
|
self.play(FadeIn(opening))
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
|
@ -439,7 +439,7 @@ class DiscussLowercaseDs(RefreshOnDerivativeDefinition, PiCreatureScene, ZoomedS
|
||||||
lhs.get_part_by_tex(tex)[0],
|
lhs.get_part_by_tex(tex)[0],
|
||||||
stretch = True,
|
stretch = True,
|
||||||
).scale_in_place(1.5).rotate_in_place(-np.pi/12)
|
).scale_in_place(1.5).rotate_in_place(-np.pi/12)
|
||||||
for tex in "df", "dx"
|
for tex in ("df", "dx")
|
||||||
])
|
])
|
||||||
d_words = TextMobject("""
|
d_words = TextMobject("""
|
||||||
Limit idea is
|
Limit idea is
|
||||||
|
@ -452,7 +452,7 @@ class DiscussLowercaseDs(RefreshOnDerivativeDefinition, PiCreatureScene, ZoomedS
|
||||||
Rectangle(color = GREEN_B).replace(
|
Rectangle(color = GREEN_B).replace(
|
||||||
mob, stretch = True
|
mob, stretch = True
|
||||||
)
|
)
|
||||||
for mob in lhs, rhs.target
|
for mob in (lhs, rhs.target)
|
||||||
]
|
]
|
||||||
for rect in rects:
|
for rect in rects:
|
||||||
rect.stretch_to_fit_width(rect.get_width()+2*MED_SMALL_BUFF)
|
rect.stretch_to_fit_width(rect.get_width()+2*MED_SMALL_BUFF)
|
||||||
|
@ -654,7 +654,7 @@ class OtherViewsOfDx(TeacherStudentsScene):
|
||||||
VGroup(*statement.get_parts_by_tex(
|
VGroup(*statement.get_parts_by_tex(
|
||||||
tex, substring = False
|
tex, substring = False
|
||||||
)).set_color(GREEN)
|
)).set_color(GREEN)
|
||||||
for tex in "$h$", "$dx$"
|
for tex in ("$h$", "$dx$")
|
||||||
]
|
]
|
||||||
|
|
||||||
#Question
|
#Question
|
||||||
|
@ -1165,14 +1165,14 @@ class GraphLimitExpression(GraphScene):
|
||||||
(limit_x+basically_zero, limit_x+delta),
|
(limit_x+basically_zero, limit_x+delta),
|
||||||
]
|
]
|
||||||
]).set_stroke(width = input_range_stroke_width)
|
]).set_stroke(width = input_range_stroke_width)
|
||||||
for func in (lambda h : 0), self.func
|
for func in ((lambda h : 0), self.func)
|
||||||
]
|
]
|
||||||
result.epsilon_lines = VGroup(*[
|
result.epsilon_lines = VGroup(*[
|
||||||
dashed_line.copy().move_to(
|
dashed_line.copy().move_to(
|
||||||
self.coords_to_point(limit_x, 0)[0]*RIGHT+\
|
self.coords_to_point(limit_x, 0)[0]*RIGHT+\
|
||||||
result.output_range.get_edge_center(vect)[1]*UP
|
result.output_range.get_edge_center(vect)[1]*UP
|
||||||
)
|
)
|
||||||
for vect in DOWN, UP
|
for vect in (DOWN, UP)
|
||||||
])
|
])
|
||||||
|
|
||||||
result.digest_mobject_attrs()
|
result.digest_mobject_attrs()
|
||||||
|
@ -1588,7 +1588,7 @@ class EpsilonDeltaExample(GraphLimitExpression, ZoomedScene):
|
||||||
Line(
|
Line(
|
||||||
ORIGIN, line_length*RIGHT,
|
ORIGIN, line_length*RIGHT,
|
||||||
).move_to(self.coords_to_point(0, limit_value+nudge))
|
).move_to(self.coords_to_point(0, limit_value+nudge))
|
||||||
for nudge in 0, -epsilon, epsilon
|
for nudge in (0, -epsilon, epsilon)
|
||||||
]
|
]
|
||||||
result.limit_line = lines[0]
|
result.limit_line = lines[0]
|
||||||
result.limit_line.set_stroke(RED, width = 3)
|
result.limit_line.set_stroke(RED, width = 3)
|
||||||
|
@ -1599,7 +1599,7 @@ class EpsilonDeltaExample(GraphLimitExpression, ZoomedScene):
|
||||||
brace.copy().scale_to_fit_height(
|
brace.copy().scale_to_fit_height(
|
||||||
group.get_height()
|
group.get_height()
|
||||||
).next_to(group, RIGHT, SMALL_BUFF)
|
).next_to(group, RIGHT, SMALL_BUFF)
|
||||||
for i in 1, 2
|
for i in (1, 2)
|
||||||
for group in [VGroup(lines[0], lines[i])]
|
for group in [VGroup(lines[0], lines[i])]
|
||||||
])
|
])
|
||||||
result.labels = VGroup(*[
|
result.labels = VGroup(*[
|
||||||
|
@ -1623,7 +1623,7 @@ class EpsilonDeltaExample(GraphLimitExpression, ZoomedScene):
|
||||||
)
|
)
|
||||||
result.braces = VGroup(*[
|
result.braces = VGroup(*[
|
||||||
brace.copy().move_to(self.coords_to_point(x, 0))
|
brace.copy().move_to(self.coords_to_point(x, 0))
|
||||||
for x in -delta/2, delta/2
|
for x in (-delta/2, delta/2)
|
||||||
])
|
])
|
||||||
result.braces.shift(self.holes[0].get_height()*DOWN)
|
result.braces.shift(self.holes[0].get_height()*DOWN)
|
||||||
result.labels = VGroup(*[
|
result.labels = VGroup(*[
|
||||||
|
@ -1897,11 +1897,11 @@ class LHopitalExample(LimitCounterExample, PiCreatureScene, ZoomedScene, Reconfi
|
||||||
line_class = DashedLine,
|
line_class = DashedLine,
|
||||||
color = self.x_color
|
color = self.x_color
|
||||||
)
|
)
|
||||||
for x in 1, -1
|
for x in (1, -1)
|
||||||
]
|
]
|
||||||
hole, alt_hole = [
|
hole, alt_hole = [
|
||||||
self.get_hole(x, self.func(x))
|
self.get_hole(x, self.func(x))
|
||||||
for x in 1, -1
|
for x in (1, -1)
|
||||||
]
|
]
|
||||||
ed_group = self.get_epsilon_delta_group(
|
ed_group = self.get_epsilon_delta_group(
|
||||||
self.big_delta, limit_x = 1,
|
self.big_delta, limit_x = 1,
|
||||||
|
@ -2090,7 +2090,7 @@ class LHopitalExample(LimitCounterExample, PiCreatureScene, ZoomedScene, Reconfi
|
||||||
fill_opacity = 0.75,
|
fill_opacity = 0.75,
|
||||||
fill_color = BLACK,
|
fill_color = BLACK,
|
||||||
).next_to(self.coords_to_point(1, 0), vect, MED_LARGE_BUFF)
|
).next_to(self.coords_to_point(1, 0), vect, MED_LARGE_BUFF)
|
||||||
for vect in LEFT, RIGHT
|
for vect in (LEFT, RIGHT)
|
||||||
])
|
])
|
||||||
|
|
||||||
self.play(
|
self.play(
|
||||||
|
@ -2149,7 +2149,7 @@ class LHopitalExample(LimitCounterExample, PiCreatureScene, ZoomedScene, Reconfi
|
||||||
tip_length = arrow_tip_length,
|
tip_length = arrow_tip_length,
|
||||||
color = graph.get_color()
|
color = graph.get_color()
|
||||||
)
|
)
|
||||||
for graph in self.sine_graph, self.parabola
|
for graph in (self.sine_graph, self.parabola)
|
||||||
]
|
]
|
||||||
tex_arrow_pairs = [
|
tex_arrow_pairs = [
|
||||||
[("d\\big(", "\\sin(", "\\pi", "x", ")", "\\big)"), d_sine_arrow],
|
[("d\\big(", "\\sin(", "\\pi", "x", ")", "\\big)"), d_sine_arrow],
|
||||||
|
@ -2606,7 +2606,7 @@ class GeneralLHoptial(LHopitalExample):
|
||||||
tip_length = arrow_tip_length,
|
tip_length = arrow_tip_length,
|
||||||
color = graph.get_color()
|
color = graph.get_color()
|
||||||
)
|
)
|
||||||
for graph in self.f_graph, self.g_graph
|
for graph in (self.f_graph, self.g_graph)
|
||||||
]
|
]
|
||||||
v_labels = []
|
v_labels = []
|
||||||
for char, arrow in ("f", df_arrow), ("g", dg_arrow):
|
for char, arrow in ("f", df_arrow), ("g", dg_arrow):
|
||||||
|
@ -2881,7 +2881,7 @@ class NextVideo(TeacherStudentsScene):
|
||||||
])
|
])
|
||||||
]+[
|
]+[
|
||||||
Write(VGroup(*ftc.get_parts_by_tex(part)))
|
Write(VGroup(*ftc.get_parts_by_tex(part)))
|
||||||
for part in "-", "=", "over", "(x)"
|
for part in ("-", "=", "over", "(x)")
|
||||||
])
|
])
|
||||||
self.change_student_modes(*["pondering"]*3)
|
self.change_student_modes(*["pondering"]*3)
|
||||||
self.wait(3)
|
self.wait(3)
|
||||||
|
|
|
@ -653,7 +653,7 @@ class ConstantVelocityPlot(PlotVelocity):
|
||||||
def note_units(self):
|
def note_units(self):
|
||||||
x_line, y_line = lines = VGroup(*[
|
x_line, y_line = lines = VGroup(*[
|
||||||
axis.main_line.copy()
|
axis.main_line.copy()
|
||||||
for axis in self.x_axis, self.y_axis
|
for axis in (self.x_axis, self.y_axis)
|
||||||
])
|
])
|
||||||
lines.set_color(TIME_COLOR)
|
lines.set_color(TIME_COLOR)
|
||||||
square = Square(
|
square = Square(
|
||||||
|
@ -665,7 +665,7 @@ class ConstantVelocityPlot(PlotVelocity):
|
||||||
square.replace(
|
square.replace(
|
||||||
VGroup(*[
|
VGroup(*[
|
||||||
VectorizedPoint(self.coords_to_point(i, i))
|
VectorizedPoint(self.coords_to_point(i, i))
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
]),
|
]),
|
||||||
stretch = True
|
stretch = True
|
||||||
)
|
)
|
||||||
|
@ -876,7 +876,7 @@ class PiecewiseConstantPlot(PlotVelocity):
|
||||||
FadeOut(self.pw_constant_graph),
|
FadeOut(self.pw_constant_graph),
|
||||||
*[
|
*[
|
||||||
m.restore
|
m.restore
|
||||||
for m in self.v_graph, self.v_graph_label
|
for m in (self.v_graph, self.v_graph_label)
|
||||||
]+[Animation(self.rects)]
|
]+[Animation(self.rects)]
|
||||||
)
|
)
|
||||||
for new_rects in self.rect_list[1:]:
|
for new_rects in self.rect_list[1:]:
|
||||||
|
@ -1022,7 +1022,7 @@ class PiecewiseConstantPlot(PlotVelocity):
|
||||||
|
|
||||||
self.play(*map(FadeOut, [
|
self.play(*map(FadeOut, [
|
||||||
group[1]
|
group[1]
|
||||||
for group in v_lines, h_lines, height_labels
|
for group in (v_lines, h_lines, height_labels)
|
||||||
]))
|
]))
|
||||||
self.play(
|
self.play(
|
||||||
v_lines[0].set_color, RED,
|
v_lines[0].set_color, RED,
|
||||||
|
@ -1368,7 +1368,7 @@ class CarJourneyApproximation(Scene):
|
||||||
"bottom_words" : "Approximated motion (5 jumps)",
|
"bottom_words" : "Approximated motion (5 jumps)",
|
||||||
}
|
}
|
||||||
def construct(self):
|
def construct(self):
|
||||||
points = [5*LEFT + v for v in UP, 2*DOWN]
|
points = [5*LEFT + v for v in (UP, 2*DOWN)]
|
||||||
cars = [Car().move_to(point) for point in points]
|
cars = [Car().move_to(point) for point in points]
|
||||||
h_line = Line(LEFT, RIGHT).scale(FRAME_X_RADIUS)
|
h_line = Line(LEFT, RIGHT).scale(FRAME_X_RADIUS)
|
||||||
words = [
|
words = [
|
||||||
|
@ -1539,7 +1539,7 @@ class AreaIsDerivative(PlotVelocity, ReconfigurableScene):
|
||||||
mob.get_left(), self.area.get_center(),
|
mob.get_left(), self.area.get_center(),
|
||||||
color = WHITE
|
color = WHITE
|
||||||
)
|
)
|
||||||
for mob in integral, s_T
|
for mob in (integral, s_T)
|
||||||
]
|
]
|
||||||
|
|
||||||
distance_word = TextMobject("Distance")
|
distance_word = TextMobject("Distance")
|
||||||
|
@ -1678,7 +1678,7 @@ class AreaIsDerivative(PlotVelocity, ReconfigurableScene):
|
||||||
formula1.get_part_by_tex(tex),
|
formula1.get_part_by_tex(tex),
|
||||||
formula2.get_part_by_tex(tex),
|
formula2.get_part_by_tex(tex),
|
||||||
)
|
)
|
||||||
for tex in "ds", "=", "v(T)", "dT"
|
for tex in ("ds", "=", "v(T)", "dT")
|
||||||
] + [
|
] + [
|
||||||
Write(formula2.get_part_by_tex("over"))
|
Write(formula2.get_part_by_tex("over"))
|
||||||
])
|
])
|
||||||
|
@ -1865,7 +1865,7 @@ class FindAntiderivative(Antiderivative):
|
||||||
run_time = 2,
|
run_time = 2,
|
||||||
path_arc = -np.pi/6.
|
path_arc = -np.pi/6.
|
||||||
)
|
)
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
])
|
])
|
||||||
self.change_mode("thinking")
|
self.change_mode("thinking")
|
||||||
self.wait()
|
self.wait()
|
||||||
|
@ -2172,7 +2172,7 @@ class LowerBound(AreaIsDerivative):
|
||||||
self.coords_to_point(d, 0),
|
self.coords_to_point(d, 0),
|
||||||
DOWN, MED_LARGE_BUFF
|
DOWN, MED_LARGE_BUFF
|
||||||
)
|
)
|
||||||
for d in 1, 7
|
for d in (1, 7)
|
||||||
]
|
]
|
||||||
tex_mobs = [new_integral]+new_antideriv_diff[1::2]+numbers
|
tex_mobs = [new_integral]+new_antideriv_diff[1::2]+numbers
|
||||||
for tex_mob in tex_mobs:
|
for tex_mob in tex_mobs:
|
||||||
|
@ -2353,7 +2353,7 @@ class FundamentalTheorem(GraphScene):
|
||||||
dx_brace.next_to, rects[i], DOWN, 0,
|
dx_brace.next_to, rects[i], DOWN, 0,
|
||||||
*[
|
*[
|
||||||
MaintainPositionRelativeTo(brace.label, brace)
|
MaintainPositionRelativeTo(brace.label, brace)
|
||||||
for brace in f_brace, dx_brace
|
for brace in (f_brace, dx_brace)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
self.wait()
|
self.wait()
|
||||||
|
@ -2419,7 +2419,7 @@ class FundamentalTheorem(GraphScene):
|
||||||
def show_integral_considering_continuum(self):
|
def show_integral_considering_continuum(self):
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(mob.set_fill, None, 0.2)
|
ApplyMethod(mob.set_fill, None, 0.2)
|
||||||
for mob in self.deriv, self.rhs
|
for mob in (self.deriv, self.rhs)
|
||||||
])
|
])
|
||||||
self.play(
|
self.play(
|
||||||
self.rects.restore,
|
self.rects.restore,
|
||||||
|
@ -2600,7 +2600,7 @@ class NegativeArea(GraphScene):
|
||||||
equation.get_part_by_tex(tex).get_top(),
|
equation.get_part_by_tex(tex).get_top(),
|
||||||
color = RED,
|
color = RED,
|
||||||
)
|
)
|
||||||
for tex in "ds", "v(t)"
|
for tex in ("ds", "v(t)")
|
||||||
])
|
])
|
||||||
|
|
||||||
self.play(
|
self.play(
|
||||||
|
|
|
@ -1149,9 +1149,9 @@ class Antiderivative(AverageOfSineStart):
|
||||||
(start_pi, end_pi), (start_zero, end_zero) = start_end_pairs = [
|
(start_pi, end_pi), (start_zero, end_zero) = start_end_pairs = [
|
||||||
[
|
[
|
||||||
m.get_part_by_tex(tex)
|
m.get_part_by_tex(tex)
|
||||||
for m in integral, rhs
|
for m in (integral, rhs)
|
||||||
]
|
]
|
||||||
for tex in "\\pi", "0"
|
for tex in ("\\pi", "0")
|
||||||
]
|
]
|
||||||
|
|
||||||
for tex_mob in integral, rhs:
|
for tex_mob in integral, rhs:
|
||||||
|
@ -1271,7 +1271,7 @@ class Antiderivative(AverageOfSineStart):
|
||||||
TexMobject("\\over\\,").stretch_to_fit_width(
|
TexMobject("\\over\\,").stretch_to_fit_width(
|
||||||
mob.get_width()
|
mob.get_width()
|
||||||
).move_to(mob)
|
).move_to(mob)
|
||||||
for mob in integral, rhs_without_eq
|
for mob in (integral, rhs_without_eq)
|
||||||
])
|
])
|
||||||
frac_lines.shift(
|
frac_lines.shift(
|
||||||
(integral.get_height()/2 + SMALL_BUFF)*DOWN
|
(integral.get_height()/2 + SMALL_BUFF)*DOWN
|
||||||
|
@ -1301,7 +1301,7 @@ class Antiderivative(AverageOfSineStart):
|
||||||
integral.get_part_by_tex(tex).copy(),
|
integral.get_part_by_tex(tex).copy(),
|
||||||
pi_minus_zeros[0].get_part_by_tex(tex)
|
pi_minus_zeros[0].get_part_by_tex(tex)
|
||||||
)
|
)
|
||||||
for tex in "\\pi","0"
|
for tex in ("\\pi","0")
|
||||||
] + [
|
] + [
|
||||||
Write(pi_minus_zeros[0].get_part_by_tex("-"))
|
Write(pi_minus_zeros[0].get_part_by_tex("-"))
|
||||||
])
|
])
|
||||||
|
@ -1312,7 +1312,7 @@ class Antiderivative(AverageOfSineStart):
|
||||||
).copy(),
|
).copy(),
|
||||||
pi_minus_zeros[1].get_part_by_tex(tex)
|
pi_minus_zeros[1].get_part_by_tex(tex)
|
||||||
)
|
)
|
||||||
for tex in "\\pi", "-", "0"
|
for tex in ("\\pi", "-", "0")
|
||||||
])
|
])
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
|
|
||||||
|
@ -1514,7 +1514,7 @@ class GeneralAverage(AverageOfContinuousVariable):
|
||||||
Write(
|
Write(
|
||||||
VGroup(*[
|
VGroup(*[
|
||||||
fraction.get_part_by_tex(tex)
|
fraction.get_part_by_tex(tex)
|
||||||
for tex in "int", "f(x)", "dx", "over"
|
for tex in ("int", "f(x)", "dx", "over")
|
||||||
]),
|
]),
|
||||||
rate_func = squish_rate_func(smooth, 0.25, 0.75),
|
rate_func = squish_rate_func(smooth, 0.25, 0.75),
|
||||||
run_time = 4
|
run_time = 4
|
||||||
|
|
|
@ -135,7 +135,7 @@ class SecondDerivativeGraphically(GraphScene):
|
||||||
second_deriv.set_color(self.second_deriv_color)
|
second_deriv.set_color(self.second_deriv_color)
|
||||||
points = [
|
points = [
|
||||||
self.input_to_graph_point(x, self.graph)
|
self.input_to_graph_point(x, self.graph)
|
||||||
for x in self.x2, self.x3
|
for x in (self.x2, self.x3)
|
||||||
]
|
]
|
||||||
words = TextMobject("Change to \\\\ slope")
|
words = TextMobject("Change to \\\\ slope")
|
||||||
words.next_to(
|
words.next_to(
|
||||||
|
@ -243,7 +243,7 @@ class SecondDerivativeGraphically(GraphScene):
|
||||||
]
|
]
|
||||||
arg_rhs_list = [
|
arg_rhs_list = [
|
||||||
TexMobject("(", str(x0), ")", "=", str(rhs))
|
TexMobject("(", str(x0), ")", "=", str(rhs))
|
||||||
for rhs in 10, 0.4, 0
|
for rhs in (10, 0.4, 0)
|
||||||
]
|
]
|
||||||
for graph, arg_rhs in zip(graphs, arg_rhs_list):
|
for graph, arg_rhs in zip(graphs, arg_rhs_list):
|
||||||
graph.ss_group = self.get_secant_slope_group(
|
graph.ss_group = self.get_secant_slope_group(
|
||||||
|
@ -736,7 +736,7 @@ class SecondDerivativeAsAcceleration(Scene):
|
||||||
)
|
)
|
||||||
s_graph, v_graph, a_graph, j_graph = graphs = [
|
s_graph, v_graph, a_graph, j_graph = graphs = [
|
||||||
VGroup(*scene.get_top_level_mobjects())
|
VGroup(*scene.get_top_level_mobjects())
|
||||||
for scene in s_scene, v_scene, a_scene, j_scene
|
for scene in (s_scene, v_scene, a_scene, j_scene)
|
||||||
]
|
]
|
||||||
for i, graph in enumerate(graphs):
|
for i, graph in enumerate(graphs):
|
||||||
graph.scale_to_fit_height(FRAME_Y_RADIUS)
|
graph.scale_to_fit_height(FRAME_Y_RADIUS)
|
||||||
|
|
|
@ -723,12 +723,12 @@ class IntroduceTinyChangeInArea(CircleScene):
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(mob.set_color, RED)
|
ApplyMethod(mob.set_color, RED)
|
||||||
for mob in pi_R_squared, pi_R_squared2
|
for mob in (pi_R_squared, pi_R_squared2)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(mob.fade, 0.7)
|
ApplyMethod(mob.fade, 0.7)
|
||||||
for mob in plus, pi_R_squared, pi_R_squared2, minus2
|
for mob in (plus, pi_R_squared, pi_R_squared2, minus2)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
|
@ -2056,7 +2056,7 @@ class GraphIntegral(GraphScene):
|
||||||
def show_horizontal_axis(self):
|
def show_horizontal_axis(self):
|
||||||
arrows = [
|
arrows = [
|
||||||
Arrow(self.little_r, self.coords_to_point(*coords))
|
Arrow(self.little_r, self.coords_to_point(*coords))
|
||||||
for coords in (0, 0), (self.x_max, 0)
|
for coords in ((0, 0), (self.x_max, 0))
|
||||||
]
|
]
|
||||||
moving_arrow = arrows[0].copy()
|
moving_arrow = arrows[0].copy()
|
||||||
self.play(
|
self.play(
|
||||||
|
|
|
@ -381,7 +381,7 @@ class LinAlgPyramid(Scene):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(m.set_color, DARK_GREY)
|
ApplyMethod(m.set_color, DARK_GREY)
|
||||||
for m in words[0], rects[0]
|
for m in (words[0], rects[0])
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
self.list_applications(rects[-1])
|
self.list_applications(rects[-1])
|
||||||
|
@ -390,7 +390,7 @@ class LinAlgPyramid(Scene):
|
||||||
height = 1
|
height = 1
|
||||||
rects = [
|
rects = [
|
||||||
Rectangle(height = height, width = width)
|
Rectangle(height = height, width = width)
|
||||||
for width in 8, 5, 2
|
for width in (8, 5, 2)
|
||||||
]
|
]
|
||||||
rects[0].shift(2*DOWN)
|
rects[0].shift(2*DOWN)
|
||||||
for i in 1, 2:
|
for i in 1, 2:
|
||||||
|
@ -907,7 +907,7 @@ class ResourceForTeachers(Scene):
|
||||||
bubble.clear()
|
bubble.clear()
|
||||||
randys = VMobject(*[
|
randys = VMobject(*[
|
||||||
Randolph(color = c)
|
Randolph(color = c)
|
||||||
for c in BLUE_D, BLUE_C, BLUE_E
|
for c in (BLUE_D, BLUE_C, BLUE_E)
|
||||||
])
|
])
|
||||||
randys.arrange_submobjects(RIGHT)
|
randys.arrange_submobjects(RIGHT)
|
||||||
randys.scale(0.8)
|
randys.scale(0.8)
|
||||||
|
@ -937,7 +937,7 @@ class DifferingBackgrounds(Scene):
|
||||||
])
|
])
|
||||||
students = VMobject(*[
|
students = VMobject(*[
|
||||||
Randolph(color = c)
|
Randolph(color = c)
|
||||||
for c in BLUE_D, BLUE_C, BLUE_E
|
for c in (BLUE_D, BLUE_C, BLUE_E)
|
||||||
])
|
])
|
||||||
modes = ["pondering", "speaking_looking_left", "sassy"]
|
modes = ["pondering", "speaking_looking_left", "sassy"]
|
||||||
students.arrange_submobjects(RIGHT)
|
students.arrange_submobjects(RIGHT)
|
||||||
|
|
|
@ -403,7 +403,7 @@ class HelpsToHaveOneThought(Scene):
|
||||||
|
|
||||||
randys = VMobject(*[
|
randys = VMobject(*[
|
||||||
Randolph(color = color).scale(0.8)
|
Randolph(color = color).scale(0.8)
|
||||||
for color in BLUE_D, BLUE_C, BLUE_E
|
for color in (BLUE_D, BLUE_C, BLUE_E)
|
||||||
])
|
])
|
||||||
randys.arrange_submobjects(RIGHT)
|
randys.arrange_submobjects(RIGHT)
|
||||||
randys.to_corner(DOWN+LEFT)
|
randys.to_corner(DOWN+LEFT)
|
||||||
|
@ -795,7 +795,7 @@ class VectorAdditionNumerically(VectorScene):
|
||||||
Write(plus, run_time = 1),
|
Write(plus, run_time = 1),
|
||||||
*[
|
*[
|
||||||
ApplyMethod(mob.shift, v1.get_end())
|
ApplyMethod(mob.shift, v1.get_end())
|
||||||
for mob in v2, x_line2, y_line2
|
for mob in (v2, x_line2, y_line2)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
equals.next_to(coords2, RIGHT)
|
equals.next_to(coords2, RIGHT)
|
||||||
|
|
|
@ -241,7 +241,7 @@ class VectorRemainsOnSpan(ExampleTranformationScene):
|
||||||
self.wait()
|
self.wait()
|
||||||
target_vectors = [
|
target_vectors = [
|
||||||
vector.copy().scale(scalar)
|
vector.copy().scale(scalar)
|
||||||
for scalar in 2, -2, 1
|
for scalar in (2, -2, 1)
|
||||||
]
|
]
|
||||||
for target, time in zip(target_vectors, [1, 2, 2]):
|
for target, time in zip(target_vectors, [1, 2, 2]):
|
||||||
self.play(Transform(vector, target, run_time = time))
|
self.play(Transform(vector, target, run_time = time))
|
||||||
|
@ -269,7 +269,7 @@ class IHatAsEigenVector(ExampleTranformationScene):
|
||||||
x_axis = self.plane.axes[0]
|
x_axis = self.plane.axes[0]
|
||||||
targets = [
|
targets = [
|
||||||
self.i_hat.copy().scale(val)
|
self.i_hat.copy().scale(val)
|
||||||
for val in -FRAME_X_RADIUS, FRAME_X_RADIUS, 1
|
for val in (-FRAME_X_RADIUS, FRAME_X_RADIUS, 1)
|
||||||
]
|
]
|
||||||
lines = [
|
lines = [
|
||||||
Line(v1.get_end(), v2.get_end(), color = YELLOW)
|
Line(v1.get_end(), v2.get_end(), color = YELLOW)
|
||||||
|
@ -1422,7 +1422,7 @@ class RevisitExampleTransformation(ExampleTranformationScene):
|
||||||
two.move_to(lamb)
|
two.move_to(lamb)
|
||||||
self.play(Transform(lamb, two))
|
self.play(Transform(lamb, two))
|
||||||
self.play(*it.chain(
|
self.play(*it.chain(
|
||||||
[mob.restore for mob in self.plane, self.i_hat, self.j_hat],
|
[mob.restore for mob in (self.plane, self.i_hat, self.j_hat)],
|
||||||
map(Animation, self.foreground_mobjects),
|
map(Animation, self.foreground_mobjects),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -1460,7 +1460,7 @@ class RevisitExampleTransformation(ExampleTranformationScene):
|
||||||
)
|
)
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*it.chain(
|
self.play(*it.chain(
|
||||||
[mob.restore for mob in self.plane, self.i_hat, self.j_hat, vectors],
|
[mob.restore for mob in (self.plane, self.i_hat, self.j_hat, vectors)],
|
||||||
map(FadeOut, [xy_array, equals, zero_array]),
|
map(FadeOut, [xy_array, equals, zero_array]),
|
||||||
map(Animation, self.foreground_mobjects)
|
map(Animation, self.foreground_mobjects)
|
||||||
))
|
))
|
||||||
|
@ -2167,7 +2167,7 @@ class ChangeToEigenBasis(ExampleTranformationScene):
|
||||||
|
|
||||||
cob_matrix = Matrix(np.array([
|
cob_matrix = Matrix(np.array([
|
||||||
list(vect.entries.target)
|
list(vect.entries.target)
|
||||||
for vect in b1, b2
|
for vect in (b1, b2)
|
||||||
]).T)
|
]).T)
|
||||||
cob_matrix.rect = BackgroundRectangle(cob_matrix)
|
cob_matrix.rect = BackgroundRectangle(cob_matrix)
|
||||||
cob_matrix.add_to_back(cob_matrix.rect)
|
cob_matrix.add_to_back(cob_matrix.rect)
|
||||||
|
@ -2178,7 +2178,7 @@ class ChangeToEigenBasis(ExampleTranformationScene):
|
||||||
brace_text.next_to(brace, DOWN, aligned_edge = LEFT)
|
brace_text.next_to(brace, DOWN, aligned_edge = LEFT)
|
||||||
brace_text.add_background_rectangle()
|
brace_text.add_background_rectangle()
|
||||||
|
|
||||||
copies = [vect.coords.copy() for vect in b1, b2]
|
copies = [vect.coords.copy() for vect in (b1, b2)]
|
||||||
self.to_fade += copies
|
self.to_fade += copies
|
||||||
self.add(*copies)
|
self.add(*copies)
|
||||||
self.play(
|
self.play(
|
||||||
|
|
|
@ -181,7 +181,7 @@ class WhatIsA2DVector(LinearTransformationScene):
|
||||||
]),
|
]),
|
||||||
[ApplyMethod(s.change_mode, "plain") for s in students],
|
[ApplyMethod(s.change_mode, "plain") for s in students],
|
||||||
map(Animation, [cs_student.bubble, cs_student.arrow]),
|
map(Animation, [cs_student.bubble, cs_student.arrow]),
|
||||||
[mob.restore for mob in cs_student.v, cs_student.coords],
|
[mob.restore for mob in (cs_student.v, cs_student.coords)],
|
||||||
))
|
))
|
||||||
bubble = cs_student.get_bubble(SpeechBubble, width = 4, height = 3)
|
bubble = cs_student.get_bubble(SpeechBubble, width = 4, height = 3)
|
||||||
bubble.set_fill(BLACK, opacity = 1)
|
bubble.set_fill(BLACK, opacity = 1)
|
||||||
|
@ -756,7 +756,7 @@ class AddTwoFunctions(FunctionGraphScene):
|
||||||
}
|
}
|
||||||
self.play(*[
|
self.play(*[
|
||||||
MoveToTarget(mob, **kwargs)
|
MoveToTarget(mob, **kwargs)
|
||||||
for mob in g_lines, dots
|
for mob in (g_lines, dots)
|
||||||
])
|
])
|
||||||
# self.play(
|
# self.play(
|
||||||
# *[mob.fade for mob in g_lines, f_lines]+[
|
# *[mob.fade for mob in g_lines, f_lines]+[
|
||||||
|
@ -933,7 +933,7 @@ class FromVectorsToFunctions(VectorScene):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(mob.shift, FRAME_WIDTH*RIGHT)
|
ApplyMethod(mob.shift, FRAME_WIDTH*RIGHT)
|
||||||
for mob in axes, everything
|
for mob in (axes, everything)
|
||||||
] + [Animation(words)]
|
] + [Animation(words)]
|
||||||
)
|
)
|
||||||
self.play(ShowCreation(graph), Animation(words))
|
self.play(ShowCreation(graph), Animation(words))
|
||||||
|
@ -2036,7 +2036,7 @@ class ShowVectorSpaces(Scene):
|
||||||
Line(
|
Line(
|
||||||
h_line.get_center(), FRAME_Y_RADIUS*DOWN
|
h_line.get_center(), FRAME_Y_RADIUS*DOWN
|
||||||
).shift(vect*FRAME_X_RADIUS/3.)
|
).shift(vect*FRAME_X_RADIUS/3.)
|
||||||
for vect in LEFT, RIGHT
|
for vect in (LEFT, RIGHT)
|
||||||
]
|
]
|
||||||
vectors = self.get_vectors()
|
vectors = self.get_vectors()
|
||||||
vectors.shift(LEFT*FRAME_X_RADIUS*(2./3))
|
vectors.shift(LEFT*FRAME_X_RADIUS*(2./3))
|
||||||
|
@ -2121,7 +2121,7 @@ class MathematicianSpeakingToAll(Scene):
|
||||||
mathy = Mathematician().to_corner(DOWN+LEFT)
|
mathy = Mathematician().to_corner(DOWN+LEFT)
|
||||||
others = VGroup(*[
|
others = VGroup(*[
|
||||||
Randolph().flip().set_color(color)
|
Randolph().flip().set_color(color)
|
||||||
for color in BLUE_D, GREEN_E, GOLD_E, BLUE_C
|
for color in (BLUE_D, GREEN_E, GOLD_E, BLUE_C)
|
||||||
])
|
])
|
||||||
others.arrange_submobjects()
|
others.arrange_submobjects()
|
||||||
others.scale(0.8)
|
others.scale(0.8)
|
||||||
|
@ -2246,7 +2246,7 @@ class AxiomsAreInterface(Scene):
|
||||||
mathy.change_mode("pondering")
|
mathy.change_mode("pondering")
|
||||||
others = [
|
others = [
|
||||||
Randolph().flip().set_color(color)
|
Randolph().flip().set_color(color)
|
||||||
for color in BLUE_D, GREEN_E, GOLD_E, BLUE_C
|
for color in (BLUE_D, GREEN_E, GOLD_E, BLUE_C)
|
||||||
]
|
]
|
||||||
others = VGroup(
|
others = VGroup(
|
||||||
VGroup(*others[:2]),
|
VGroup(*others[:2]),
|
||||||
|
@ -2336,7 +2336,7 @@ class VectorSpaceOfPiCreatures(Scene):
|
||||||
|
|
||||||
def show_sum(self, creatures):
|
def show_sum(self, creatures):
|
||||||
def is_valid(pi1, pi2, pi3):
|
def is_valid(pi1, pi2, pi3):
|
||||||
if len(set([pi.get_color() for pi in pi1, pi2, pi3])) < 3:
|
if len(set([pi.get_color() for pi in (pi1, pi2, pi3)])) < 3:
|
||||||
return False
|
return False
|
||||||
if pi1.is_flipped()^pi2.is_flipped():
|
if pi1.is_flipped()^pi2.is_flipped():
|
||||||
return False
|
return False
|
||||||
|
@ -2475,7 +2475,7 @@ class WhatIsThree(Scene):
|
||||||
triplets = [
|
triplets = [
|
||||||
VGroup(*[
|
VGroup(*[
|
||||||
PiCreature(color = color).scale(0.4)
|
PiCreature(color = color).scale(0.4)
|
||||||
for color in BLUE_E, BLUE_C, BLUE_D
|
for color in (BLUE_E, BLUE_C, BLUE_D)
|
||||||
]),
|
]),
|
||||||
VGroup(*[HyperCube().scale(0.3) for x in range(3)]),
|
VGroup(*[HyperCube().scale(0.3) for x in range(3)]),
|
||||||
VGroup(*[Vector(RIGHT) for x in range(3)]),
|
VGroup(*[Vector(RIGHT) for x in range(3)]),
|
||||||
|
|
|
@ -291,7 +291,7 @@ class ShowVaryingLinearCombinations(VectorScene):
|
||||||
]
|
]
|
||||||
anims += [
|
anims += [
|
||||||
ApplyMethod(v.copy().fade, 0.7)
|
ApplyMethod(v.copy().fade, 0.7)
|
||||||
for v in v1, v2
|
for v in (v1, v2)
|
||||||
]
|
]
|
||||||
anims += label_anims + scalar_anims
|
anims += label_anims + scalar_anims
|
||||||
self.play(*anims, **{"run_time" : 2})
|
self.play(*anims, **{"run_time" : 2})
|
||||||
|
@ -457,7 +457,7 @@ class NameLinearCombinations(Scene):
|
||||||
scalars_word.next_to(equation, DOWN, buff = 2)
|
scalars_word.next_to(equation, DOWN, buff = 2)
|
||||||
arrows = [
|
arrows = [
|
||||||
Arrow(scalars_word, letter)
|
Arrow(scalars_word, letter)
|
||||||
for letter in a, b
|
for letter in (a, b)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.add(equation)
|
self.add(equation)
|
||||||
|
@ -605,7 +605,7 @@ class DefineSpan(Scene):
|
||||||
vary_words.next_to(equation, DOWN, buff = 2)
|
vary_words.next_to(equation, DOWN, buff = 2)
|
||||||
arrows = [
|
arrows = [
|
||||||
Arrow(vary_words, letter)
|
Arrow(vary_words, letter)
|
||||||
for letter in a, b
|
for letter in (a, b)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.play(Write(definition))
|
self.play(Write(definition))
|
||||||
|
@ -836,7 +836,7 @@ class LinearCombinationOfThreeVectorsText(Scene):
|
||||||
VMobject(*span_comment.split()[3:7]).set_color(YELLOW)
|
VMobject(*span_comment.split()[3:7]).set_color(YELLOW)
|
||||||
arrows = VMobject(*[
|
arrows = VMobject(*[
|
||||||
Arrow(span_comment, var)
|
Arrow(span_comment, var)
|
||||||
for var in a, b, c
|
for var in (a, b, c)
|
||||||
])
|
])
|
||||||
|
|
||||||
self.play(Write(text))
|
self.play(Write(text))
|
||||||
|
@ -967,7 +967,7 @@ class LinearDependentEquations(Scene):
|
||||||
low_words2.to_edge(DOWN)
|
low_words2.to_edge(DOWN)
|
||||||
arrows = VMobject(*[
|
arrows = VMobject(*[
|
||||||
Arrow(low_words2, var)
|
Arrow(low_words2, var)
|
||||||
for var in a, b
|
for var in (a, b)
|
||||||
])
|
])
|
||||||
|
|
||||||
self.play(Write(equation1))
|
self.play(Write(equation1))
|
||||||
|
@ -1064,7 +1064,7 @@ class AlternateDefOfLinearlyDependent(Scene):
|
||||||
scalar_specification.shift(1.5*DOWN)
|
scalar_specification.shift(1.5*DOWN)
|
||||||
scalar_specification.add(*[
|
scalar_specification.add(*[
|
||||||
Arrow(scalar_specification, equations[0].split()[i])
|
Arrow(scalar_specification, equations[0].split()[i])
|
||||||
for i in 2, 5
|
for i in (2, 5)
|
||||||
])
|
])
|
||||||
|
|
||||||
brace = Brace(VMobject(*equations[2].split()[2:]))
|
brace = Brace(VMobject(*equations[2].split()[2:]))
|
||||||
|
|
|
@ -152,7 +152,7 @@ class WhyConfuseWithTerminology(TeacherStudentsScene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
self.setup()
|
self.setup()
|
||||||
self.student_says("Why confuse us with \\\\ redundant terminology?")
|
self.student_says("Why confuse us with \\\\ redundant terminology?")
|
||||||
other_students = [self.get_students()[i] for i in 0, 2]
|
other_students = [self.get_students()[i] for i in (0, 2)]
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(student.change_mode, "confused")
|
ApplyMethod(student.change_mode, "confused")
|
||||||
for student in other_students
|
for student in other_students
|
||||||
|
@ -668,7 +668,7 @@ class TrackBasisVectorsExample(LinearTransformationScene):
|
||||||
self.remove(coords)
|
self.remove(coords)
|
||||||
|
|
||||||
def show_linear_combination(self, clean_up = True):
|
def show_linear_combination(self, clean_up = True):
|
||||||
i_hat_copy, j_hat_copy = [m.copy() for m in self.i_hat, self.j_hat]
|
i_hat_copy, j_hat_copy = [m.copy() for m in (self.i_hat, self.j_hat)]
|
||||||
self.play(ApplyFunction(
|
self.play(ApplyFunction(
|
||||||
lambda m : m.scale(self.v_coords[0]).fade(0.3),
|
lambda m : m.scale(self.v_coords[0]).fade(0.3),
|
||||||
i_hat_copy
|
i_hat_copy
|
||||||
|
|
|
@ -164,7 +164,7 @@ class FollowLinearCombination(LinearTransformationScene):
|
||||||
scaled_j = self.get_mobjects_from_last_animation()[0]
|
scaled_j = self.get_mobjects_from_last_animation()[0]
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(mob.shift, scaled_i.get_end())
|
ApplyMethod(mob.shift, scaled_i.get_end())
|
||||||
for mob in scaled_j, scaled_j_label
|
for mob in (scaled_j, scaled_j_label)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*map(FadeOut, [
|
self.play(*map(FadeOut, [
|
||||||
|
@ -313,7 +313,7 @@ class IntroduceIdeaOfComposition(RotationThenShear):
|
||||||
matrix.next_to(words, RIGHT, aligned_edge = UP)
|
matrix.next_to(words, RIGHT, aligned_edge = UP)
|
||||||
col1, col2 = [
|
col1, col2 = [
|
||||||
VMobject(*matrix.get_mob_matrix()[:,i])
|
VMobject(*matrix.get_mob_matrix()[:,i])
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
]
|
]
|
||||||
matrix_background = BackgroundRectangle(matrix)
|
matrix_background = BackgroundRectangle(matrix)
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ class MoreComplicatedExampleNumerically(MoreComplicatedExampleVisually):
|
||||||
|
|
||||||
col1, col2 = [
|
col1, col2 = [
|
||||||
VMobject(*m1_mob.split()[1].get_mob_matrix()[:,i])
|
VMobject(*m1_mob.split()[1].get_mob_matrix()[:,i])
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
]
|
]
|
||||||
col1.target_color = X_COLOR
|
col1.target_color = X_COLOR
|
||||||
col2.target_color = Y_COLOR
|
col2.target_color = Y_COLOR
|
||||||
|
@ -862,9 +862,9 @@ class AskAssociativityQuestion(Scene):
|
||||||
|
|
||||||
lhs = TexMobject(list("(AB)C"))
|
lhs = TexMobject(list("(AB)C"))
|
||||||
lp, a, b, rp, c = lhs.split()
|
lp, a, b, rp, c = lhs.split()
|
||||||
rhs = VMobject(*[m.copy() for m in a, lp, b, c, rp])
|
rhs = VMobject(*[m.copy() for m in (a, lp, b, c, rp)])
|
||||||
point = VectorizedPoint()
|
point = VectorizedPoint()
|
||||||
start = VMobject(*[m.copy() for m in point, a, b, point, c])
|
start = VMobject(*[m.copy() for m in (point, a, b, point, c)])
|
||||||
for mob in lhs, rhs, start:
|
for mob in lhs, rhs, start:
|
||||||
mob.arrange_submobjects(buff = 0.1)
|
mob.arrange_submobjects(buff = 0.1)
|
||||||
a, lp, b, c, rp = rhs.split()
|
a, lp, b, c, rp = rhs.split()
|
||||||
|
@ -904,7 +904,7 @@ class AskAssociativityQuestion(Scene):
|
||||||
|
|
||||||
matrices = map(matrix_to_mobject, [
|
matrices = map(matrix_to_mobject, [
|
||||||
np.array(list(m)).reshape((2, 2))
|
np.array(list(m)).reshape((2, 2))
|
||||||
for m in "abcd", "efgh", "ijkl"
|
for m in ("abcd", "efgh", "ijkl")
|
||||||
])
|
])
|
||||||
VMobject(*matrices).arrange_submobjects()
|
VMobject(*matrices).arrange_submobjects()
|
||||||
|
|
||||||
|
@ -931,10 +931,10 @@ class AskAssociativityQuestion(Scene):
|
||||||
m3
|
m3
|
||||||
)
|
)
|
||||||
state2 = VMobject(*[
|
state2 = VMobject(*[
|
||||||
m.copy() for m in lp, m1, m2, rp, m3
|
m.copy() for m in (lp, m1, m2, rp, m3)
|
||||||
])
|
])
|
||||||
state3 = VMobject(*[
|
state3 = VMobject(*[
|
||||||
m.copy() for m in m1, lp, m2, m3, rp
|
m.copy() for m in (m1, lp, m2, m3, rp)
|
||||||
])
|
])
|
||||||
for state in state2, state3:
|
for state in state2, state3:
|
||||||
state.arrange_submobjects(RIGHT, buff = 0.1)
|
state.arrange_submobjects(RIGHT, buff = 0.1)
|
||||||
|
|
|
@ -875,7 +875,7 @@ class TwoDDeterminantFormula(Scene):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
Transform(m, m.zero)
|
Transform(m, m.zero)
|
||||||
for m in mb, mc, b, c
|
for m in (mb, mc, b, c)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
for pair in (mb, b), (mc, c):
|
for pair in (mb, b), (mc, c):
|
||||||
|
@ -914,7 +914,7 @@ class TwoDDeterminantFormulaIntuition(LinearTransformationScene):
|
||||||
[[1, 0], [float(b)/d, 1]],
|
[[1, 0], [float(b)/d, 1]],
|
||||||
added_anims = [
|
added_anims = [
|
||||||
ApplyMethod(m.shift, b*RIGHT)
|
ApplyMethod(m.shift, b*RIGHT)
|
||||||
for m in side_brace, height
|
for m in (side_brace, height)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
|
@ -362,7 +362,7 @@ class SystemOfEquations(Scene):
|
||||||
eq.split()[i]
|
eq.split()[i]
|
||||||
for eq in equations.split()
|
for eq in equations.split()
|
||||||
])
|
])
|
||||||
for i in 1, 4, 7
|
for i in (1, 4, 7)
|
||||||
]
|
]
|
||||||
ys.words = "Vertically align variables"
|
ys.words = "Vertically align variables"
|
||||||
colors = [PINK, YELLOW, BLUE_B, BLUE_C, BLUE_D]
|
colors = [PINK, YELLOW, BLUE_B, BLUE_C, BLUE_D]
|
||||||
|
@ -432,7 +432,7 @@ class SystemOfEquations(Scene):
|
||||||
ax_equals_v.to_edge(RIGHT)
|
ax_equals_v.to_edge(RIGHT)
|
||||||
all_brackets = [
|
all_brackets = [
|
||||||
mob.get_brackets()
|
mob.get_brackets()
|
||||||
for mob in matrix, x_array, v_array
|
for mob in (matrix, x_array, v_array)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.play(equations.to_edge, LEFT)
|
self.play(equations.to_edge, LEFT)
|
||||||
|
@ -651,7 +651,7 @@ class ShowBijectivity(LinearTransformationScene):
|
||||||
Vector([x, y])
|
Vector([x, y])
|
||||||
for x, y in it.product(*[
|
for x, y in it.product(*[
|
||||||
np.arange(-int(val)+0.5, int(val)+0.5)
|
np.arange(-int(val)+0.5, int(val)+0.5)
|
||||||
for val in FRAME_X_RADIUS, FRAME_Y_RADIUS
|
for val in (FRAME_X_RADIUS, FRAME_Y_RADIUS)
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
vectors.set_submobject_colors_by_gradient(BLUE_E, PINK)
|
vectors.set_submobject_colors_by_gradient(BLUE_E, PINK)
|
||||||
|
@ -970,7 +970,7 @@ class SymbolicInversion(Scene):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(m.set_color, BLACK)
|
ApplyMethod(m.set_color, BLACK)
|
||||||
for m in product, product.brace, product.words
|
for m in (product, product.brace, product.words)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(ApplyFunction(
|
self.play(ApplyFunction(
|
||||||
|
@ -1239,7 +1239,7 @@ class ColumnsRepresentBasisVectors(Scene):
|
||||||
matrix.shift(UP)
|
matrix.shift(UP)
|
||||||
i_hat_words, j_hat_words = [
|
i_hat_words, j_hat_words = [
|
||||||
TextMobject("Where $\\hat{\\%smath}$ lands"%char)
|
TextMobject("Where $\\hat{\\%smath}$ lands"%char)
|
||||||
for char in "i", "j"
|
for char in ("i", "j")
|
||||||
]
|
]
|
||||||
i_hat_words.set_color(X_COLOR)
|
i_hat_words.set_color(X_COLOR)
|
||||||
i_hat_words.next_to(ORIGIN, LEFT).to_edge(UP)
|
i_hat_words.next_to(ORIGIN, LEFT).to_edge(UP)
|
||||||
|
@ -1462,7 +1462,7 @@ class NameColumnSpace(Scene):
|
||||||
two_d_span.move_to(span_text, aligned_edge = RIGHT)
|
two_d_span.move_to(span_text, aligned_edge = RIGHT)
|
||||||
mob_matrix = np.array([
|
mob_matrix = np.array([
|
||||||
two_d_span[i].get_entries().split()
|
two_d_span[i].get_entries().split()
|
||||||
for i in 2, 4
|
for i in (2, 4)
|
||||||
])
|
])
|
||||||
|
|
||||||
self.play(Transform(span_text, two_d_span))
|
self.play(Transform(span_text, two_d_span))
|
||||||
|
@ -1482,7 +1482,7 @@ class NameColumnSpace(Scene):
|
||||||
self.add(span_text)
|
self.add(span_text)
|
||||||
mob_matrix = np.array([
|
mob_matrix = np.array([
|
||||||
span_text[i].get_entries().split()
|
span_text[i].get_entries().split()
|
||||||
for i in 2, 4, 6
|
for i in (2, 4, 6)
|
||||||
])
|
])
|
||||||
self.replace_number_matrix(mob_matrix, [[1, 1, 0], [0, 1, 1], [1, 0, 1]])
|
self.replace_number_matrix(mob_matrix, [[1, 1, 0], [0, 1, 1], [1, 0, 1]])
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
|
@ -304,7 +304,7 @@ class GeometricInterpretation(VectorScene):
|
||||||
dot_product = np.dot(self.v.get_end(), self.w.get_end())
|
dot_product = np.dot(self.v.get_end(), self.w.get_end())
|
||||||
v_norm, w_norm = [
|
v_norm, w_norm = [
|
||||||
np.linalg.norm(vect.get_end())
|
np.linalg.norm(vect.get_end())
|
||||||
for vect in self.v, self.w
|
for vect in (self.v, self.w)
|
||||||
]
|
]
|
||||||
projected = Vector(
|
projected = Vector(
|
||||||
self.stable_vect.get_end()*dot_product/(
|
self.stable_vect.get_end()*dot_product/(
|
||||||
|
@ -348,7 +348,7 @@ class GeometricInterpretation(VectorScene):
|
||||||
|
|
||||||
proj_brace, stable_brace = braces = [
|
proj_brace, stable_brace = braces = [
|
||||||
Brace(Line(ORIGIN, vect.get_length()*RIGHT*sgn), UP)
|
Brace(Line(ORIGIN, vect.get_length()*RIGHT*sgn), UP)
|
||||||
for vect in self.proj_vect, self.stable_vect
|
for vect in (self.proj_vect, self.stable_vect)
|
||||||
for sgn in [np.sign(np.dot(vect.get_end(), self.stable_vect.get_end()))]
|
for sgn in [np.sign(np.dot(vect.get_end(), self.stable_vect.get_end()))]
|
||||||
]
|
]
|
||||||
proj_brace.put_at_tip(proj_words.start)
|
proj_brace.put_at_tip(proj_words.start)
|
||||||
|
@ -581,7 +581,7 @@ class SymmetricVAndW(VectorScene):
|
||||||
color = GREY
|
color = GREY
|
||||||
)
|
)
|
||||||
|
|
||||||
v_tex, w_tex = ["\\vec{\\textbf{%s}}"%c for c in "v", "w"]
|
v_tex, w_tex = ["\\vec{\\textbf{%s}}"%c for c in ("v", "w")]
|
||||||
equation = TexMobject(
|
equation = TexMobject(
|
||||||
"(", "2", v_tex, ")", "\\cdot", w_tex,
|
"(", "2", v_tex, ")", "\\cdot", w_tex,
|
||||||
"=",
|
"=",
|
||||||
|
@ -600,7 +600,7 @@ class SymmetricVAndW(VectorScene):
|
||||||
v.proj_line.save_state()
|
v.proj_line.save_state()
|
||||||
self.play(Transform(*[
|
self.play(Transform(*[
|
||||||
VGroup(mob, mob.label)
|
VGroup(mob, mob.label)
|
||||||
for mob in v, new_v
|
for mob in (v, new_v)
|
||||||
]), run_time = 2)
|
]), run_time = 2)
|
||||||
last_mob = self.get_mobjects_from_last_animation()[0]
|
last_mob = self.get_mobjects_from_last_animation()[0]
|
||||||
self.remove(last_mob)
|
self.remove(last_mob)
|
||||||
|
@ -700,7 +700,7 @@ class Introduce2Dto1DLinearTransformations(TwoDToOneDScene):
|
||||||
self.apply_transposed_matrix(self.t_matrix)
|
self.apply_transposed_matrix(self.t_matrix)
|
||||||
self.play(
|
self.play(
|
||||||
ShowCreation(number_line),
|
ShowCreation(number_line),
|
||||||
*[Animation(v) for v in self.i_hat, self.j_hat]
|
*[Animation(v) for v in (self.i_hat, self.j_hat)]
|
||||||
)
|
)
|
||||||
self.play(*map(Write, [numbers, number_line_words]))
|
self.play(*map(Write, [numbers, number_line_words]))
|
||||||
self.wait()
|
self.wait()
|
||||||
|
@ -778,7 +778,7 @@ class OkayToIgnoreFormalProperties(Scene):
|
||||||
title.to_edge(UP)
|
title.to_edge(UP)
|
||||||
h_line = Line(LEFT, RIGHT).scale(FRAME_X_RADIUS)
|
h_line = Line(LEFT, RIGHT).scale(FRAME_X_RADIUS)
|
||||||
h_line.next_to(title, DOWN)
|
h_line.next_to(title, DOWN)
|
||||||
v_tex, w_tex = ["\\vec{\\textbf{%s}}"%s for s in "v", "w"]
|
v_tex, w_tex = ["\\vec{\\textbf{%s}}"%s for s in ("v", "w")]
|
||||||
additivity = TexMobject(
|
additivity = TexMobject(
|
||||||
"L(", v_tex, "+", w_tex, ") = ",
|
"L(", v_tex, "+", w_tex, ") = ",
|
||||||
"L(", v_tex, ") + L(", w_tex, ")",
|
"L(", v_tex, ") + L(", w_tex, ")",
|
||||||
|
@ -829,7 +829,7 @@ class FormalVsVisual(Scene):
|
||||||
formal.next_to(line, DOWN).shift(FRAME_X_RADIUS*LEFT/2)
|
formal.next_to(line, DOWN).shift(FRAME_X_RADIUS*LEFT/2)
|
||||||
visual.next_to(line, DOWN).shift(FRAME_X_RADIUS*RIGHT/2)
|
visual.next_to(line, DOWN).shift(FRAME_X_RADIUS*RIGHT/2)
|
||||||
|
|
||||||
v_tex, w_tex = ["\\vec{\\textbf{%s}}"%c for c in "v", "w"]
|
v_tex, w_tex = ["\\vec{\\textbf{%s}}"%c for c in ("v", "w")]
|
||||||
additivity = TexMobject(
|
additivity = TexMobject(
|
||||||
"L(", v_tex, "+", w_tex, ") = ",
|
"L(", v_tex, "+", w_tex, ") = ",
|
||||||
"L(", v_tex, ")+", "L(", w_tex, ")"
|
"L(", v_tex, ")+", "L(", w_tex, ")"
|
||||||
|
@ -900,13 +900,13 @@ class AdditivityProperty(TwoDToOneDScene):
|
||||||
sum_vect.target = sum_vect
|
sum_vect.target = sum_vect
|
||||||
self.play(*[
|
self.play(*[
|
||||||
Transform(mob, mob.target)
|
Transform(mob, mob.target)
|
||||||
for mob in v, w, sum_vect
|
for mob in (v, w, sum_vect)
|
||||||
])
|
])
|
||||||
self.add_vector(sum_vect, animate = False)
|
self.add_vector(sum_vect, animate = False)
|
||||||
return sum_vect
|
return sum_vect
|
||||||
|
|
||||||
def get_symbols(self):
|
def get_symbols(self):
|
||||||
v_tex, w_tex = ["\\vec{\\textbf{%s}}"%c for c in "v", "w"]
|
v_tex, w_tex = ["\\vec{\\textbf{%s}}"%c for c in ("v", "w")]
|
||||||
if self.sum_before:
|
if self.sum_before:
|
||||||
tex_mob = TexMobject(
|
tex_mob = TexMobject(
|
||||||
"L(", v_tex, "+", w_tex, ")"
|
"L(", v_tex, "+", w_tex, ")"
|
||||||
|
@ -1029,7 +1029,7 @@ class NonLinearFailsDotTest(TwoDTo1DTransformWithDots):
|
||||||
|
|
||||||
class AlwaysfollowIHatJHat(TeacherStudentsScene):
|
class AlwaysfollowIHatJHat(TeacherStudentsScene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
i_tex, j_tex = ["$\\hat{\\%smath}$"%c for c in "i", "j"]
|
i_tex, j_tex = ["$\\hat{\\%smath}$"%c for c in ("i", "j")]
|
||||||
words = TextMobject(
|
words = TextMobject(
|
||||||
"Always follow", i_tex, "and", j_tex
|
"Always follow", i_tex, "and", j_tex
|
||||||
)
|
)
|
||||||
|
@ -1131,7 +1131,7 @@ class FollowVectorViaCoordinates(TwoDToOneDScene):
|
||||||
self.play(
|
self.play(
|
||||||
*map(FadeOut, to_fade) + [
|
*map(FadeOut, to_fade) + [
|
||||||
vect.restore
|
vect.restore
|
||||||
for vect in self.i_hat, self.j_hat
|
for vect in (self.i_hat, self.j_hat)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1149,7 +1149,7 @@ class FollowVectorViaCoordinates(TwoDToOneDScene):
|
||||||
else:
|
else:
|
||||||
new_labels = [
|
new_labels = [
|
||||||
TexMobject("L(\\hat{\\%smath})"%char)
|
TexMobject("L(\\hat{\\%smath})"%char)
|
||||||
for char in "i", "j"
|
for char in ("i", "j")
|
||||||
]
|
]
|
||||||
|
|
||||||
new_labels[0].set_color(X_COLOR)
|
new_labels[0].set_color(X_COLOR)
|
||||||
|
@ -1609,7 +1609,7 @@ class AskAboutProjectionMatrix(Scene):
|
||||||
VMobject(words, matrix).arrange_submobjects(buff = MED_SMALL_BUFF).shift(UP)
|
VMobject(words, matrix).arrange_submobjects(buff = MED_SMALL_BUFF).shift(UP)
|
||||||
basis_words = [
|
basis_words = [
|
||||||
TextMobject("Where", "$\\hat{\\%smath}$"%char, "lands")
|
TextMobject("Where", "$\\hat{\\%smath}$"%char, "lands")
|
||||||
for char in "i", "j"
|
for char in ("i", "j")
|
||||||
]
|
]
|
||||||
for b_words, q_mark, direction in zip(basis_words, matrix.get_entries(), [UP, DOWN]):
|
for b_words, q_mark, direction in zip(basis_words, matrix.get_entries(), [UP, DOWN]):
|
||||||
b_words.next_to(q_mark, direction, buff = 1.5)
|
b_words.next_to(q_mark, direction, buff = 1.5)
|
||||||
|
@ -1650,7 +1650,7 @@ class ProjectBasisVectors(ProjectOntoUnitVectorNumberline):
|
||||||
for vector in basis_vectors
|
for vector in basis_vectors
|
||||||
])
|
])
|
||||||
|
|
||||||
i_tex, j_tex = ["$\\hat{\\%smath}$"%char for char in "i", "j"]
|
i_tex, j_tex = ["$\\hat{\\%smath}$"%char for char in ("i", "j")]
|
||||||
question = TextMobject(
|
question = TextMobject(
|
||||||
"Where do", i_tex, "and", j_tex, "land?"
|
"Where do", i_tex, "and", j_tex, "land?"
|
||||||
)
|
)
|
||||||
|
@ -1698,7 +1698,7 @@ class ProjectBasisVectors(ProjectOntoUnitVectorNumberline):
|
||||||
# self.show_u_coords(u_label)
|
# self.show_u_coords(u_label)
|
||||||
u_x, u_y = [
|
u_x, u_y = [
|
||||||
TexMobject("u_%s"%c).set_color(self.u_hat.get_color())
|
TexMobject("u_%s"%c).set_color(self.u_hat.get_color())
|
||||||
for c in "x", "y"
|
for c in ("x", "y")
|
||||||
]
|
]
|
||||||
matrix_x, matrix_y = matrix.get_entries()
|
matrix_x, matrix_y = matrix.get_entries()
|
||||||
self.remove(j_hat, j_label)
|
self.remove(j_hat, j_label)
|
||||||
|
@ -2160,7 +2160,7 @@ class TranslateToTheWorldOfTransformations(TwoDOneDMatrixMultiplication):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
v1, v2 = [
|
v1, v2 = [
|
||||||
Matrix(["x_%d"%n, "y_%d"%n])
|
Matrix(["x_%d"%n, "y_%d"%n])
|
||||||
for n in 1, 2
|
for n in (1, 2)
|
||||||
]
|
]
|
||||||
v1.set_color_columns(V_COLOR)
|
v1.set_color_columns(V_COLOR)
|
||||||
v2.set_color_columns(W_COLOR)
|
v2.set_color_columns(W_COLOR)
|
||||||
|
|
|
@ -183,7 +183,7 @@ class SimpleDefine2dCrossProduct(LinearTransformationScene):
|
||||||
vect.label.target.restore,
|
vect.label.target.restore,
|
||||||
rate_func = lambda t : smooth(1-t)
|
rate_func = lambda t : smooth(1-t)
|
||||||
)
|
)
|
||||||
for vect in self.v, self.w
|
for vect in (self.v, self.w)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
self.wait()
|
self.wait()
|
||||||
|
@ -250,7 +250,7 @@ class SimpleDefine2dCrossProduct(LinearTransformationScene):
|
||||||
self.play(
|
self.play(
|
||||||
FadeOut(positive),
|
FadeOut(positive),
|
||||||
FadeOut(positive.arrow),
|
FadeOut(positive.arrow),
|
||||||
*[mob.restore for mob in square, self.v, self.w]
|
*[mob.restore for mob in (square, self.v, self.w)]
|
||||||
)
|
)
|
||||||
arc = self.get_arc(self.v, self.w, radius = 1.5)
|
arc = self.get_arc(self.v, self.w, radius = 1.5)
|
||||||
arc.set_color(RED)
|
arc.set_color(RED)
|
||||||
|
@ -770,7 +770,7 @@ class Define2dCrossProduct(LinearTransformationScene):
|
||||||
|
|
||||||
col1, col2 = [
|
col1, col2 = [
|
||||||
VGroup(*matrix.get_mob_matrix()[i,:])
|
VGroup(*matrix.get_mob_matrix()[i,:])
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
both_words = []
|
both_words = []
|
||||||
|
@ -836,7 +836,7 @@ class Define2dCrossProduct(LinearTransformationScene):
|
||||||
|
|
||||||
vect_stuffs = VGroup(*it.chain(*[
|
vect_stuffs = VGroup(*it.chain(*[
|
||||||
[m, m.label, m.coord_array]
|
[m, m.label, m.coord_array]
|
||||||
for m in self.v, self.w
|
for m in (self.v, self.w)
|
||||||
]))
|
]))
|
||||||
to_restore = [self.plane, self.i_hat, self.j_hat]
|
to_restore = [self.plane, self.i_hat, self.j_hat]
|
||||||
for mob in to_restore:
|
for mob in to_restore:
|
||||||
|
@ -917,10 +917,10 @@ class Define2dCrossProduct(LinearTransformationScene):
|
||||||
self.play(Transform(movers, movers.target))
|
self.play(Transform(movers, movers.target))
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
v_tex, w_tex = ["\\vec{\\textbf{%s}}"%s for s in "v", "w"]
|
v_tex, w_tex = ["\\vec{\\textbf{%s}}"%s for s in ("v", "w")]
|
||||||
positive_words, negative_words = words_list = [
|
positive_words, negative_words = words_list = [
|
||||||
TexMobject(v_tex, "\\times", w_tex, "\\text{ is }", word)
|
TexMobject(v_tex, "\\times", w_tex, "\\text{ is }", word)
|
||||||
for word in "\\text{positive}", "\\text{negative}"
|
for word in ("\\text{positive}", "\\text{negative}")
|
||||||
]
|
]
|
||||||
for words in words_list:
|
for words in words_list:
|
||||||
words.set_color_by_tex(v_tex, V_COLOR)
|
words.set_color_by_tex(v_tex, V_COLOR)
|
||||||
|
@ -1382,7 +1382,7 @@ class ShowCrossProductFormula(Scene):
|
||||||
|
|
||||||
arrays = [
|
arrays = [
|
||||||
["%s_%d"%(s, i) for i in range(1, 4)]
|
["%s_%d"%(s, i) for i in range(1, 4)]
|
||||||
for s in "v", "w"
|
for s in ("v", "w")
|
||||||
]
|
]
|
||||||
matrices = map(Matrix, arrays)
|
matrices = map(Matrix, arrays)
|
||||||
for matrix in matrices:
|
for matrix in matrices:
|
||||||
|
@ -1466,7 +1466,7 @@ class DeterminantTrick(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
v_terms, w_terms = [
|
v_terms, w_terms = [
|
||||||
["%s_%d"%(s, d) for d in range(1, 4)]
|
["%s_%d"%(s, d) for d in range(1, 4)]
|
||||||
for s in "v", "w"
|
for s in ("v", "w")
|
||||||
]
|
]
|
||||||
v = Matrix(v_terms)
|
v = Matrix(v_terms)
|
||||||
w = Matrix(w_terms)
|
w = Matrix(w_terms)
|
||||||
|
@ -1475,7 +1475,7 @@ class DeterminantTrick(Scene):
|
||||||
matrix = Matrix(np.array([
|
matrix = Matrix(np.array([
|
||||||
[
|
[
|
||||||
TexMobject("\\hat{%s}"%s)
|
TexMobject("\\hat{%s}"%s)
|
||||||
for s in "\\imath", "\\jmath", "k"
|
for s in ("\\imath", "\\jmath", "k")
|
||||||
],
|
],
|
||||||
list(v.get_entries().copy()),
|
list(v.get_entries().copy()),
|
||||||
list(w.get_entries().copy()),
|
list(w.get_entries().copy()),
|
||||||
|
|
|
@ -106,7 +106,7 @@ class BruteForceVerification(Scene):
|
||||||
"(", v_tex, "\\times", w_tex, ")",
|
"(", v_tex, "\\times", w_tex, ")",
|
||||||
"= 0"
|
"= 0"
|
||||||
)
|
)
|
||||||
for tex in v_tex, w_tex
|
for tex in (v_tex, w_tex)
|
||||||
]
|
]
|
||||||
theta_def = TexMobject(
|
theta_def = TexMobject(
|
||||||
"\\theta",
|
"\\theta",
|
||||||
|
@ -149,7 +149,7 @@ class Prerequisites(Scene):
|
||||||
rect.scale_to_fit_width(FRAME_X_RADIUS - 1)
|
rect.scale_to_fit_width(FRAME_X_RADIUS - 1)
|
||||||
left_rect, right_rect = [
|
left_rect, right_rect = [
|
||||||
rect.copy().shift(DOWN/2).to_edge(edge)
|
rect.copy().shift(DOWN/2).to_edge(edge)
|
||||||
for edge in LEFT, RIGHT
|
for edge in (LEFT, RIGHT)
|
||||||
]
|
]
|
||||||
chapter5 = TextMobject("""
|
chapter5 = TextMobject("""
|
||||||
\\centering
|
\\centering
|
||||||
|
@ -293,7 +293,7 @@ class ThreeStepPlan(Scene):
|
||||||
v_tex, w_tex = get_vect_tex(*"vw")
|
v_tex, w_tex = get_vect_tex(*"vw")
|
||||||
v_text, w_text, cross_text = [
|
v_text, w_text, cross_text = [
|
||||||
"$%s$"%s
|
"$%s$"%s
|
||||||
for s in v_tex, w_tex, v_tex + "\\times" + w_tex
|
for s in (v_tex, w_tex, v_tex + "\\times" + w_tex)
|
||||||
]
|
]
|
||||||
steps = [
|
steps = [
|
||||||
TextMobject(
|
TextMobject(
|
||||||
|
@ -413,7 +413,7 @@ class DefineDualTransform(Scene):
|
||||||
det_text = get_det_text(matrix, background_rect = False)
|
det_text = get_det_text(matrix, background_rect = False)
|
||||||
syms = times1, times2, equals = [
|
syms = times1, times2, equals = [
|
||||||
TexMobject(sym)
|
TexMobject(sym)
|
||||||
for sym in "\\times", "\\times", "=",
|
for sym in ("\\times", "\\times", "=",)
|
||||||
]
|
]
|
||||||
triple_cross = VGroup(
|
triple_cross = VGroup(
|
||||||
u_tex.target, times1, v_tex.target, times2, w_tex.target, equals
|
u_tex.target, times1, v_tex.target, times2, w_tex.target, equals
|
||||||
|
@ -509,7 +509,7 @@ class DefineDualTransform(Scene):
|
||||||
func_tex[0].scale_in_place(1.5)
|
func_tex[0].scale_in_place(1.5)
|
||||||
|
|
||||||
func_tex = VGroup(
|
func_tex = VGroup(
|
||||||
VGroup(*[func_tex[i] for i in 0, 1, 2, -2, -1]),
|
VGroup(*[func_tex[i] for i in (0, 1, 2, -2, -1)]),
|
||||||
func_input
|
func_input
|
||||||
)
|
)
|
||||||
func_tex.next_to(self.equals, LEFT)
|
func_tex.next_to(self.equals, LEFT)
|
||||||
|
@ -528,7 +528,7 @@ class DefineDualTransform(Scene):
|
||||||
])
|
])
|
||||||
self.play(*[
|
self.play(*[
|
||||||
Write(VGroup(vect_brace, vect_brace.tex))
|
Write(VGroup(vect_brace, vect_brace.tex))
|
||||||
for vect_brace in v_brace, w_brace
|
for vect_brace in (v_brace, w_brace)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(Write(func_tex))
|
self.play(Write(func_tex))
|
||||||
|
|
|
@ -559,9 +559,9 @@ class IntroduceJennifer(JenniferScene):
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
ApplyMethod(pi.change_mode, "plain")
|
ApplyMethod(pi.change_mode, "plain")
|
||||||
for pi in self.jenny, self.you
|
for pi in (self.jenny, self.you)
|
||||||
],
|
],
|
||||||
[mob.restore for mob in b1, b2, b1.label, b2.label]
|
[mob.restore for mob in (b1, b2, b1.label, b2.label)]
|
||||||
))
|
))
|
||||||
self.jenny.bubble.restore()
|
self.jenny.bubble.restore()
|
||||||
|
|
||||||
|
@ -1548,7 +1548,7 @@ class JennyWatchesRotation(JenniferScene):
|
||||||
self.play(*it.chain(
|
self.play(*it.chain(
|
||||||
[
|
[
|
||||||
Rotate(mob, np.pi/2, run_time = 3)
|
Rotate(mob, np.pi/2, run_time = 3)
|
||||||
for mob in self.jenny_plane, self.b1, self.b2
|
for mob in (self.jenny_plane, self.b1, self.b2)
|
||||||
],
|
],
|
||||||
map(Animation, [jenny, jenny.bubble, matrix])
|
map(Animation, [jenny, jenny.bubble, matrix])
|
||||||
))
|
))
|
||||||
|
@ -1757,7 +1757,7 @@ class JennyWatchesRotationWithMatrixAndVector(JenniferScene):
|
||||||
self.play(*it.chain(
|
self.play(*it.chain(
|
||||||
[
|
[
|
||||||
Rotate(mob, np.pi/2, run_time = 3)
|
Rotate(mob, np.pi/2, run_time = 3)
|
||||||
for mob in self.jenny_plane, self.b1, self.b2, vector
|
for mob in (self.jenny_plane, self.b1, self.b2, vector)
|
||||||
],
|
],
|
||||||
map(Animation, [self.jenny, matrix, vector_array]),
|
map(Animation, [self.jenny, matrix, vector_array]),
|
||||||
))
|
))
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
class OpeningQuote(Scene):
|
class OpeningQuote(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ColumnsRepresentBasisVectors(Scene):
|
||||||
matrix = Matrix([[3, 1], [4, 1], [5, 9]])
|
matrix = Matrix([[3, 1], [4, 1], [5, 9]])
|
||||||
i_hat_words, j_hat_words = [
|
i_hat_words, j_hat_words = [
|
||||||
TextMobject("Where $\\hat{\\%smath}$ lands"%char)
|
TextMobject("Where $\\hat{\\%smath}$ lands"%char)
|
||||||
for char in "i", "j"
|
for char in ("i", "j")
|
||||||
]
|
]
|
||||||
i_hat_words.set_color(X_COLOR)
|
i_hat_words.set_color(X_COLOR)
|
||||||
i_hat_words.next_to(ORIGIN, LEFT).to_edge(UP)
|
i_hat_words.next_to(ORIGIN, LEFT).to_edge(UP)
|
||||||
|
@ -166,7 +166,7 @@ class DescribeColumnsInSpecificTransformation(Scene):
|
||||||
])
|
])
|
||||||
matrix.set_color_columns(X_COLOR, Y_COLOR)
|
matrix.set_color_columns(X_COLOR, Y_COLOR)
|
||||||
mob_matrix = matrix.get_mob_matrix()
|
mob_matrix = matrix.get_mob_matrix()
|
||||||
i_col, j_col = [VMobject(*mob_matrix[:,i]) for i in 0, 1]
|
i_col, j_col = [VMobject(*mob_matrix[:,i]) for i in (0, 1)]
|
||||||
for col, char, vect in zip([i_col, j_col], ["i", "j"], [UP, DOWN]):
|
for col, char, vect in zip([i_col, j_col], ["i", "j"], [UP, DOWN]):
|
||||||
color = col[0].get_color()
|
color = col[0].get_color()
|
||||||
col.words = TextMobject("Where $\\hat\\%smath$ lands"%char)
|
col.words = TextMobject("Where $\\hat\\%smath$ lands"%char)
|
||||||
|
@ -572,7 +572,7 @@ class DotProductPreview(VectorScene):
|
||||||
dot_product = np.dot(self.v.get_end(), self.w.get_end())
|
dot_product = np.dot(self.v.get_end(), self.w.get_end())
|
||||||
v_norm, w_norm = [
|
v_norm, w_norm = [
|
||||||
np.linalg.norm(vect.get_end())
|
np.linalg.norm(vect.get_end())
|
||||||
for vect in self.v, self.w
|
for vect in (self.v, self.w)
|
||||||
]
|
]
|
||||||
projected_w = Vector(
|
projected_w = Vector(
|
||||||
self.v.get_end()*dot_product/(v_norm**2),
|
self.v.get_end()*dot_product/(v_norm**2),
|
||||||
|
@ -595,7 +595,7 @@ class DotProductPreview(VectorScene):
|
||||||
Line(ORIGIN, norm*RIGHT),
|
Line(ORIGIN, norm*RIGHT),
|
||||||
UP
|
UP
|
||||||
)
|
)
|
||||||
for norm in 1, self.v.get_length(), dot_product
|
for norm in (1, self.v.get_length(), dot_product)
|
||||||
]
|
]
|
||||||
length_texs = list(it.starmap(TexMobject, [
|
length_texs = list(it.starmap(TexMobject, [
|
||||||
("1",),
|
("1",),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools as it
|
import itertools as it
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
@ -13,7 +14,7 @@ from mobject.region import *
|
||||||
import displayer as disp
|
import displayer as disp
|
||||||
from scene.scene import Scene, GraphScene
|
from scene.scene import Scene, GraphScene
|
||||||
from scene.graphs import *
|
from scene.graphs import *
|
||||||
from moser_main import EulersFormula
|
from .moser_main import EulersFormula
|
||||||
from script_wrapper import command_line_create_scene
|
from script_wrapper import command_line_create_scene
|
||||||
|
|
||||||
MOVIE_PREFIX = "ecf_graph_scenes/"
|
MOVIE_PREFIX = "ecf_graph_scenes/"
|
||||||
|
@ -726,7 +727,7 @@ class ExamplesOfGraphs(GraphScene):
|
||||||
found = False
|
found = False
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
cycle1, cycle2 = region_pairs.next()
|
cycle1, cycle2 = next(region_pairs)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
shared = set(cycle1).intersection(cycle2)
|
shared = set(cycle1).intersection(cycle2)
|
||||||
|
|
|
@ -35,7 +35,7 @@ def get_fourier_graph(
|
||||||
graph.set_color(color)
|
graph.set_color(color)
|
||||||
f_min, f_max = [
|
f_min, f_max = [
|
||||||
axes.x_axis.point_to_number(graph.points[i])
|
axes.x_axis.point_to_number(graph.points[i])
|
||||||
for i in 0, -1
|
for i in (0, -1)
|
||||||
]
|
]
|
||||||
graph.underlying_function = lambda f : axes.y_axis.point_to_number(
|
graph.underlying_function = lambda f : axes.y_axis.point_to_number(
|
||||||
graph.point_from_proportion((f - f_min)/(f_max - f_min))
|
graph.point_from_proportion((f - f_min)/(f_max - f_min))
|
||||||
|
@ -291,7 +291,7 @@ class AddingPureFrequencies(PiCreatureScene):
|
||||||
self.pi_creature.change, "thinking",
|
self.pi_creature.change, "thinking",
|
||||||
*[
|
*[
|
||||||
ShowCreation(graph, run_time = 4, rate_func = None)
|
ShowCreation(graph, run_time = 4, rate_func = None)
|
||||||
for graph in self.A_graph, self.D_graph
|
for graph in (self.A_graph, self.D_graph)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
self.wait()
|
self.wait()
|
||||||
|
@ -322,7 +322,7 @@ class AddingPureFrequencies(PiCreatureScene):
|
||||||
map(MoveToTarget, movers),
|
map(MoveToTarget, movers),
|
||||||
[
|
[
|
||||||
ApplyMethod(mob.shift, FRAME_Y_RADIUS*DOWN, remover = True)
|
ApplyMethod(mob.shift, FRAME_Y_RADIUS*DOWN, remover = True)
|
||||||
for mob in randy, speaker
|
for mob in (randy, speaker)
|
||||||
]
|
]
|
||||||
))
|
))
|
||||||
self.wait()
|
self.wait()
|
||||||
|
@ -1114,7 +1114,7 @@ class WrapCosineGraphAroundCircle(FourierMachineScene):
|
||||||
DashedLine(
|
DashedLine(
|
||||||
ORIGIN, 2*UP, color = RED
|
ORIGIN, 2*UP, color = RED
|
||||||
).move_to(axes.coords_to_point(x, 0), DOWN)
|
).move_to(axes.coords_to_point(x, 0), DOWN)
|
||||||
for x in 1, 2
|
for x in (1, 2)
|
||||||
])
|
])
|
||||||
words = self.get_bps_label()
|
words = self.get_bps_label()
|
||||||
words.save_state()
|
words.save_state()
|
||||||
|
@ -1714,7 +1714,7 @@ class ShowLowerFrequency(DrawFrequencyPlot):
|
||||||
DashedLine(ORIGIN, 1.5*UP).move_to(
|
DashedLine(ORIGIN, 1.5*UP).move_to(
|
||||||
axes.coords_to_point(x, 0), DOWN
|
axes.coords_to_point(x, 0), DOWN
|
||||||
)
|
)
|
||||||
for x in 1, 2
|
for x in (1, 2)
|
||||||
])
|
])
|
||||||
bps_label = self.get_bps_label(2)
|
bps_label = self.get_bps_label(2)
|
||||||
bps_label.save_state()
|
bps_label.save_state()
|
||||||
|
@ -1866,7 +1866,7 @@ class ShowLinearity(DrawFrequencyPlot):
|
||||||
scale_val = 0.5,
|
scale_val = 0.5,
|
||||||
shift_val = 0.55,
|
shift_val = 0.55,
|
||||||
)
|
)
|
||||||
for freq in low_freq, high_freq
|
for freq in (low_freq, high_freq)
|
||||||
]
|
]
|
||||||
sum_graph = self.get_time_graph(
|
sum_graph = self.get_time_graph(
|
||||||
lambda t : sum([
|
lambda t : sum([
|
||||||
|
@ -2120,7 +2120,7 @@ class ShowCommutativeDiagram(ShowLinearity):
|
||||||
ReplacementTransform(
|
ReplacementTransform(
|
||||||
getattr(ta, attr), getattr(fa, attr)
|
getattr(ta, attr), getattr(fa, attr)
|
||||||
)
|
)
|
||||||
for attr in "x_axis", "y_axis", "graph"
|
for attr in ("x_axis", "y_axis", "graph")
|
||||||
]
|
]
|
||||||
anims += [
|
anims += [
|
||||||
GrowArrow(ta.arrow),
|
GrowArrow(ta.arrow),
|
||||||
|
@ -2308,7 +2308,7 @@ class FilterOutHighPitch(AddingPureFrequencies, ShowCommutativeDiagram):
|
||||||
|
|
||||||
func = lambda t : sum([
|
func = lambda t : sum([
|
||||||
np.cos(TAU*f*t)
|
np.cos(TAU*f*t)
|
||||||
for f in 0.5, 0.7, 1.0, 1.2, 3.0,
|
for f in (0.5, 0.7, 1.0, 1.2, 3.0,)
|
||||||
])
|
])
|
||||||
graph = axes.get_graph(func)
|
graph = axes.get_graph(func)
|
||||||
graph.set_color(BLUE)
|
graph.set_color(BLUE)
|
||||||
|
@ -2457,7 +2457,7 @@ class FilterOutHighPitch(AddingPureFrequencies, ShowCommutativeDiagram):
|
||||||
start_stroke_width = 5,
|
start_stroke_width = 5,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
for n in 5, 7, 10, 12
|
for n in (5, 7, 10, 12)
|
||||||
]
|
]
|
||||||
|
|
||||||
class AskAboutInverseFourier(TeacherStudentsScene):
|
class AskAboutInverseFourier(TeacherStudentsScene):
|
||||||
|
@ -2788,7 +2788,7 @@ class WriteComplexExponentialExpression(DrawFrequencyPlot):
|
||||||
#Show arc
|
#Show arc
|
||||||
arc, circle = [
|
arc, circle = [
|
||||||
Line(ORIGIN, t*UP)
|
Line(ORIGIN, t*UP)
|
||||||
for t in get_t(), TAU
|
for t in (get_t(), TAU)
|
||||||
]
|
]
|
||||||
for mob in arc, circle:
|
for mob in arc, circle:
|
||||||
mob.insert_n_anchor_points(20)
|
mob.insert_n_anchor_points(20)
|
||||||
|
@ -3315,7 +3315,7 @@ class ScaleUpCenterOfMass(WriteComplexExponentialExpression):
|
||||||
axes.get_graph(
|
axes.get_graph(
|
||||||
graph.underlying_function, x_min = 0, x_max = t_max,
|
graph.underlying_function, x_min = 0, x_max = t_max,
|
||||||
).match_style(graph)
|
).match_style(graph)
|
||||||
for t_max in 3, 6
|
for t_max in (3, 6)
|
||||||
]
|
]
|
||||||
for g in short_graph, long_graph:
|
for g in short_graph, long_graph:
|
||||||
self.get_polarized_mobject(g, freq = self.initial_winding_frequency)
|
self.get_polarized_mobject(g, freq = self.initial_winding_frequency)
|
||||||
|
@ -3400,7 +3400,7 @@ class ScaleUpCenterOfMass(WriteComplexExponentialExpression):
|
||||||
0.5, 1, smooth(a)
|
0.5, 1, smooth(a)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
for mob in long_graph, long_graph.polarized_mobject
|
for mob in (long_graph, long_graph.polarized_mobject)
|
||||||
],
|
],
|
||||||
run_time = 2
|
run_time = 2
|
||||||
)
|
)
|
||||||
|
@ -3843,7 +3843,7 @@ class BoundsAtInfinity(SummarizeFormula):
|
||||||
bound_rects.set_color(TEAL)
|
bound_rects.set_color(TEAL)
|
||||||
inf_bounds = VGroup(*[
|
inf_bounds = VGroup(*[
|
||||||
VGroup(TexMobject(s + "\\infty"))
|
VGroup(TexMobject(s + "\\infty"))
|
||||||
for s in "-", "+"
|
for s in ("-", "+")
|
||||||
])
|
])
|
||||||
decimal_bounds = VGroup(*[DecimalNumber(0) for x in range(2)])
|
decimal_bounds = VGroup(*[DecimalNumber(0) for x in range(2)])
|
||||||
for bound, inf_bound, d_bound in zip(bounds, inf_bounds, decimal_bounds):
|
for bound, inf_bound, d_bound in zip(bounds, inf_bounds, decimal_bounds):
|
||||||
|
@ -3928,7 +3928,7 @@ class BoundsAtInfinity(SummarizeFormula):
|
||||||
def get_time_interval(self, t1, t2):
|
def get_time_interval(self, t1, t2):
|
||||||
line = Line(*[
|
line = Line(*[
|
||||||
self.axes.coords_to_point(t, 0)
|
self.axes.coords_to_point(t, 0)
|
||||||
for t in t1, t2
|
for t in (t1, t2)
|
||||||
])
|
])
|
||||||
rect = Rectangle(
|
rect = Rectangle(
|
||||||
stroke_width = 0,
|
stroke_width = 0,
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
from __future__ import print_function
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
def break_up(mobject, factor = 1.3):
|
def break_up(mobject, factor = 1.3):
|
||||||
mobject.scale_in_place(factor)
|
mobject.scale_in_place(factor)
|
||||||
|
@ -498,7 +500,7 @@ class ExamplesOfDimension(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
labels = VGroup(*[
|
labels = VGroup(*[
|
||||||
TextMobject("%s-dimensional"%s)
|
TextMobject("%s-dimensional"%s)
|
||||||
for s in "1.585", "1.262", "1.21"
|
for s in ("1.585", "1.262", "1.21")
|
||||||
])
|
])
|
||||||
fractals = VGroup(*[
|
fractals = VGroup(*[
|
||||||
Sierpinski(order = 7),
|
Sierpinski(order = 7),
|
||||||
|
@ -548,7 +550,7 @@ class DimensionForNaturalNumbers(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
labels = VGroup(*[
|
labels = VGroup(*[
|
||||||
TextMobject("%d-dimensional"%d)
|
TextMobject("%d-dimensional"%d)
|
||||||
for d in 1, 2, 3
|
for d in (1, 2, 3)
|
||||||
])
|
])
|
||||||
for label, vect in zip(labels, [LEFT, ORIGIN, RIGHT]):
|
for label, vect in zip(labels, [LEFT, ORIGIN, RIGHT]):
|
||||||
label.to_edge(vect)
|
label.to_edge(vect)
|
||||||
|
@ -2380,7 +2382,7 @@ class DifferentSlopesAtDifferentScales(IntroduceLogLogPlot):
|
||||||
words.to_edge(RIGHT)
|
words.to_edge(RIGHT)
|
||||||
arrows = VGroup(*[
|
arrows = VGroup(*[
|
||||||
Arrow(words.get_left(), self.input_to_graph_point(x))
|
Arrow(words.get_left(), self.input_to_graph_point(x))
|
||||||
for x in 1, 7, 12
|
for x in (1, 7, 12)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@ -2567,7 +2569,7 @@ class WhatSlopeDoesLogLogPlotApproach(IntroduceLogLogPlot):
|
||||||
words = TextMobject(self.words)
|
words = TextMobject(self.words)
|
||||||
p1, p2 = [
|
p1, p2 = [
|
||||||
data_dots[int(alpha*len(data_dots))].get_center()
|
data_dots[int(alpha*len(data_dots))].get_center()
|
||||||
for alpha in 0.3, 0.5
|
for alpha in (0.3, 0.5)
|
||||||
]
|
]
|
||||||
words.rotate(Line(p1, p2).get_angle())
|
words.rotate(Line(p1, p2).get_angle())
|
||||||
words.next_to(p1, RIGHT, aligned_edge = DOWN, buff = 1.5)
|
words.next_to(p1, RIGHT, aligned_edge = DOWN, buff = 1.5)
|
||||||
|
@ -2639,7 +2641,7 @@ class SmoothBritainLogLogPlot(IntroduceLogLogPlot):
|
||||||
|
|
||||||
p1, p2, p3, p4 = [
|
p1, p2, p3, p4 = [
|
||||||
self.input_to_graph_point(x)
|
self.input_to_graph_point(x)
|
||||||
for x in 1, 2, 7, 8
|
for x in (1, 2, 7, 8)
|
||||||
]
|
]
|
||||||
interim_point1 = p2[0]*RIGHT + p1[1]*UP
|
interim_point1 = p2[0]*RIGHT + p1[1]*UP
|
||||||
interim_point2 = p4[0]*RIGHT + p3[1]*UP
|
interim_point2 = p4[0]*RIGHT + p3[1]*UP
|
||||||
|
@ -2742,7 +2744,7 @@ class CompareBritainAndNorway(Scene):
|
||||||
mob.set_stroke, None, 0,
|
mob.set_stroke, None, 0,
|
||||||
mob.set_fill, BLUE, 1
|
mob.set_fill, BLUE, 1
|
||||||
]
|
]
|
||||||
for mob in britain, norway
|
for mob in (britain, norway)
|
||||||
]))
|
]))
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class LogoGeneration(Scene):
|
||||||
self.interpolation_factor
|
self.interpolation_factor
|
||||||
)
|
)
|
||||||
for mob, color in [(iris, self.sphere_brown), (circle, self.circle_brown)]:
|
for mob, color in [(iris, self.sphere_brown), (circle, self.circle_brown)]:
|
||||||
mob.set_color(color, lambda (x, y, z) : x < 0 and y > 0)
|
mob.set_color(color, lambda x_y_z : x_y_z[0] < 0 and x_y_z[1] > 0)
|
||||||
mob.set_color(
|
mob.set_color(
|
||||||
"black",
|
"black",
|
||||||
lambda point: np.linalg.norm(point) < \
|
lambda point: np.linalg.norm(point) < \
|
||||||
|
|
|
@ -93,7 +93,7 @@ class CountingScene(Scene):
|
||||||
added_anims += self.get_new_configuration_animations()
|
added_anims += self.get_new_configuration_animations()
|
||||||
while continue_rolling_over:
|
while continue_rolling_over:
|
||||||
moving_dot.target.replace(
|
moving_dot.target.replace(
|
||||||
self.dot_template_iterators[place].next()
|
next(self.dot_template_iterators[place])
|
||||||
)
|
)
|
||||||
if run_all_at_once:
|
if run_all_at_once:
|
||||||
denom = float(num_rollovers+1)
|
denom = float(num_rollovers+1)
|
||||||
|
@ -267,7 +267,7 @@ class TowersOfHanoiScene(Scene):
|
||||||
peg.move_to(self.middle_peg_bottom, DOWN)
|
peg.move_to(self.middle_peg_bottom, DOWN)
|
||||||
self.pegs = VGroup(*[
|
self.pegs = VGroup(*[
|
||||||
peg.copy().shift(vect)
|
peg.copy().shift(vect)
|
||||||
for vect in self.peg_spacing*LEFT, ORIGIN, self.peg_spacing*RIGHT
|
for vect in (self.peg_spacing*LEFT, ORIGIN, self.peg_spacing*RIGHT)
|
||||||
])
|
])
|
||||||
self.add(self.pegs)
|
self.add(self.pegs)
|
||||||
if self.include_peg_labels:
|
if self.include_peg_labels:
|
||||||
|
@ -1357,7 +1357,7 @@ class IntroduceSolveByCounting(TowersOfHanoiScene):
|
||||||
])
|
])
|
||||||
bit_mobs.scale(2)
|
bit_mobs.scale(2)
|
||||||
self.bit_mobs_iter = it.cycle(bit_mobs)
|
self.bit_mobs_iter = it.cycle(bit_mobs)
|
||||||
self.curr_bit_mob = self.bit_mobs_iter.next()
|
self.curr_bit_mob = next(self.bit_mobs_iter)
|
||||||
|
|
||||||
for bit_mob in bit_mobs:
|
for bit_mob in bit_mobs:
|
||||||
bit_mob.align_data(self.curr_bit_mob)
|
bit_mob.align_data(self.curr_bit_mob)
|
||||||
|
@ -1370,7 +1370,7 @@ class IntroduceSolveByCounting(TowersOfHanoiScene):
|
||||||
def get_increment_animation(self):
|
def get_increment_animation(self):
|
||||||
return Succession(
|
return Succession(
|
||||||
Transform(
|
Transform(
|
||||||
self.curr_bit_mob, self.bit_mobs_iter.next(),
|
self.curr_bit_mob, next(self.bit_mobs_iter),
|
||||||
submobject_mode = "lagged_start",
|
submobject_mode = "lagged_start",
|
||||||
path_arc = -np.pi/3
|
path_arc = -np.pi/3
|
||||||
),
|
),
|
||||||
|
@ -1836,7 +1836,7 @@ class ShowFourDiskFourBitsParallel(IntroduceSolveByCounting):
|
||||||
|
|
||||||
def get_increment_animation(self):
|
def get_increment_animation(self):
|
||||||
return Transform(
|
return Transform(
|
||||||
self.curr_bit_mob, self.bit_mobs_iter.next(),
|
self.curr_bit_mob, next(self.bit_mobs_iter),
|
||||||
path_arc = -np.pi/3,
|
path_arc = -np.pi/3,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2259,7 +2259,7 @@ class SolveConstrainedByCounting(ConstrainedTowersOfHanoiScene):
|
||||||
ternary_mobs.add(ternary_mob)
|
ternary_mobs.add(ternary_mob)
|
||||||
ternary_mobs.next_to(self.peg_labels, DOWN)
|
ternary_mobs.next_to(self.peg_labels, DOWN)
|
||||||
self.ternary_mob_iter = it.cycle(ternary_mobs)
|
self.ternary_mob_iter = it.cycle(ternary_mobs)
|
||||||
self.curr_ternary_mob = self.ternary_mob_iter.next()
|
self.curr_ternary_mob = next(self.ternary_mob_iter)
|
||||||
self.add(self.curr_ternary_mob)
|
self.add(self.curr_ternary_mob)
|
||||||
|
|
||||||
for index in get_ternary_ruler_sequence(self.num_disks-1):
|
for index in get_ternary_ruler_sequence(self.num_disks-1):
|
||||||
|
@ -2270,7 +2270,7 @@ class SolveConstrainedByCounting(ConstrainedTowersOfHanoiScene):
|
||||||
def increment_animation(self):
|
def increment_animation(self):
|
||||||
return Succession(
|
return Succession(
|
||||||
Transform(
|
Transform(
|
||||||
self.curr_ternary_mob, self.ternary_mob_iter.next(),
|
self.curr_ternary_mob, next(self.ternary_mob_iter),
|
||||||
submobject_mode = "lagged_start",
|
submobject_mode = "lagged_start",
|
||||||
path_arc = np.pi/6,
|
path_arc = np.pi/6,
|
||||||
),
|
),
|
||||||
|
@ -2429,7 +2429,7 @@ class TernaryCountingSelfSimilarPattern(Scene):
|
||||||
])
|
])
|
||||||
ternary_mobs.scale(2)
|
ternary_mobs.scale(2)
|
||||||
ternary_mob_iter = it.cycle(ternary_mobs)
|
ternary_mob_iter = it.cycle(ternary_mobs)
|
||||||
curr_ternary_mob = ternary_mob_iter.next()
|
curr_ternary_mob = next(ternary_mob_iter)
|
||||||
|
|
||||||
for trits in ternary_mobs:
|
for trits in ternary_mobs:
|
||||||
trits.align_data(curr_ternary_mob)
|
trits.align_data(curr_ternary_mob)
|
||||||
|
@ -2437,7 +2437,7 @@ class TernaryCountingSelfSimilarPattern(Scene):
|
||||||
trit.set_color(color)
|
trit.set_color(color)
|
||||||
def get_increment():
|
def get_increment():
|
||||||
return Transform(
|
return Transform(
|
||||||
curr_ternary_mob, ternary_mob_iter.next(),
|
curr_ternary_mob, next(ternary_mob_iter),
|
||||||
submobject_mode = "lagged_start",
|
submobject_mode = "lagged_start",
|
||||||
path_arc = -np.pi/3
|
path_arc = -np.pi/3
|
||||||
)
|
)
|
||||||
|
@ -2504,7 +2504,7 @@ class SolveConstrainedWithTernaryCounting(ConstrainedTowersOfHanoiScene):
|
||||||
|
|
||||||
def increment_number(self, run_time = 1):
|
def increment_number(self, run_time = 1):
|
||||||
self.play(Transform(
|
self.play(Transform(
|
||||||
self.curr_ternary_mob, self.ternary_mob_iter.next(),
|
self.curr_ternary_mob, next(self.ternary_mob_iter),
|
||||||
path_arc = -np.pi/3,
|
path_arc = -np.pi/3,
|
||||||
submobject_mode = "lagged_start",
|
submobject_mode = "lagged_start",
|
||||||
run_time = run_time,
|
run_time = run_time,
|
||||||
|
@ -2512,7 +2512,7 @@ class SolveConstrainedWithTernaryCounting(ConstrainedTowersOfHanoiScene):
|
||||||
|
|
||||||
def move_next_disk(self, run_time = None, stay_on_peg = False):
|
def move_next_disk(self, run_time = None, stay_on_peg = False):
|
||||||
self.move_disk(
|
self.move_disk(
|
||||||
self.disk_index_iter.next(),
|
next(self.disk_index_iter),
|
||||||
run_time = run_time,
|
run_time = run_time,
|
||||||
stay_on_peg = stay_on_peg
|
stay_on_peg = stay_on_peg
|
||||||
)
|
)
|
||||||
|
@ -2986,7 +2986,7 @@ class IntroduceGraphStructure(SierpinskiGraphScene):
|
||||||
vect = -vect
|
vect = -vect
|
||||||
|
|
||||||
def define_edges(self):
|
def define_edges(self):
|
||||||
nodes = [self.nodes[i] for i in 12, 14]
|
nodes = [self.nodes[i] for i in (12, 14)]
|
||||||
for node, vect in zip(nodes, [LEFT, RIGHT]):
|
for node, vect in zip(nodes, [LEFT, RIGHT]):
|
||||||
node.save_state()
|
node.save_state()
|
||||||
node.generate_target()
|
node.generate_target()
|
||||||
|
|
|
@ -1937,7 +1937,7 @@ class TwoDBoxWithSliders(TwoDimensionalCase):
|
||||||
self.circle.copy().move_to(
|
self.circle.copy().move_to(
|
||||||
self.plane.coords_to_point(*coords)
|
self.plane.coords_to_point(*coords)
|
||||||
).set_color(GREY)
|
).set_color(GREY)
|
||||||
for coords in (1, 1), (-1, 1), (-1, -1)
|
for coords in ((1, 1), (-1, 1), (-1, -1))
|
||||||
])
|
])
|
||||||
line = Line(
|
line = Line(
|
||||||
self.plane.coords_to_point(-1, -1),
|
self.plane.coords_to_point(-1, -1),
|
||||||
|
@ -2055,7 +2055,7 @@ class TwoDBoxWithSliders(TwoDimensionalCase):
|
||||||
mob.shift,
|
mob.shift,
|
||||||
slider.number_to_point(1) - slider.number_to_point(-1)
|
slider.number_to_point(1) - slider.number_to_point(-1)
|
||||||
)
|
)
|
||||||
for mob in slider.real_estate_ticks, slider.dial
|
for mob in (slider.real_estate_ticks, slider.dial)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
slider.center_value = 1
|
slider.center_value = 1
|
||||||
|
@ -2657,7 +2657,7 @@ class TwoDInnerSphereTouchingBox(TwoDBoxWithSliders, PiCreatureScene):
|
||||||
radius = radius*self.plane.x_unit_size,
|
radius = radius*self.plane.x_unit_size,
|
||||||
color = GREEN
|
color = GREEN
|
||||||
).move_to(self.plane.coords_to_point(0, 0))
|
).move_to(self.plane.coords_to_point(0, 0))
|
||||||
for radius in np.sqrt(2)-1, 1
|
for radius in (np.sqrt(2)-1, 1)
|
||||||
]
|
]
|
||||||
randy = self.randy
|
randy = self.randy
|
||||||
tangency_points = VGroup(*[
|
tangency_points = VGroup(*[
|
||||||
|
|
|
@ -228,7 +228,7 @@ class FromKochToSpaceFilling(Scene):
|
||||||
words.to_edge(UP)
|
words.to_edge(UP)
|
||||||
koch, sharper_koch, duller_koch = curves = [
|
koch, sharper_koch, duller_koch = curves = [
|
||||||
CurveClass(order = 1)
|
CurveClass(order = 1)
|
||||||
for CurveClass in StraightKoch, SharperKoch, DullerKoch
|
for CurveClass in (StraightKoch, SharperKoch, DullerKoch)
|
||||||
]
|
]
|
||||||
arcs = [
|
arcs = [
|
||||||
Arc(
|
Arc(
|
||||||
|
@ -276,11 +276,11 @@ class FromKochToSpaceFilling(Scene):
|
||||||
text.to_edge(UP)
|
text.to_edge(UP)
|
||||||
sharper, duller, space_filling = [
|
sharper, duller, space_filling = [
|
||||||
CurveClass(order = 1).shift(3*LEFT)
|
CurveClass(order = 1).shift(3*LEFT)
|
||||||
for CurveClass in SharperKoch, DullerKoch, SpaceFillingKoch
|
for CurveClass in (SharperKoch, DullerKoch, SpaceFillingKoch)
|
||||||
]
|
]
|
||||||
shaper_f, duller_f, space_filling_f = [
|
shaper_f, duller_f, space_filling_f = [
|
||||||
CurveClass(order = self.max_order).shift(3*RIGHT)
|
CurveClass(order = self.max_order).shift(3*RIGHT)
|
||||||
for CurveClass in SharperKoch, DullerKoch, SpaceFillingKoch
|
for CurveClass in (SharperKoch, DullerKoch, SpaceFillingKoch)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.add(words[0])
|
self.add(words[0])
|
||||||
|
|
|
@ -101,7 +101,7 @@ class AboutSpaceFillingCurves(TransformOverIncreasingOrders):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ShimmerIn(mob)
|
ShimmerIn(mob)
|
||||||
for mob in infinity, rightarrow, N
|
for mob in (infinity, rightarrow, N)
|
||||||
] + [
|
] + [
|
||||||
ApplyMethod(question_mark.next_to, rightarrow, UP),
|
ApplyMethod(question_mark.next_to, rightarrow, UP),
|
||||||
])
|
])
|
||||||
|
@ -540,11 +540,11 @@ class ThinkInTermsOfReverseMapping(Scene):
|
||||||
arrow2 = Arrow(4*RIGHT+UP, dot2, color = color2, buff = 0.1)
|
arrow2 = Arrow(4*RIGHT+UP, dot2, color = color2, buff = 0.1)
|
||||||
dot3, arrow3 = [
|
dot3, arrow3 = [
|
||||||
mob.copy().shift(5*LEFT+UP)
|
mob.copy().shift(5*LEFT+UP)
|
||||||
for mob in dot1, arrow1
|
for mob in (dot1, arrow1)
|
||||||
]
|
]
|
||||||
dot4, arrow4 = [
|
dot4, arrow4 = [
|
||||||
mob.copy().shift(5*LEFT+0.9*UP)
|
mob.copy().shift(5*LEFT+0.9*UP)
|
||||||
for mob in dot2, arrow2
|
for mob in (dot2, arrow2)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.add(grid, freq_line, arrow)
|
self.add(grid, freq_line, arrow)
|
||||||
|
@ -659,7 +659,7 @@ class TellMathematicianFriend(Scene):
|
||||||
mathy, bubble = get_mathy_and_bubble()
|
mathy, bubble = get_mathy_and_bubble()
|
||||||
squiggle_mouth = mathy.mouth.copy()
|
squiggle_mouth = mathy.mouth.copy()
|
||||||
squiggle_mouth.apply_function(
|
squiggle_mouth.apply_function(
|
||||||
lambda (x, y, z) : (x, y+0.02*np.sin(50*x), z)
|
lambda x_y_z : (x_y_z[0], x_y_z[1]+0.02*np.sin(50*x_y_z[0]), x_y_z[2])
|
||||||
)
|
)
|
||||||
bubble.ingest_submobjects()
|
bubble.ingest_submobjects()
|
||||||
bubble.write("Why not use a Hilbert curve \\textinterrobang ")
|
bubble.write("Why not use a Hilbert curve \\textinterrobang ")
|
||||||
|
@ -898,7 +898,7 @@ class HilbertBetterThanSnakeQ(Scene):
|
||||||
CurveClass(order = n)
|
CurveClass(order = n)
|
||||||
for n in range(2, 7)
|
for n in range(2, 7)
|
||||||
]
|
]
|
||||||
for CurveClass in HilbertCurve, SnakeCurve
|
for CurveClass in (HilbertCurve, SnakeCurve)
|
||||||
]
|
]
|
||||||
for curve in hilbert_curves+snake_curves:
|
for curve in hilbert_curves+snake_curves:
|
||||||
curve.scale(0.8)
|
curve.scale(0.8)
|
||||||
|
@ -949,7 +949,7 @@ class IncreaseResolution(Scene):
|
||||||
2**order, 2**order,
|
2**order, 2**order,
|
||||||
stroke_width = 1
|
stroke_width = 1
|
||||||
).shift(0.3*DOWN)
|
).shift(0.3*DOWN)
|
||||||
for order in 6, 7
|
for order in (6, 7)
|
||||||
]
|
]
|
||||||
grid = grids[0]
|
grid = grids[0]
|
||||||
side_brace = Brace(grid, LEFT)
|
side_brace = Brace(grid, LEFT)
|
||||||
|
@ -995,7 +995,7 @@ class IncreasingResolutionWithSnakeCurve(Scene):
|
||||||
(0.7, RED)
|
(0.7, RED)
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
for curve in start_curve, end_curve
|
for curve in (start_curve, end_curve)
|
||||||
]
|
]
|
||||||
self.add(start_curve)
|
self.add(start_curve)
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
|
@ -190,7 +190,7 @@ class HistoryOfDiscover(Scene):
|
||||||
peano_curve.to_corner(UP+LEFT)
|
peano_curve.to_corner(UP+LEFT)
|
||||||
squares = Mobject(*[
|
squares = Mobject(*[
|
||||||
Square(side_length=3, color=WHITE).replace(curve)
|
Square(side_length=3, color=WHITE).replace(curve)
|
||||||
for curve in hilbert_curve, peano_curve
|
for curve in (hilbert_curve, peano_curve)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@ -499,15 +499,15 @@ class FormalDefinitionOfContinuity(Scene):
|
||||||
self.input_dot = Dot(color = self.input_color)
|
self.input_dot = Dot(color = self.input_color)
|
||||||
self.output_dot = self.input_dot.copy().set_color(self.output_color)
|
self.output_dot = self.input_dot.copy().set_color(self.output_color)
|
||||||
left, right = self.interval.get_left(), self.interval.get_right()
|
left, right = self.interval.get_left(), self.interval.get_right()
|
||||||
self.input_homotopy = lambda (x, y, z, t) : (x, y, t) + interpolate(left, right, t)
|
self.input_homotopy = lambda x_y_z_t : (x_y_z_t[0], x_y_z_t[1], x_y_z_t[3]) + interpolate(left, right, x_y_z_t[3])
|
||||||
output_size = self.output.get_num_points()-1
|
output_size = self.output.get_num_points()-1
|
||||||
output_points = self.output.points
|
output_points = self.output.points
|
||||||
self.output_homotopy = lambda (x, y, z, t) : (x, y, z) + output_points[int(t*output_size)]
|
self.output_homotopy = lambda x_y_z_t1 : (x_y_z_t1[0], x_y_z_t1[1], x_y_z_t1[2]) + output_points[int(x_y_z_t1[3]*output_size)]
|
||||||
|
|
||||||
def get_circles_and_points(self, min_input, max_input):
|
def get_circles_and_points(self, min_input, max_input):
|
||||||
input_left, input_right = [
|
input_left, input_right = [
|
||||||
self.interval.number_to_point(num)
|
self.interval.number_to_point(num)
|
||||||
for num in min_input, max_input
|
for num in (min_input, max_input)
|
||||||
]
|
]
|
||||||
input_circle = Circle(
|
input_circle = Circle(
|
||||||
radius = np.linalg.norm(input_left-input_right)/2,
|
radius = np.linalg.norm(input_left-input_right)/2,
|
||||||
|
@ -811,7 +811,7 @@ class WonderfulPropertyOfPseudoHilbertCurves(Scene):
|
||||||
FadeOut(arrow),
|
FadeOut(arrow),
|
||||||
*[
|
*[
|
||||||
FadeIn(func_parts[i])
|
FadeIn(func_parts[i])
|
||||||
for i in 0, 1, 2, 4
|
for i in (0, 1, 2, 4)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
for num in range(2,9):
|
for num in range(2,9):
|
||||||
|
|
|
@ -9,6 +9,7 @@ from random import sample
|
||||||
|
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
from script_wrapper import command_line_create_scene
|
from script_wrapper import command_line_create_scene
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
# from inventing_math_images import *
|
# from inventing_math_images import *
|
||||||
|
|
||||||
|
@ -351,7 +352,7 @@ class YouAsMathematician(Scene):
|
||||||
bubble.clear()
|
bubble.clear()
|
||||||
dot_pair = [
|
dot_pair = [
|
||||||
Dot(density = 3*DEFAULT_POINT_DENSITY_1D).shift(x+UP)
|
Dot(density = 3*DEFAULT_POINT_DENSITY_1D).shift(x+UP)
|
||||||
for x in LEFT, RIGHT
|
for x in (LEFT, RIGHT)
|
||||||
]
|
]
|
||||||
self.add(you, explanation)
|
self.add(you, explanation)
|
||||||
self.play(
|
self.play(
|
||||||
|
@ -376,7 +377,7 @@ class YouAsMathematician(Scene):
|
||||||
self.add(*dot_pair)
|
self.add(*dot_pair)
|
||||||
two_arrows = [
|
two_arrows = [
|
||||||
Arrow(x, direction = x).shift(UP).nudge()
|
Arrow(x, direction = x).shift(UP).nudge()
|
||||||
for x in LEFT, RIGHT
|
for x in (LEFT, RIGHT)
|
||||||
]
|
]
|
||||||
self.play(*[ShowCreation(a) for a in two_arrows])
|
self.play(*[ShowCreation(a) for a in two_arrows])
|
||||||
self.play(BlinkPiCreature(you))
|
self.play(BlinkPiCreature(you))
|
||||||
|
@ -412,7 +413,7 @@ class DotsGettingCloser(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
dots = [
|
dots = [
|
||||||
Dot(radius = 3*Dot.DEFAULT_RADIUS).shift(3*x)
|
Dot(radius = 3*Dot.DEFAULT_RADIUS).shift(3*x)
|
||||||
for x in LEFT, RIGHT
|
for x in (LEFT, RIGHT)
|
||||||
]
|
]
|
||||||
self.add(*dots)
|
self.add(*dots)
|
||||||
self.wait()
|
self.wait()
|
||||||
|
@ -428,7 +429,7 @@ class ZoomInOnInterval(Scene):
|
||||||
interval = zero_to_one_interval().split()
|
interval = zero_to_one_interval().split()
|
||||||
|
|
||||||
new_line = deepcopy(number_line)
|
new_line = deepcopy(number_line)
|
||||||
new_line.set_color("black", lambda (x,y,z) : x < 0 or x > 1 or y < -0.2)
|
new_line.set_color("black", lambda x_y_z1 : x_y_z1[0] < 0 or x_y_z1[0] > 1 or x_y_z1[1] < -0.2)
|
||||||
# height = new_line.get_height()
|
# height = new_line.get_height()
|
||||||
new_line.scale(2*INTERVAL_RADIUS)
|
new_line.scale(2*INTERVAL_RADIUS)
|
||||||
new_line.shift(INTERVAL_RADIUS*LEFT)
|
new_line.shift(INTERVAL_RADIUS*LEFT)
|
||||||
|
@ -465,7 +466,7 @@ class DanceDotOnInterval(Scene):
|
||||||
interval = zero_to_one_interval()
|
interval = zero_to_one_interval()
|
||||||
dots = [
|
dots = [
|
||||||
Dot(radius = 3*Dot.DEFAULT_RADIUS).shift(INTERVAL_RADIUS*x+UP)
|
Dot(radius = 3*Dot.DEFAULT_RADIUS).shift(INTERVAL_RADIUS*x+UP)
|
||||||
for x in LEFT, RIGHT
|
for x in (LEFT, RIGHT)
|
||||||
]
|
]
|
||||||
color_range = Color("green").range_to("yellow", num_written_terms)
|
color_range = Color("green").range_to("yellow", num_written_terms)
|
||||||
conv_sum = TexMobject(sum_terms, size = "\\large").split()
|
conv_sum = TexMobject(sum_terms, size = "\\large").split()
|
||||||
|
@ -480,7 +481,7 @@ class DanceDotOnInterval(Scene):
|
||||||
shift_val = 2*RIGHT*INTERVAL_RADIUS*(1-prop)*(prop**count)
|
shift_val = 2*RIGHT*INTERVAL_RADIUS*(1-prop)*(prop**count)
|
||||||
start = dots[0].get_center()
|
start = dots[0].get_center()
|
||||||
line = Line(start, start + shift_val*RIGHT)
|
line = Line(start, start + shift_val*RIGHT)
|
||||||
line.set_color(color_range.next())
|
line.set_color(next(color_range))
|
||||||
self.play(
|
self.play(
|
||||||
ApplyMethod(dots[0].shift, shift_val),
|
ApplyMethod(dots[0].shift, shift_val),
|
||||||
ShowCreation(line)
|
ShowCreation(line)
|
||||||
|
@ -570,7 +571,7 @@ class SeeNumbersApproachOne(Scene):
|
||||||
).scale(1+1.0/2.0**x).shift(
|
).scale(1+1.0/2.0**x).shift(
|
||||||
INTERVAL_RADIUS*RIGHT +\
|
INTERVAL_RADIUS*RIGHT +\
|
||||||
(INTERVAL_RADIUS/2.0**x)*LEFT
|
(INTERVAL_RADIUS/2.0**x)*LEFT
|
||||||
).set_color(colors.next())
|
).set_color(next(colors))
|
||||||
for x in range(num_dots)
|
for x in range(num_dots)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -661,7 +662,7 @@ class ListOfPartialSums(Scene):
|
||||||
).split())
|
).split())
|
||||||
numbers, equals, sums = [
|
numbers, equals, sums = [
|
||||||
all_terms[range(k, 12, 3)]
|
all_terms[range(k, 12, 3)]
|
||||||
for k in 0, 1, 2
|
for k in (0, 1, 2)
|
||||||
]
|
]
|
||||||
dots = all_terms[12]
|
dots = all_terms[12]
|
||||||
one = all_terms[-3]
|
one = all_terms[-3]
|
||||||
|
@ -755,7 +756,7 @@ class CircleZoomInOnOne(Scene):
|
||||||
|
|
||||||
self.play(*[
|
self.play(*[
|
||||||
DelayByOrder(FadeIn(mob))
|
DelayByOrder(FadeIn(mob))
|
||||||
for mob in arrow, curr_num
|
for mob in (arrow, curr_num)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
for num in numbers[1:] + [text]:
|
for num in numbers[1:] + [text]:
|
||||||
|
@ -775,16 +776,16 @@ class ZoomInOnOne(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
num_iterations = 8
|
num_iterations = 8
|
||||||
number_line = NumberLine(interval_size = 1, radius = FRAME_X_RADIUS+2)
|
number_line = NumberLine(interval_size = 1, radius = FRAME_X_RADIUS+2)
|
||||||
number_line.filter_out(lambda (x, y, z):abs(y)>0.1)
|
number_line.filter_out(lambda x_y_z2:abs(x_y_z2[1])>0.1)
|
||||||
nl_with_nums = deepcopy(number_line).add_numbers()
|
nl_with_nums = deepcopy(number_line).add_numbers()
|
||||||
self.play(ApplyMethod(nl_with_nums.shift, 2*LEFT))
|
self.play(ApplyMethod(nl_with_nums.shift, 2*LEFT))
|
||||||
zero, one, two = [
|
zero, one, two = [
|
||||||
TexMobject(str(n)).scale(0.5).shift(0.4*DOWN+2*(-1+n)*RIGHT)
|
TexMobject(str(n)).scale(0.5).shift(0.4*DOWN+2*(-1+n)*RIGHT)
|
||||||
for n in 0, 1, 2
|
for n in (0, 1, 2)
|
||||||
]
|
]
|
||||||
self.play(
|
self.play(
|
||||||
FadeOut(nl_with_nums),
|
FadeOut(nl_with_nums),
|
||||||
*[Animation(mob) for mob in zero, one, two, number_line]
|
*[Animation(mob) for mob in (zero, one, two, number_line)]
|
||||||
)
|
)
|
||||||
self.remove(nl_with_nums, number_line, zero, two)
|
self.remove(nl_with_nums, number_line, zero, two)
|
||||||
powers_of_10 = [10**(-n) for n in range(num_iterations+1)]
|
powers_of_10 = [10**(-n) for n in range(num_iterations+1)]
|
||||||
|
@ -796,7 +797,7 @@ class ZoomInOnOne(Scene):
|
||||||
|
|
||||||
def zoom_with_numbers(self, numbers, next_numbers):
|
def zoom_with_numbers(self, numbers, next_numbers):
|
||||||
all_numbers = map(
|
all_numbers = map(
|
||||||
lambda (n, u): TexMobject(str(n)).scale(0.5).shift(0.4*DOWN+2*u*RIGHT),
|
lambda n_u: TexMobject(str(n_u[0])).scale(0.5).shift(0.4*DOWN+2*n_u[1]*RIGHT),
|
||||||
zip(numbers+next_numbers, it.cycle([-1, 1]))
|
zip(numbers+next_numbers, it.cycle([-1, 1]))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -807,7 +808,7 @@ class ZoomInOnOne(Scene):
|
||||||
interval_size = 1,
|
interval_size = 1,
|
||||||
density = scale_factor*DEFAULT_POINT_DENSITY_1D
|
density = scale_factor*DEFAULT_POINT_DENSITY_1D
|
||||||
).filter_out(
|
).filter_out(
|
||||||
lambda (x, y, z):abs(y)>0.1
|
lambda x_y_z:abs(x_y_z[1])>0.1
|
||||||
).scale(1.0/scale_factor**x)
|
).scale(1.0/scale_factor**x)
|
||||||
for x in range(num_levels)
|
for x in range(num_levels)
|
||||||
]
|
]
|
||||||
|
@ -823,7 +824,7 @@ class ZoomInOnOne(Scene):
|
||||||
2*LEFT*(scale_factor-1)*(-1)**i,
|
2*LEFT*(scale_factor-1)*(-1)**i,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
for i in 0, 1
|
for i in (0, 1)
|
||||||
]+[
|
]+[
|
||||||
Transform(Point(0.4*DOWN + u*0.2*RIGHT), num, **kwargs)
|
Transform(Point(0.4*DOWN + u*0.2*RIGHT), num, **kwargs)
|
||||||
for u, num in zip([-1, 1], all_numbers[2:])
|
for u, num in zip([-1, 1], all_numbers[2:])
|
||||||
|
@ -917,7 +918,7 @@ class DefineInfiniteSum(Scene):
|
||||||
]
|
]
|
||||||
self.play(*[
|
self.play(*[
|
||||||
Transform(lines[x], lines[x+1], run_time = 3.0)
|
Transform(lines[x], lines[x+1], run_time = 3.0)
|
||||||
for x in 0, 2
|
for x in (0, 2)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@ -982,7 +983,7 @@ class ChopIntervalInProportions(Scene):
|
||||||
TexMobject("\\frac{%d}{%d}"%(k, (10**(count+1))))
|
TexMobject("\\frac{%d}{%d}"%(k, (10**(count+1))))
|
||||||
for count in range(num_terms)
|
for count in range(num_terms)
|
||||||
]
|
]
|
||||||
for k in 9, 1
|
for k in (9, 1)
|
||||||
]
|
]
|
||||||
if mode == "p":
|
if mode == "p":
|
||||||
num_terms = 4
|
num_terms = 4
|
||||||
|
@ -1359,7 +1360,7 @@ class SumPowersOfTwoAnimation(Scene):
|
||||||
topbrace = Underbrace(top_brace_left, right).rotate(np.pi, RIGHT)
|
topbrace = Underbrace(top_brace_left, right).rotate(np.pi, RIGHT)
|
||||||
bottombrace = Underbrace(bottom_brace_left, right)
|
bottombrace = Underbrace(bottom_brace_left, right)
|
||||||
colors = Color("yellow").range_to("purple", iterations)
|
colors = Color("yellow").range_to("purple", iterations)
|
||||||
curr_dots.set_color(colors.next())
|
curr_dots.set_color(next(colors))
|
||||||
equation = TexMobject(
|
equation = TexMobject(
|
||||||
"1+2+4+\\cdots+2^n=2^{n+1} - 1",
|
"1+2+4+\\cdots+2^n=2^{n+1} - 1",
|
||||||
size = "\\Huge"
|
size = "\\Huge"
|
||||||
|
@ -1386,7 +1387,7 @@ class SumPowersOfTwoAnimation(Scene):
|
||||||
shift_val = (2**n)*(dot_width+dot_buff)
|
shift_val = (2**n)*(dot_width+dot_buff)
|
||||||
right += shift_val
|
right += shift_val
|
||||||
new_dots = Mobject(new_dot, curr_dots)
|
new_dots = Mobject(new_dot, curr_dots)
|
||||||
new_dots.set_color(colors.next()).shift(shift_val)
|
new_dots.set_color(next(colors)).shift(shift_val)
|
||||||
alt_bottombrace = deepcopy(bottombrace).shift(shift_val)
|
alt_bottombrace = deepcopy(bottombrace).shift(shift_val)
|
||||||
alt_bottom_num = deepcopy(bottom_num).shift(shift_val)
|
alt_bottom_num = deepcopy(bottom_num).shift(shift_val)
|
||||||
alt_topbrace = deepcopy(alt_bottombrace).rotate(np.pi, RIGHT)
|
alt_topbrace = deepcopy(alt_bottombrace).rotate(np.pi, RIGHT)
|
||||||
|
@ -1655,9 +1656,9 @@ class TriangleInequality(Scene):
|
||||||
self.play(ShowCreation(ac_line), FadeIn(ac_copy))
|
self.play(ShowCreation(ac_line), FadeIn(ac_copy))
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ShowCreation(line) for line in ab_line, bc_line
|
ShowCreation(line) for line in (ab_line, bc_line)
|
||||||
]+[
|
]+[
|
||||||
FadeIn(dist) for dist in ab_copy, bc_copy
|
FadeIn(dist) for dist in (ab_copy, bc_copy)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
|
@ -1665,7 +1666,7 @@ class TriangleInequality(Scene):
|
||||||
for pair in zip(all_copies, all_dists)
|
for pair in zip(all_copies, all_dists)
|
||||||
]+[
|
]+[
|
||||||
FadeIn(mob)
|
FadeIn(mob)
|
||||||
for mob in plus, greater_than
|
for mob in (plus, greater_than)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
|
@ -1844,7 +1845,7 @@ class RoomsAndSubroomsWithNumbers(Scene):
|
||||||
return mob
|
return mob
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyFunction(transform, mob)
|
ApplyFunction(transform, mob)
|
||||||
for mob in zero_copy, power_mob_copy
|
for mob in (zero_copy, power_mob_copy)
|
||||||
])
|
])
|
||||||
last_left_mob = zero
|
last_left_mob = zero
|
||||||
for n in range(power+1, 2*power):
|
for n in range(power+1, 2*power):
|
||||||
|
@ -1852,7 +1853,7 @@ class RoomsAndSubroomsWithNumbers(Scene):
|
||||||
shift_val = left_mob.get_center()-last_left_mob.get_center()
|
shift_val = left_mob.get_center()-last_left_mob.get_center()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(mob.shift, shift_val)
|
ApplyMethod(mob.shift, shift_val)
|
||||||
for mob in zero_copy, power_mob_copy
|
for mob in (zero_copy, power_mob_copy)
|
||||||
])
|
])
|
||||||
num_mobs[n] = TexMobject(str(n))
|
num_mobs[n] = TexMobject(str(n))
|
||||||
num_mobs[n].scale(1.0/(power_of_divisor(n, 2)+1))
|
num_mobs[n].scale(1.0/(power_of_divisor(n, 2)+1))
|
||||||
|
@ -1901,7 +1902,7 @@ class RoomsAndSubroomsWithNumbers(Scene):
|
||||||
self.clear_way_for_text(text, cluster)
|
self.clear_way_for_text(text, cluster)
|
||||||
self.add(*cluster)
|
self.add(*cluster)
|
||||||
pairs = filter(
|
pairs = filter(
|
||||||
lambda (a, b) : (a-b)%(2**count) == 0 and (a-b)%(2**(count+1)) != 0,
|
lambda a_b : (a_b[0]-a_b[1])%(2**count) == 0 and (a_b[0]-a_b[1])%(2**(count+1)) != 0,
|
||||||
it.combinations(range(16), 2)
|
it.combinations(range(16), 2)
|
||||||
)
|
)
|
||||||
for pair in sample(pairs, min(10, len(pairs))):
|
for pair in sample(pairs, min(10, len(pairs))):
|
||||||
|
@ -1922,7 +1923,8 @@ class RoomsAndSubroomsWithNumbers(Scene):
|
||||||
def clear_way_for_text(text, mobjects):
|
def clear_way_for_text(text, mobjects):
|
||||||
right, top, null = np.max(text.points, 0)
|
right, top, null = np.max(text.points, 0)
|
||||||
left, bottom, null = np.min(text.points, 0)
|
left, bottom, null = np.min(text.points, 0)
|
||||||
def filter_func((x, y, z)):
|
def filter_func(xxx_todo_changeme):
|
||||||
|
(x, y, z) = xxx_todo_changeme
|
||||||
return x>left and x<right and y>bottom and y<top
|
return x>left and x<right and y>bottom and y<top
|
||||||
for mobject in mobjects:
|
for mobject in mobjects:
|
||||||
mobject.filter_out(filter_func)
|
mobject.filter_out(filter_func)
|
||||||
|
@ -1957,7 +1959,7 @@ class DeduceWhereNegativeOneFalls(Scene):
|
||||||
rest_time = 0.3 + 1.0/(n+1)
|
rest_time = 0.3 + 1.0/(n+1)
|
||||||
new_args = [
|
new_args = [
|
||||||
TextMobject("$%d$"%k).scale(1.5)
|
TextMobject("$%d$"%k).scale(1.5)
|
||||||
for k in 2**n-1, 2**n
|
for k in (2**n-1, 2**n)
|
||||||
]
|
]
|
||||||
for new_arg, old_arg in zip(new_args, last_args):
|
for new_arg, old_arg in zip(new_args, last_args):
|
||||||
new_arg.shift(old_arg.get_center())
|
new_arg.shift(old_arg.get_center())
|
||||||
|
@ -2015,7 +2017,7 @@ class PAdicMetric(Scene):
|
||||||
self.add(curr, text)
|
self.add(curr, text)
|
||||||
self.wait()
|
self.wait()
|
||||||
for prime, count in zip(primes, it.count()):
|
for prime, count in zip(primes, it.count()):
|
||||||
prime.scale(1.0).set_color(colors.next())
|
prime.scale(1.0).set_color(next(colors))
|
||||||
prime.shift(center_of_mass([p_str.get_top(), p_str.get_center()]))
|
prime.shift(center_of_mass([p_str.get_top(), p_str.get_center()]))
|
||||||
self.play(DelayByOrder(Transform(curr, prime)))
|
self.play(DelayByOrder(Transform(curr, prime)))
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools as it
|
import itertools as it
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
@ -7,7 +8,7 @@ import sys
|
||||||
|
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
from script_wrapper import command_line_create_scene
|
from script_wrapper import command_line_create_scene
|
||||||
from inventing_math import divergent_sum, draw_you
|
from .inventing_math import divergent_sum, draw_you
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
# revert_to_original_skipping_status
|
# revert_to_original_skipping_status
|
||||||
|
|
||||||
|
@ -840,7 +841,7 @@ class CountLatticePoints(LatticePointScene):
|
||||||
"\\approx \\pi", "(", R, ")^2"
|
"\\approx \\pi", "(", R, ")^2"
|
||||||
)
|
)
|
||||||
).arrange_submobjects(RIGHT)
|
).arrange_submobjects(RIGHT)
|
||||||
for R in "10", "1{,}000{,}000", "R"
|
for R in ("10", "1{,}000{,}000", "R")
|
||||||
])
|
])
|
||||||
radius_10_eq, radius_million_eq, radius_R_eq = equations
|
radius_10_eq, radius_million_eq, radius_R_eq = equations
|
||||||
for eq in equations:
|
for eq in equations:
|
||||||
|
@ -1747,7 +1748,7 @@ class NameGaussianIntegers(LatticePointScene):
|
||||||
integers.add_background_rectangle()
|
integers.add_background_rectangle()
|
||||||
arrows = VGroup(*[
|
arrows = VGroup(*[
|
||||||
Arrow(integers.get_top(), mob, tip_length = 0.15)
|
Arrow(integers.get_top(), mob, tip_length = 0.15)
|
||||||
for mob in a, b
|
for mob in (a, b)
|
||||||
])
|
])
|
||||||
self.add_foreground_mobjects(label, integers, arrows)
|
self.add_foreground_mobjects(label, integers, arrows)
|
||||||
|
|
||||||
|
@ -1836,7 +1837,7 @@ class NameGaussianIntegers(LatticePointScene):
|
||||||
self.plane.coords_to_point(x, u*y),
|
self.plane.coords_to_point(x, u*y),
|
||||||
color = PINK,
|
color = PINK,
|
||||||
)
|
)
|
||||||
for u in 1, -1
|
for u in (1, -1)
|
||||||
])
|
])
|
||||||
dot.conjugate_dot = self.circle_dots[-i]
|
dot.conjugate_dot = self.circle_dots[-i]
|
||||||
|
|
||||||
|
@ -1979,7 +1980,7 @@ class IntroduceGaussianPrimes(LatticePointScene, PiCreatureScene):
|
||||||
|
|
||||||
labels = [
|
labels = [
|
||||||
TexMobject(tex).add_background_rectangle()
|
TexMobject(tex).add_background_rectangle()
|
||||||
for tex in "5", "2+i", "2-i", "-1+2i", "-1-2i", "-2-i", "-2+i"
|
for tex in ("5", "2+i", "2-i", "-1+2i", "-1-2i", "-2-i", "-2+i")
|
||||||
]
|
]
|
||||||
five_label, p1_label, p2_label, p3_label, p4_label, p5_label, p6_label = labels
|
five_label, p1_label, p2_label, p3_label, p4_label, p5_label, p6_label = labels
|
||||||
vects = [
|
vects = [
|
||||||
|
@ -2393,7 +2394,7 @@ class FactorTwo(LatticePointScene):
|
||||||
two_dot.set_color(YELLOW)
|
two_dot.set_color(YELLOW)
|
||||||
factor_dots = VGroup(*[
|
factor_dots = VGroup(*[
|
||||||
Dot(self.plane.coords_to_point(1, u))
|
Dot(self.plane.coords_to_point(1, u))
|
||||||
for u in 1, -1
|
for u in (1, -1)
|
||||||
])
|
])
|
||||||
two_label = TexMobject("2").next_to(two_dot, DOWN)
|
two_label = TexMobject("2").next_to(two_dot, DOWN)
|
||||||
two_label.set_color(YELLOW)
|
two_label.set_color(YELLOW)
|
||||||
|
@ -2888,7 +2889,7 @@ class ThreeOutputsAsLatticePointsContinued(ThreeOutputsAsLatticePoints):
|
||||||
dot.add(line)
|
dot.add(line)
|
||||||
words_group = VGroup(*[
|
words_group = VGroup(*[
|
||||||
TextMobject("Multiply by $%s$"%s)
|
TextMobject("Multiply by $%s$"%s)
|
||||||
for s in "1", "i", "-1", "-i"
|
for s in ("1", "i", "-1", "-i")
|
||||||
])
|
])
|
||||||
for words, color in zip(words_group, self.colors):
|
for words, color in zip(words_group, self.colors):
|
||||||
words.add_background_rectangle()
|
words.add_background_rectangle()
|
||||||
|
@ -3212,7 +3213,7 @@ class SummarizeCountingRule(Show125Circle):
|
||||||
|
|
||||||
three, five, thirteen = [
|
three, five, thirteen = [
|
||||||
factorization.get_part_by_tex(str(n), substring = False)
|
factorization.get_part_by_tex(str(n), substring = False)
|
||||||
for n in 3, 5, 13
|
for n in (3, 5, 13)
|
||||||
]
|
]
|
||||||
three_power = factorization.get_part_by_tex("^4")
|
three_power = factorization.get_part_by_tex("^4")
|
||||||
five_power = factorization.get_part_by_tex("^3")
|
five_power = factorization.get_part_by_tex("^3")
|
||||||
|
@ -3583,7 +3584,7 @@ class IntroduceChi(FactorizationPattern):
|
||||||
)
|
)
|
||||||
braces = [
|
braces = [
|
||||||
Brace(expression[i], UP)
|
Brace(expression[i], UP)
|
||||||
for i in 0, 2, 4
|
for i in (0, 2, 4)
|
||||||
]
|
]
|
||||||
for brace, n in zip(braces, [x, y, x*y]):
|
for brace, n in zip(braces, [x, y, x*y]):
|
||||||
output = chi_func(n)
|
output = chi_func(n)
|
||||||
|
@ -4350,7 +4351,7 @@ class AddUpGrid(Scene):
|
||||||
rect.copy().move_to(self.radicals[N-1], LEFT)
|
rect.copy().move_to(self.radicals[N-1], LEFT)
|
||||||
for N in numbers
|
for N in numbers
|
||||||
])
|
])
|
||||||
for numbers in [6, 12], [2, 3, 5, 7, 11]
|
for numbers in ([6, 12], [2, 3, 5, 7, 11])
|
||||||
]
|
]
|
||||||
prime_rects.set_color(GREEN)
|
prime_rects.set_color(GREEN)
|
||||||
|
|
||||||
|
|
|
@ -93,9 +93,11 @@ class ExamplesOfOneDimensionalLinearTransforms(ShowMultiplication):
|
||||||
|
|
||||||
class ExamplesOfNonlinearOneDimensionalTransforms(NumberLineScene):
|
class ExamplesOfNonlinearOneDimensionalTransforms(NumberLineScene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
def sinx_plux_x((x, y, z)):
|
def sinx_plux_x(xxx_todo_changeme):
|
||||||
|
(x, y, z) = xxx_todo_changeme
|
||||||
return (np.sin(x) + 1.2*x, y, z)
|
return (np.sin(x) + 1.2*x, y, z)
|
||||||
def shift_zero((x, y, z)):
|
def shift_zero(xxx_todo_changeme2):
|
||||||
|
(x, y, z) = xxx_todo_changeme2
|
||||||
return (2*x+4, y, z)
|
return (2*x+4, y, z)
|
||||||
self.nonlinear = TextMobject("Not a Linear Transform")
|
self.nonlinear = TextMobject("Not a Linear Transform")
|
||||||
self.nonlinear.set_color(LIGHT_RED).to_edge(UP, buff = 1.5)
|
self.nonlinear.set_color(LIGHT_RED).to_edge(UP, buff = 1.5)
|
||||||
|
@ -187,10 +189,10 @@ class TransformScene2D(Scene):
|
||||||
)
|
)
|
||||||
self.add(self.x_arrow, self.y_arrow)
|
self.add(self.x_arrow, self.y_arrow)
|
||||||
self.number_plane.filter_out(
|
self.number_plane.filter_out(
|
||||||
lambda (x, y, z) : (0 < x) and (x < 1) and (abs(y) < 0.1)
|
lambda x_y_z : (0 < x_y_z[0]) and (x_y_z[0] < 1) and (abs(x_y_z[1]) < 0.1)
|
||||||
)
|
)
|
||||||
self.number_plane.filter_out(
|
self.number_plane.filter_out(
|
||||||
lambda (x, y, z) : (0 < y) and (y < 1) and (abs(x) < 0.1)
|
lambda x_y_z1 : (0 < x_y_z1[1]) and (x_y_z1[1] < 1) and (abs(x_y_z1[0]) < 0.1)
|
||||||
)
|
)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -293,9 +295,11 @@ class ExamplesOfTwoDimensionalLinearTransformations(ShowMatrixTransform):
|
||||||
class ExamplesOfNonlinearTwoDimensionalTransformations(Scene):
|
class ExamplesOfNonlinearTwoDimensionalTransformations(Scene):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
Scene.construct(self)
|
Scene.construct(self)
|
||||||
def squiggle((x, y, z)):
|
def squiggle(xxx_todo_changeme3):
|
||||||
|
(x, y, z) = xxx_todo_changeme3
|
||||||
return (x+np.sin(y), y+np.cos(x), z)
|
return (x+np.sin(y), y+np.cos(x), z)
|
||||||
def shift_zero((x, y, z)):
|
def shift_zero(xxx_todo_changeme4):
|
||||||
|
(x, y, z) = xxx_todo_changeme4
|
||||||
return (2*x + 3*y + 4, -1*x+y+2, z)
|
return (2*x + 3*y + 4, -1*x+y+2, z)
|
||||||
self.nonlinear = TextMobject("Nonlinear Transform")
|
self.nonlinear = TextMobject("Nonlinear Transform")
|
||||||
self.nonlinear.set_color(LIGHT_RED)
|
self.nonlinear.set_color(LIGHT_RED)
|
||||||
|
@ -382,10 +386,12 @@ class TrickyExamplesOfNonlinearTwoDimensionalTransformations(Scene):
|
||||||
UP*FRAME_Y_RADIUS+RIGHT*FRAME_X_RADIUS,
|
UP*FRAME_Y_RADIUS+RIGHT*FRAME_X_RADIUS,
|
||||||
density = 10*DEFAULT_POINT_DENSITY_1D
|
density = 10*DEFAULT_POINT_DENSITY_1D
|
||||||
)
|
)
|
||||||
def sunrise((x, y, z)):
|
def sunrise(xxx_todo_changeme5):
|
||||||
|
(x, y, z) = xxx_todo_changeme5
|
||||||
return ((FRAME_Y_RADIUS+y)*x, y, z)
|
return ((FRAME_Y_RADIUS+y)*x, y, z)
|
||||||
|
|
||||||
def squished((x, y, z)):
|
def squished(xxx_todo_changeme6):
|
||||||
|
(x, y, z) = xxx_todo_changeme6
|
||||||
return (x + np.sin(x), y+np.sin(y), z)
|
return (x + np.sin(x), y+np.sin(y), z)
|
||||||
|
|
||||||
self.get_blackness()
|
self.get_blackness()
|
||||||
|
@ -534,7 +540,7 @@ class Show90DegreeRotation(TransformScene2D):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
RotationAsTransform(mob, run_time = 2.0)
|
RotationAsTransform(mob, run_time = 2.0)
|
||||||
for mob in self.number_plane, self.x_arrow, self.y_arrow
|
for mob in (self.number_plane, self.x_arrow, self.y_arrow)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools as it
|
import itertools as it
|
||||||
import operator as op
|
import operator as op
|
||||||
|
@ -12,13 +13,13 @@ CIRCLE_DENSITY = DEFAULT_POINT_DENSITY_1D*RADIUS
|
||||||
|
|
||||||
|
|
||||||
def logo_to_circle():
|
def logo_to_circle():
|
||||||
from generate_logo import DARK_BROWN, LOGO_RADIUS
|
from .generate_logo import DARK_BROWN, LOGO_RADIUS
|
||||||
sc = Scene()
|
sc = Scene()
|
||||||
small_circle = Circle(
|
small_circle = Circle(
|
||||||
density = CIRCLE_DENSITY,
|
density = CIRCLE_DENSITY,
|
||||||
color = 'skyblue'
|
color = 'skyblue'
|
||||||
).scale(LOGO_RADIUS).set_color(
|
).scale(LOGO_RADIUS).set_color(
|
||||||
DARK_BROWN, lambda (x, y, z) : x < 0 and y > 0
|
DARK_BROWN, lambda x_y_z : x_y_z[0] < 0 and x_y_z[1] > 0
|
||||||
)
|
)
|
||||||
big_circle = Circle(density = CIRCLE_DENSITY).scale(RADIUS)
|
big_circle = Circle(density = CIRCLE_DENSITY).scale(RADIUS)
|
||||||
sc.add(small_circle)
|
sc.add(small_circle)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import inspect
|
||||||
|
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
from script_wrapper import command_line_create_scene
|
from script_wrapper import command_line_create_scene
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
RADIUS = FRAME_Y_RADIUS - 0.1
|
RADIUS = FRAME_Y_RADIUS - 0.1
|
||||||
CIRCLE_DENSITY = DEFAULT_POINT_DENSITY_1D*RADIUS
|
CIRCLE_DENSITY = DEFAULT_POINT_DENSITY_1D*RADIUS
|
||||||
|
@ -677,7 +678,7 @@ class GraphsAndEulersFormulaJoke(Scene):
|
||||||
lambda t : (10*t, ((10*t)**3 - 10*t), 0),
|
lambda t : (10*t, ((10*t)**3 - 10*t), 0),
|
||||||
expected_measure = 40.0
|
expected_measure = 40.0
|
||||||
)
|
)
|
||||||
graph.filter_out(lambda (x, y, z) : abs(y) > FRAME_Y_RADIUS)
|
graph.filter_out(lambda x_y_z : abs(x_y_z[1]) > FRAME_Y_RADIUS)
|
||||||
self.add(axes)
|
self.add(axes)
|
||||||
self.play(ShowCreation(graph), run_time = 1.0)
|
self.play(ShowCreation(graph), run_time = 1.0)
|
||||||
eulers = TexMobject("e^{\pi i} = -1").shift((0, 3, 0))
|
eulers = TexMobject("e^{\pi i} = -1").shift((0, 3, 0))
|
||||||
|
@ -1568,7 +1569,7 @@ class ExplainNChoose2Formula(Scene):
|
||||||
])
|
])
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(mob.shift, (0, 1, 0))
|
ApplyMethod(mob.shift, (0, 1, 0))
|
||||||
for mob in parens, a_mob, b_mob
|
for mob in (parens, a_mob, b_mob)
|
||||||
])
|
])
|
||||||
parens_copy = deepcopy(parens).shift((0, -2, 0))
|
parens_copy = deepcopy(parens).shift((0, -2, 0))
|
||||||
a_center = a_mob.get_center()
|
a_center = a_mob.get_center()
|
||||||
|
|
|
@ -1247,7 +1247,7 @@ class ShowRule(TeacherStudentsScene):
|
||||||
color = WHITE,
|
color = WHITE,
|
||||||
buff = SMALL_BUFF
|
buff = SMALL_BUFF
|
||||||
)
|
)
|
||||||
for mob in new_vertex, new_region
|
for mob in (new_vertex, new_region)
|
||||||
])
|
])
|
||||||
for word, arrow in zip(["Either", "or"], arrows):
|
for word, arrow in zip(["Either", "or"], arrows):
|
||||||
word_mob = TextMobject(word)
|
word_mob = TextMobject(word)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools as it
|
import itertools as it
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
@ -7,7 +8,7 @@ import sys
|
||||||
from fractions import Fraction, gcd
|
from fractions import Fraction, gcd
|
||||||
|
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
from inventing_math import Underbrace
|
from .inventing_math import Underbrace
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ class IntervalScene(NumberLineScene):
|
||||||
all_rationals = rationals()
|
all_rationals = rationals()
|
||||||
count = 0
|
count = 0
|
||||||
while True:
|
while True:
|
||||||
fraction = all_rationals.next()
|
fraction = next(all_rationals)
|
||||||
count += 1
|
count += 1
|
||||||
if num_intervals >= num_fractions:
|
if num_intervals >= num_fractions:
|
||||||
break
|
break
|
||||||
|
@ -314,7 +315,7 @@ class ChallengeOne(Scene):
|
||||||
top_vibrations = [
|
top_vibrations = [
|
||||||
Vibrate(
|
Vibrate(
|
||||||
num_periods = freq, run_time = 3.0,
|
num_periods = freq, run_time = 3.0,
|
||||||
center = 2*UP, color = colors.next()
|
center = 2*UP, color = next(colors)
|
||||||
)
|
)
|
||||||
for freq in [1, 2, 5.0/3, 4.0/3, 2]
|
for freq in [1, 2, 5.0/3, 4.0/3, 2]
|
||||||
]
|
]
|
||||||
|
@ -581,7 +582,7 @@ class PatternInFrequencies(Scene):
|
||||||
)
|
)
|
||||||
anims = [
|
anims = [
|
||||||
ApplyMethod(mob.shift, setup_width*LEFT, **kwargs)
|
ApplyMethod(mob.shift, setup_width*LEFT, **kwargs)
|
||||||
for mob in top_lines, bottom_lines
|
for mob in (top_lines, bottom_lines)
|
||||||
]
|
]
|
||||||
anim_mobs = [anim.mobject for anim in anims]
|
anim_mobs = [anim.mobject for anim in anims]
|
||||||
self.play(
|
self.play(
|
||||||
|
@ -614,12 +615,12 @@ class CompareFractionComplexity(Scene):
|
||||||
self.add(simple, complicated)
|
self.add(simple, complicated)
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ShowCreation(arrow)
|
ShowCreation(arrow)
|
||||||
for arrow in arrow1, arrow2
|
for arrow in (arrow1, arrow2)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
DelayByOrder(ApplyMethod(frac[1].set_color, "yellow"))
|
DelayByOrder(ApplyMethod(frac[1].set_color, "yellow"))
|
||||||
for frac in frac0, frac1
|
for frac in (frac0, frac1)
|
||||||
])
|
])
|
||||||
self.play(
|
self.play(
|
||||||
FadeIn(indicates),
|
FadeIn(indicates),
|
||||||
|
@ -851,7 +852,7 @@ class AllValuesBetween1And2(NumberLineScene):
|
||||||
}
|
}
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ApplyMethod(mob.shift, RIGHT, **kwargs)
|
ApplyMethod(mob.shift, RIGHT, **kwargs)
|
||||||
for mob in r, top_arrow
|
for mob in (r, top_arrow)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
self.remove(r, top_arrow)
|
self.remove(r, top_arrow)
|
||||||
|
@ -930,10 +931,10 @@ class DefineOpenInterval(IntervalScene):
|
||||||
left_arrow = Arrow(a.get_corner(DOWN+LEFT), left)
|
left_arrow = Arrow(a.get_corner(DOWN+LEFT), left)
|
||||||
right_arrow = Arrow(b.get_corner(DOWN+RIGHT), right)
|
right_arrow = Arrow(b.get_corner(DOWN+RIGHT), right)
|
||||||
|
|
||||||
self.play(*[ShimmerIn(mob) for mob in a, less_than1, x])
|
self.play(*[ShimmerIn(mob) for mob in (a, less_than1, x)])
|
||||||
self.play(ShowCreation(left_arrow))
|
self.play(ShowCreation(left_arrow))
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[ShimmerIn(mob) for mob in less_than2, b])
|
self.play(*[ShimmerIn(mob) for mob in (less_than2, b)])
|
||||||
self.play(ShowCreation(right_arrow))
|
self.play(ShowCreation(right_arrow))
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
|
@ -1229,7 +1230,7 @@ class StepsToSolution(IntervalScene):
|
||||||
arrow = Arrow(ORIGIN, RIGHT).next_to(dots)
|
arrow = Arrow(ORIGIN, RIGHT).next_to(dots)
|
||||||
one = TexMobject("1").next_to(arrow)
|
one = TexMobject("1").next_to(arrow)
|
||||||
self.ones.append(one)
|
self.ones.append(one)
|
||||||
self.play(*[ShowCreation(mob) for mob in dots, arrow, one])
|
self.play(*[ShowCreation(mob) for mob in (dots, arrow, one)])
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
def multiply_by_epsilon(self):
|
def multiply_by_epsilon(self):
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
NAME_WITH_SPACES = "Prime Meridian"
|
NAME_WITH_SPACES = "Prime Meridian"
|
||||||
|
@ -104,4 +105,4 @@ if __name__ == "__main__":
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "Could not animate %s: %s" % (name, e)
|
print("Could not animate %s: %s" % (name, e))
|
||||||
|
|
|
@ -8,6 +8,7 @@ using backpropagation. Note that I have focused on making the code
|
||||||
simple, easily readable, and easily modifiable. It is not optimized,
|
simple, easily readable, and easily modifiable. It is not optimized,
|
||||||
and omits many desirable features.
|
and omits many desirable features.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
#### Libraries
|
#### Libraries
|
||||||
# Standard library
|
# Standard library
|
||||||
|
@ -221,7 +222,7 @@ def test_network():
|
||||||
n_right += 1
|
n_right += 1
|
||||||
else:
|
else:
|
||||||
n_wrong += 1
|
n_wrong += 1
|
||||||
print(n_right, n_wrong, float(n_right)/(n_right + n_wrong))
|
print((n_right, n_wrong, float(n_right)/(n_right + n_wrong)))
|
||||||
|
|
||||||
def layer_to_image_array(layer):
|
def layer_to_image_array(layer):
|
||||||
w = int(np.ceil(np.sqrt(len(layer))))
|
w = int(np.ceil(np.sqrt(len(layer))))
|
||||||
|
|
|
@ -339,7 +339,7 @@ class ExampleThrees(PiCreatureScene):
|
||||||
three_mob_copy = three_mob[1].copy()
|
three_mob_copy = three_mob[1].copy()
|
||||||
three_mob_copy.sort_submobjects(lambda p : np.dot(p, DOWN+RIGHT))
|
three_mob_copy.sort_submobjects(lambda p : np.dot(p, DOWN+RIGHT))
|
||||||
|
|
||||||
braces = VGroup(*[Brace(three_mob, v) for v in LEFT, UP])
|
braces = VGroup(*[Brace(three_mob, v) for v in (LEFT, UP)])
|
||||||
brace_labels = VGroup(*[
|
brace_labels = VGroup(*[
|
||||||
brace.get_text("28px")
|
brace.get_text("28px")
|
||||||
for brace in braces
|
for brace in braces
|
||||||
|
@ -1070,7 +1070,7 @@ class IntroduceEachLayer(PreviewMNistNetwork):
|
||||||
neurons.space_out_submobjects(1.3)
|
neurons.space_out_submobjects(1.3)
|
||||||
neurons.to_edge(DOWN)
|
neurons.to_edge(DOWN)
|
||||||
|
|
||||||
braces = VGroup(*[Brace(neurons, vect) for vect in LEFT, UP])
|
braces = VGroup(*[Brace(neurons, vect) for vect in (LEFT, UP)])
|
||||||
labels = VGroup(*[
|
labels = VGroup(*[
|
||||||
brace.get_tex("28", buff = SMALL_BUFF)
|
brace.get_tex("28", buff = SMALL_BUFF)
|
||||||
for brace in braces
|
for brace in braces
|
||||||
|
@ -1517,7 +1517,7 @@ class BreakUpMacroPatterns(IntroduceEachLayer):
|
||||||
image_map = get_organized_images()
|
image_map = get_organized_images()
|
||||||
two, three, five = mobs = [
|
two, three, five = mobs = [
|
||||||
MNistMobject(image_map[n][0])
|
MNistMobject(image_map[n][0])
|
||||||
for n in 2, 3, 5
|
for n in (2, 3, 5)
|
||||||
]
|
]
|
||||||
self.added_patterns = VGroup()
|
self.added_patterns = VGroup()
|
||||||
for mob in mobs:
|
for mob in mobs:
|
||||||
|
@ -1846,7 +1846,7 @@ class BreakUpMicroPatterns(BreakUpMacroPatterns):
|
||||||
image_map = get_organized_images()
|
image_map = get_organized_images()
|
||||||
digits = VGroup(*[
|
digits = VGroup(*[
|
||||||
MNistMobject(image_map[n][1])
|
MNistMobject(image_map[n][1])
|
||||||
for n in 1, 4, 7
|
for n in (1, 4, 7)
|
||||||
])
|
])
|
||||||
digits.arrange_submobjects(RIGHT)
|
digits.arrange_submobjects(RIGHT)
|
||||||
digits.next_to(randy, RIGHT)
|
digits.next_to(randy, RIGHT)
|
||||||
|
@ -1892,7 +1892,7 @@ class SecondLayerIsLittleEdgeLayer(IntroduceEachLayer):
|
||||||
layers = self.network_mob.layers
|
layers = self.network_mob.layers
|
||||||
nine_im, loop_im, line_im = images = [
|
nine_im, loop_im, line_im = images = [
|
||||||
Image.open(get_full_raster_image_path("handwritten_%s"%s))
|
Image.open(get_full_raster_image_path("handwritten_%s"%s))
|
||||||
for s in "nine", "upper_loop", "right_line"
|
for s in ("nine", "upper_loop", "right_line")
|
||||||
]
|
]
|
||||||
nine_array, loop_array, line_array = [
|
nine_array, loop_array, line_array = [
|
||||||
np.array(im)[:,:,0]/255.0
|
np.array(im)[:,:,0]/255.0
|
||||||
|
@ -1929,7 +1929,7 @@ class SecondLayerIsLittleEdgeLayer(IntroduceEachLayer):
|
||||||
|
|
||||||
loop, line = [
|
loop, line = [
|
||||||
ImageMobject(layer_to_image_array(array.flatten()))
|
ImageMobject(layer_to_image_array(array.flatten()))
|
||||||
for array in loop_array, line_array
|
for array in (loop_array, line_array)
|
||||||
]
|
]
|
||||||
for mob, color in (loop, YELLOW), (line, RED):
|
for mob, color in (loop, YELLOW), (line, RED):
|
||||||
make_transparent(mob)
|
make_transparent(mob)
|
||||||
|
@ -2571,7 +2571,7 @@ class IntroduceWeights(IntroduceEachLayer):
|
||||||
self.negative_weights_color,
|
self.negative_weights_color,
|
||||||
0.5
|
0.5
|
||||||
)
|
)
|
||||||
for y in 6, 10
|
for y in (6, 10)
|
||||||
for x in range(14-4, 14+4)
|
for x in range(14-4, 14+4)
|
||||||
])
|
])
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
|
@ -2597,7 +2597,7 @@ class IntroduceWeights(IntroduceEachLayer):
|
||||||
d = int(np.sqrt(len(pixels)))
|
d = int(np.sqrt(len(pixels)))
|
||||||
return VGroup(*it.chain(*[
|
return VGroup(*it.chain(*[
|
||||||
pixels[d*n + d/2 - 4 : d*n + d/2 + 4]
|
pixels[d*n + d/2 - 4 : d*n + d/2 + 4]
|
||||||
for n in 6, 10
|
for n in (6, 10)
|
||||||
]))
|
]))
|
||||||
|
|
||||||
def make_edges_weighted(self, edges, weights):
|
def make_edges_weighted(self, edges, weights):
|
||||||
|
@ -2637,7 +2637,7 @@ class MotivateSquishing(Scene):
|
||||||
weighted_sum.get_bottom(),
|
weighted_sum.get_bottom(),
|
||||||
number_line.number_to_point(n),
|
number_line.number_to_point(n),
|
||||||
)
|
)
|
||||||
for n in -3, 3
|
for n in (-3, 3)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.play(Write(number_line))
|
self.play(Write(number_line))
|
||||||
|
@ -2761,7 +2761,7 @@ class IntroduceSigmoid(GraphScene):
|
||||||
x_max = x_max,
|
x_max = x_max,
|
||||||
color = color,
|
color = color,
|
||||||
).set_stroke(width = 4)
|
).set_stroke(width = 4)
|
||||||
for func in lambda x : 0, sigmoid
|
for func in (lambda x : 0, sigmoid)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.play(ShowCreation(line))
|
self.play(ShowCreation(line))
|
||||||
|
@ -3542,7 +3542,7 @@ class IntroduceWeightMatrix(NetworkScene):
|
||||||
self.wait()
|
self.wait()
|
||||||
self.play(*[
|
self.play(*[
|
||||||
LaggedStart(Indicate, mob, rate_func = there_and_back)
|
LaggedStart(Indicate, mob, rate_func = there_and_back)
|
||||||
for mob in a_labels, a_labels_in_sum
|
for mob in (a_labels, a_labels_in_sum)
|
||||||
])
|
])
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
|
@ -3573,7 +3573,7 @@ class IntroduceWeightMatrix(NetworkScene):
|
||||||
"\\cdots",
|
"\\cdots",
|
||||||
"w_{%s, n}"%i,
|
"w_{%s, n}"%i,
|
||||||
]))
|
]))
|
||||||
for i in "1", "k"
|
for i in ("1", "k")
|
||||||
]
|
]
|
||||||
dots_row = VGroup(*map(TexMobject, [
|
dots_row = VGroup(*map(TexMobject, [
|
||||||
"\\vdots", "\\vdots", "\\ddots", "\\vdots"
|
"\\vdots", "\\vdots", "\\ddots", "\\vdots"
|
||||||
|
@ -3678,7 +3678,7 @@ class IntroduceWeightMatrix(NetworkScene):
|
||||||
def show_meaning_of_lower_rows(self, arrow, brace, row_rect, result_terms):
|
def show_meaning_of_lower_rows(self, arrow, brace, row_rect, result_terms):
|
||||||
n1, n2, nk = neurons = VGroup(*[
|
n1, n2, nk = neurons = VGroup(*[
|
||||||
self.network_mob.layers[1].neurons[i]
|
self.network_mob.layers[1].neurons[i]
|
||||||
for i in 0, 1, -1
|
for i in (0, 1, -1)
|
||||||
])
|
])
|
||||||
for n in neurons:
|
for n in neurons:
|
||||||
n.save_state()
|
n.save_state()
|
||||||
|
@ -4074,7 +4074,7 @@ class NeuronIsFunction(MoreHonestMNistNetworkPreview):
|
||||||
run_time = 2,
|
run_time = 2,
|
||||||
submobject_mode = "lagged_start"
|
submobject_mode = "lagged_start"
|
||||||
)
|
)
|
||||||
for mob in self.network_mob.layers, self.network_mob.edge_groups
|
for mob in (self.network_mob.layers, self.network_mob.edge_groups)
|
||||||
]
|
]
|
||||||
anims += [
|
anims += [
|
||||||
FadeOut(self.neuron_arrow),
|
FadeOut(self.neuron_arrow),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
import cv2
|
import cv2
|
||||||
|
@ -460,7 +461,7 @@ class MNistDescription(Scene):
|
||||||
]
|
]
|
||||||
|
|
||||||
for i, td_group in enumerate(training_data_groups):
|
for i, td_group in enumerate(training_data_groups):
|
||||||
print i
|
print(i)
|
||||||
group = Group(*[
|
group = Group(*[
|
||||||
self.get_digit_pair(v_in, v_out)
|
self.get_digit_pair(v_in, v_out)
|
||||||
for v_in, v_out in td_group
|
for v_in, v_out in td_group
|
||||||
|
@ -656,7 +657,7 @@ class IntroduceCostFunction(PreviewLearning):
|
||||||
)
|
)
|
||||||
symbols = VGroup(*[
|
symbols = VGroup(*[
|
||||||
formula.get_parts_by_tex(tex)
|
formula.get_parts_by_tex(tex)
|
||||||
for tex in "=", "+", "dots"
|
for tex in ("=", "+", "dots")
|
||||||
])
|
])
|
||||||
|
|
||||||
w_labels.set_color(self.positive_edge_color)
|
w_labels.set_color(self.positive_edge_color)
|
||||||
|
@ -774,7 +775,7 @@ class IntroduceCostFunction(PreviewLearning):
|
||||||
FadeIn, group,
|
FadeIn, group,
|
||||||
run_time = 3,
|
run_time = 3,
|
||||||
)
|
)
|
||||||
for group in neurons, edges
|
for group in (neurons, edges)
|
||||||
])
|
])
|
||||||
|
|
||||||
def feed_in_example(self):
|
def feed_in_example(self):
|
||||||
|
@ -885,7 +886,7 @@ class IntroduceCostFunction(PreviewLearning):
|
||||||
desired_layer = self.desired_last_layer
|
desired_layer = self.desired_last_layer
|
||||||
decimal_groups = VGroup(*[
|
decimal_groups = VGroup(*[
|
||||||
self.num_vect_to_decimals(self.layer_to_num_vect(l))
|
self.num_vect_to_decimals(self.layer_to_num_vect(l))
|
||||||
for l in layer, desired_layer
|
for l in (layer, desired_layer)
|
||||||
])
|
])
|
||||||
|
|
||||||
terms = VGroup()
|
terms = VGroup()
|
||||||
|
@ -1060,7 +1061,7 @@ class IntroduceCostFunction(PreviewLearning):
|
||||||
random_v = np.random.random(10)
|
random_v = np.random.random(10)
|
||||||
new_decimal_groups = VGroup(*[
|
new_decimal_groups = VGroup(*[
|
||||||
self.num_vect_to_decimals(v)
|
self.num_vect_to_decimals(v)
|
||||||
for v in random_v, out_vect
|
for v in (random_v, out_vect)
|
||||||
])
|
])
|
||||||
for ds, nds in zip(decimal_groups, new_decimal_groups):
|
for ds, nds in zip(decimal_groups, new_decimal_groups):
|
||||||
for old_d, new_d in zip(ds, nds):
|
for old_d, new_d in zip(ds, nds):
|
||||||
|
@ -1077,7 +1078,7 @@ class IntroduceCostFunction(PreviewLearning):
|
||||||
self.add(new_image_group)
|
self.add(new_image_group)
|
||||||
image_group = new_image_group
|
image_group = new_image_group
|
||||||
|
|
||||||
self.wait(wait_times.next())
|
self.wait(next(wait_times))
|
||||||
|
|
||||||
####
|
####
|
||||||
|
|
||||||
|
@ -1465,7 +1466,7 @@ class SingleVariableCostFunction(GraphScene):
|
||||||
VGroup(cf[0], cf[2]).set_color(RED)
|
VGroup(cf[0], cf[2]).set_color(RED)
|
||||||
big_brace, lil_brace = [
|
big_brace, lil_brace = [
|
||||||
Brace(cf[1], DOWN)
|
Brace(cf[1], DOWN)
|
||||||
for cf in cf1, cf2
|
for cf in (cf1, cf2)
|
||||||
]
|
]
|
||||||
big_brace_text = big_brace.get_text("Weights and biases")
|
big_brace_text = big_brace.get_text("Weights and biases")
|
||||||
lil_brace_text = lil_brace.get_text("Single input")
|
lil_brace_text = lil_brace.get_text("Single input")
|
||||||
|
|
|
@ -2255,7 +2255,7 @@ class SimplestNetworkExample(PreviewLearning):
|
||||||
def label_neurons(self):
|
def label_neurons(self):
|
||||||
neurons = VGroup(*[
|
neurons = VGroup(*[
|
||||||
self.network_mob.layers[i].neurons[0]
|
self.network_mob.layers[i].neurons[0]
|
||||||
for i in -1, -2
|
for i in (-1, -2)
|
||||||
])
|
])
|
||||||
decimals = VGroup()
|
decimals = VGroup()
|
||||||
a_labels = VGroup()
|
a_labels = VGroup()
|
||||||
|
@ -2374,7 +2374,7 @@ class SimplestNetworkExample(PreviewLearning):
|
||||||
cost_equation.to_corner(UP+RIGHT)
|
cost_equation.to_corner(UP+RIGHT)
|
||||||
C0, a, y = [
|
C0, a, y = [
|
||||||
cost_equation.get_part_by_tex(tex)
|
cost_equation.get_part_by_tex(tex)
|
||||||
for tex in "C_0", "a^{(L)}", "y"
|
for tex in ("C_0", "a^{(L)}", "y")
|
||||||
]
|
]
|
||||||
y.set_color(YELLOW)
|
y.set_color(YELLOW)
|
||||||
|
|
||||||
|
@ -2577,7 +2577,7 @@ class SimplestNetworkExample(PreviewLearning):
|
||||||
self.play(MoveToTarget(C0))
|
self.play(MoveToTarget(C0))
|
||||||
self.play(*it.chain(*[
|
self.play(*it.chain(*[
|
||||||
[ShowCreation(line), line.flash]
|
[ShowCreation(line), line.flash]
|
||||||
for line in a_to_c_line, y_to_c_line
|
for line in (a_to_c_line, y_to_c_line)
|
||||||
]))
|
]))
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
|
|
||||||
|
@ -2895,7 +2895,7 @@ class SimplestNetworkExample(PreviewLearning):
|
||||||
dC_dw = self.dC_dw
|
dC_dw = self.dC_dw
|
||||||
del_syms = [
|
del_syms = [
|
||||||
getattr(self, attr)
|
getattr(self, attr)
|
||||||
for attr in "del_wL", "del_zL", "del_aL", "del_C0"
|
for attr in ("del_wL", "del_zL", "del_aL", "del_C0")
|
||||||
]
|
]
|
||||||
|
|
||||||
dz_dw = TexMobject(
|
dz_dw = TexMobject(
|
||||||
|
@ -3088,7 +3088,7 @@ class SimplestNetworkExample(PreviewLearning):
|
||||||
neuron.set_fill, None, target_o,
|
neuron.set_fill, None, target_o,
|
||||||
*[
|
*[
|
||||||
ChangingDecimal(d, lambda a : neuron.get_fill_opacity())
|
ChangingDecimal(d, lambda a : neuron.get_fill_opacity())
|
||||||
for d in decimal, moving_decimals[0]
|
for d in (decimal, moving_decimals[0])
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
self.play(*map(FadeOut, [double_arrow, moving_decimals]))
|
self.play(*map(FadeOut, [double_arrow, moving_decimals]))
|
||||||
|
@ -3726,8 +3726,8 @@ class GeneralFormulas(SimplestNetworkExample):
|
||||||
all_subscript_rects.add(subscript_rects)
|
all_subscript_rects.add(subscript_rects)
|
||||||
|
|
||||||
start_labels, start_arrows = [
|
start_labels, start_arrows = [
|
||||||
VGroup(*map(VGroup, [group[i][0] for i in 0, 1])).copy()
|
VGroup(*map(VGroup, [group[i][0] for i in (0, 1)])).copy()
|
||||||
for group in all_labels, all_arrows
|
for group in (all_labels, all_arrows)
|
||||||
]
|
]
|
||||||
for label in start_labels:
|
for label in start_labels:
|
||||||
label[0][-1].set_color(BLACK)
|
label[0][-1].set_color(BLACK)
|
||||||
|
@ -3856,7 +3856,7 @@ class GeneralFormulas(SimplestNetworkExample):
|
||||||
|
|
||||||
self.play(*[
|
self.play(*[
|
||||||
ReplacementTransform(mob, mob.target)
|
ReplacementTransform(mob, mob.target)
|
||||||
for mob in aj, yj
|
for mob in (aj, yj)
|
||||||
])
|
])
|
||||||
self.play(LaggedStart(FadeIn, to_fade_in))
|
self.play(LaggedStart(FadeIn, to_fade_in))
|
||||||
self.wait(2)
|
self.wait(2)
|
||||||
|
@ -4050,7 +4050,7 @@ class GeneralFormulas(SimplestNetworkExample):
|
||||||
neurons = self.network_mob.layers[-1].neurons
|
neurons = self.network_mob.layers[-1].neurons
|
||||||
labels, arrows, decimals = [
|
labels, arrows, decimals = [
|
||||||
VGroup(*[getattr(n, attr) for n in neurons])
|
VGroup(*[getattr(n, attr) for n in neurons])
|
||||||
for attr in "label", "arrow", "decimal"
|
for attr in ("label", "arrow", "decimal")
|
||||||
]
|
]
|
||||||
edges = VGroup(*[n.edges_in[1] for n in neurons])
|
edges = VGroup(*[n.edges_in[1] for n in neurons])
|
||||||
labels[0].generate_target()
|
labels[0].generate_target()
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
from constants import *
|
from constants import *
|
||||||
|
|
|
@ -19,7 +19,7 @@ class SideGigToFullTime(Scene):
|
||||||
dollar_sign = TexMobject("\\$")
|
dollar_sign = TexMobject("\\$")
|
||||||
cross = VGroup(*[
|
cross = VGroup(*[
|
||||||
Line(vect, -vect, color = RED)
|
Line(vect, -vect, color = RED)
|
||||||
for vect in UP+RIGHT, UP+LEFT
|
for vect in (UP+RIGHT, UP+LEFT)
|
||||||
])
|
])
|
||||||
cross.scale_to_fit_height(dollar_sign.get_height())
|
cross.scale_to_fit_height(dollar_sign.get_height())
|
||||||
no_money = VGroup(dollar_sign, cross)
|
no_money = VGroup(dollar_sign, cross)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import itertools as it
|
import itertools as it
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
@ -12,6 +13,7 @@ from constants import *
|
||||||
from mobject.region import *
|
from mobject.region import *
|
||||||
from scene.scene import Scene, SceneFromVideo
|
from scene.scene import Scene, SceneFromVideo
|
||||||
from script_wrapper import command_line_create_scene
|
from script_wrapper import command_line_create_scene
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
MOVIE_PREFIX = "counting_in_binary/"
|
MOVIE_PREFIX = "counting_in_binary/"
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class IntroducePutnam(Scene):
|
||||||
TextMobject("%s%d)"%(c, i))
|
TextMobject("%s%d)"%(c, i))
|
||||||
for i in range(1, 7)
|
for i in range(1, 7)
|
||||||
]).arrange_submobjects(DOWN, buff = MED_LARGE_BUFF)
|
]).arrange_submobjects(DOWN, buff = MED_LARGE_BUFF)
|
||||||
for c in "A", "B"
|
for c in ("A", "B")
|
||||||
]).arrange_submobjects(RIGHT, buff = FRAME_X_RADIUS - MED_SMALL_BUFF)
|
]).arrange_submobjects(RIGHT, buff = FRAME_X_RADIUS - MED_SMALL_BUFF)
|
||||||
question_groups.to_edge(LEFT)
|
question_groups.to_edge(LEFT)
|
||||||
question_groups.to_edge(DOWN, MED_LARGE_BUFF)
|
question_groups.to_edge(DOWN, MED_LARGE_BUFF)
|
||||||
|
|
|
@ -324,7 +324,7 @@ class DrawCSquareWithAllTraingles(Scene):
|
||||||
toggle_vector = [False]*4
|
toggle_vector = [False]*4
|
||||||
self.c_square = c_square().center()
|
self.c_square = c_square().center()
|
||||||
vertices = it.cycle(self.c_square.get_vertices())
|
vertices = it.cycle(self.c_square.get_vertices())
|
||||||
last_vertex = vertices.next()
|
last_vertex = next(vertices)
|
||||||
have_letters = False
|
have_letters = False
|
||||||
self.triangles = []
|
self.triangles = []
|
||||||
for vertex, should_flip in zip(vertices, toggle_vector):
|
for vertex, should_flip in zip(vertices, toggle_vector):
|
||||||
|
@ -385,8 +385,8 @@ class ZoomInOnTroublePoint(Scene):
|
||||||
circle = Circle(radius = 2.5, color = WHITE)
|
circle = Circle(radius = 2.5, color = WHITE)
|
||||||
angle1_arc = Circle(color = WHITE)
|
angle1_arc = Circle(color = WHITE)
|
||||||
angle2_arc = Circle(color = WHITE).scale(0.5)
|
angle2_arc = Circle(color = WHITE).scale(0.5)
|
||||||
angle1_arc.filter_out(lambda (x, y, z) : not (x > 0 and y > 0 and y < x/3))
|
angle1_arc.filter_out(lambda x_y_z2 : not (x_y_z2[0] > 0 and x_y_z2[1] > 0 and x_y_z2[1] < x_y_z2[0]/3))
|
||||||
angle2_arc.filter_out(lambda (x, y, z) : not (x < 0 and y > 0 and y < -3*x))
|
angle2_arc.filter_out(lambda x_y_z3 : not (x_y_z3[0] < 0 and x_y_z3[1] > 0 and x_y_z3[1] < -3*x_y_z3[0]))
|
||||||
|
|
||||||
self.add_mobjects_among(locals().values())
|
self.add_mobjects_among(locals().values())
|
||||||
self.add_elbow()
|
self.add_elbow()
|
||||||
|
@ -422,10 +422,10 @@ class DrawTriangleWithAngles(Scene):
|
||||||
vertices = triangle.get_vertices()
|
vertices = triangle.get_vertices()
|
||||||
kwargs = {"color" : WHITE}
|
kwargs = {"color" : WHITE}
|
||||||
angle1_arc = Circle(radius = 0.4, **kwargs).filter_out(
|
angle1_arc = Circle(radius = 0.4, **kwargs).filter_out(
|
||||||
lambda (x, y, z) : not(x > 0 and y < 0 and y < -3*x)
|
lambda x_y_z : not(x_y_z[0] > 0 and x_y_z[1] < 0 and x_y_z[1] < -3*x_y_z[0])
|
||||||
).shift(vertices[1])
|
).shift(vertices[1])
|
||||||
angle2_arc = Circle(radius = 0.2, **kwargs).filter_out(
|
angle2_arc = Circle(radius = 0.2, **kwargs).filter_out(
|
||||||
lambda (x, y, z) : not(x < 0 and y > 0 and y < -3*x)
|
lambda x_y_z1 : not(x_y_z1[0] < 0 and x_y_z1[1] > 0 and x_y_z1[1] < -3*x_y_z1[0])
|
||||||
).shift(vertices[2])
|
).shift(vertices[2])
|
||||||
alpha = TexMobject("\\alpha")
|
alpha = TexMobject("\\alpha")
|
||||||
beta = TexMobject("90-\\alpha")
|
beta = TexMobject("90-\\alpha")
|
||||||
|
|
|
@ -100,7 +100,7 @@ class PowersOfTwo(Scene):
|
||||||
two_to_ten.get_corner(vect+RIGHT),
|
two_to_ten.get_corner(vect+RIGHT),
|
||||||
mob[0].get_corner(vect+LEFT),
|
mob[0].get_corner(vect+LEFT),
|
||||||
)
|
)
|
||||||
for vect in UP, DOWN
|
for vect in (UP, DOWN)
|
||||||
])
|
])
|
||||||
two_to_ten.save_state()
|
two_to_ten.save_state()
|
||||||
two_to_ten.replace(mob[0])
|
two_to_ten.replace(mob[0])
|
||||||
|
|
|
@ -404,7 +404,7 @@ class ExplainTrigFunctionDistances(TrigRepresentationsScene, PiCreatureScene):
|
||||||
|
|
||||||
sec_dot, csc_dot = [
|
sec_dot, csc_dot = [
|
||||||
Dot(line.get_end(), color = line.get_color())
|
Dot(line.get_end(), color = line.get_color())
|
||||||
for line in sec_line, csc_line
|
for line in (sec_line, csc_line)
|
||||||
]
|
]
|
||||||
sec_group.add(sec_dot)
|
sec_group.add(sec_dot)
|
||||||
csc_group.add(csc_dot)
|
csc_group.add(csc_dot)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue