Editing some div_curl scenes I want to carry over

This commit is contained in:
Grant Sanderson
2019-03-28 16:19:46 -07:00
parent 5337dc5ee4
commit ea4df1f41e

View File

@ -2817,18 +2817,16 @@ class ShowTwoPopulations(Scene):
num_foxes = Integer(10) num_foxes = Integer(10)
num_foxes.scale(self.count_word_scale_val) num_foxes.scale(self.count_word_scale_val)
num_foxes.next_to(labels[0], RIGHT) num_foxes.next_to(labels[0], RIGHT)
num_foxes.align_to(labels[0][1], DOWN) num_foxes.align_to(labels[0][0][1], DOWN)
num_rabbits = Integer(10) num_rabbits = Integer(10)
num_rabbits.scale(self.count_word_scale_val) num_rabbits.scale(self.count_word_scale_val)
num_rabbits.next_to(labels[1], RIGHT) num_rabbits.next_to(labels[1], RIGHT)
num_rabbits.align_to(labels[1][1], DOWN) num_rabbits.align_to(labels[1][0][1], DOWN)
self.add(ContinualChangingDecimal( num_foxes.add_updater(lambda d: d.set_value(get_num_foxes()))
num_foxes, lambda a: get_num_foxes() num_rabbits.add_updater(lambda d: d.set_value(get_num_rabbits()))
))
self.add(ContinualChangingDecimal( self.add(num_foxes, num_rabbits)
num_rabbits, lambda a: get_num_rabbits()
))
for count in num_foxes, num_rabbits: for count in num_foxes, num_rabbits:
self.add(Mobject.add_updater( self.add(Mobject.add_updater(
@ -2853,13 +2851,13 @@ class ShowTwoPopulations(Scene):
height=self.animal_height, height=self.animal_height,
fill_color=color, fill_color=color,
) )
for submob in result.family_members_with_points(): # for submob in result.family_members_with_points():
if submob.is_subpath: # if submob.is_subpath:
submob.is_subpath = False # submob.is_subpath = False
submob.set_fill( # submob.set_fill(
interpolate_color(color, BLACK, 0.8), # interpolate_color(color, BLACK, 0.8),
opacity=1 # opacity=1
) # )
x_shift, y_shift = [ x_shift, y_shift = [
(2 * random.random() - 1) * max_val (2 * random.random() - 1) * max_val
for max_val in [ for max_val in [
@ -3021,25 +3019,7 @@ class PhaseSpaceOfPopulationModel(ShowTwoPopulations, PiCreatureScene, MovingCam
self.pop_sizes_updates = pop_sizes_updates self.pop_sizes_updates = pop_sizes_updates
def write_differential_equations(self): def write_differential_equations(self):
variables = ["X", "YY"] equations = self.get_equations()
equations = TexMobject(
"""
{dX \\over dt} =
X \\cdot (\\alpha - \\beta YY \\,) \\\\
\\quad \\\\
{dYY \\over dt} =
YY \\cdot (\\delta X - \\gamma)
""",
substrings_to_isolate=variables
)
animals = [self.get_rabbit(), self.get_fox().flip()]
for char, animal in zip(variables, animals):
for part in equations.get_parts_by_tex(char):
animal_copy = animal.copy()
animal_copy.set_height(0.5)
animal_copy.move_to(part, DL)
Transform(part, animal_copy).update(1)
equations.shift(2 * DOWN) equations.shift(2 * DOWN)
rect = SurroundingRectangle(equations, color=YELLOW) rect = SurroundingRectangle(equations, color=YELLOW)
rect.set_fill(BLACK, 0.8) rect.set_fill(BLACK, 0.8)
@ -3183,6 +3163,28 @@ class PhaseSpaceOfPopulationModel(ShowTwoPopulations, PiCreatureScene, MovingCam
) )
self.wait(self.flow_time) self.wait(self.flow_time)
#
def get_equations(self):
variables = ["X", "YY"]
equations = TexMobject(
"""
{dX \\over dt} =
X \\cdot (\\alpha - \\beta YY \\,) \\\\
\\quad \\\\
{dYY \\over dt} =
YY \\cdot (\\delta X - \\gamma)
""",
substrings_to_isolate=variables
)
animals = [self.get_rabbit(), self.get_fox().flip()]
for char, animal in zip(variables, animals):
for part in equations.get_parts_by_tex(char):
animal_copy = animal.copy()
animal_copy.set_height(0.5)
animal_copy.move_to(part, DL)
part.become(animal_copy)
return equations
class PhaseFlowWords(Scene): class PhaseFlowWords(Scene):
def construct(self): def construct(self):