mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 08:07:44 +00:00
sort_submobject -> sort and shuffle_submobjects -> shuffle
This commit is contained in:
parent
8f556ffb89
commit
eb0c63606d
24 changed files with 62 additions and 56 deletions
|
|
@ -2366,13 +2366,13 @@ class ChooseThreeFromFive(InitialFiveChooseThreeExample, PiCreatureScene):
|
||||||
for x in range(6):
|
for x in range(6):
|
||||||
line.generate_target()
|
line.generate_target()
|
||||||
resorter = VGroup(*line.target)
|
resorter = VGroup(*line.target)
|
||||||
resorter.sort_submobjects(lambda p : random.random())
|
resorter.sort(lambda p : random.random())
|
||||||
resorter.arrange(RIGHT, buff = SMALL_BUFF)
|
resorter.arrange(RIGHT, buff = SMALL_BUFF)
|
||||||
resorter.move_to(line)
|
resorter.move_to(line)
|
||||||
self.play(MoveToTarget(line, path_arc = np.pi))
|
self.play(MoveToTarget(line, path_arc = np.pi))
|
||||||
self.play(FadeOut(q_marks))
|
self.play(FadeOut(q_marks))
|
||||||
|
|
||||||
line.sort_submobjects(lambda p : p[0])
|
line.sort(lambda p : p[0])
|
||||||
words = VGroup(*list(map(TextMobject, ["First", "Second", "Fifth"])))
|
words = VGroup(*list(map(TextMobject, ["First", "Second", "Fifth"])))
|
||||||
words.set_color(YELLOW)
|
words.set_color(YELLOW)
|
||||||
words.scale(0.75)
|
words.scale(0.75)
|
||||||
|
|
|
||||||
|
|
@ -903,7 +903,7 @@ class ThousandPossibleQuizzes(Scene):
|
||||||
top_split = VGroup(*self.quizzes[:n])
|
top_split = VGroup(*self.quizzes[:n])
|
||||||
bottom_split = VGroup(*self.quizzes[n:])
|
bottom_split = VGroup(*self.quizzes[n:])
|
||||||
for split, color, vect in (top_split, GREEN, UP), (bottom_split, RED, DOWN):
|
for split, color, vect in (top_split, GREEN, UP), (bottom_split, RED, DOWN):
|
||||||
split.sort_submobjects(lambda p : p[0])
|
split.sort(lambda p : p[0])
|
||||||
split.generate_target()
|
split.generate_target()
|
||||||
split.target.shift(MED_LARGE_BUFF*vect)
|
split.target.shift(MED_LARGE_BUFF*vect)
|
||||||
for quiz in split.target:
|
for quiz in split.target:
|
||||||
|
|
@ -1175,7 +1175,7 @@ class ThousandPossibleQuizzes(Scene):
|
||||||
proportions = [0.9, 0.8, 0.8, 0.4]
|
proportions = [0.9, 0.8, 0.8, 0.4]
|
||||||
for split, prop in zip(all_splits, proportions):
|
for split, prop in zip(all_splits, proportions):
|
||||||
n = int(prop*len(split))
|
n = int(prop*len(split))
|
||||||
split.sort_submobjects(lambda p : -p[1])
|
split.sort(lambda p : -p[1])
|
||||||
split.generate_target()
|
split.generate_target()
|
||||||
top_part = VGroup(*split.target[:n])
|
top_part = VGroup(*split.target[:n])
|
||||||
top_part.shift(MED_SMALL_BUFF*UP)
|
top_part.shift(MED_SMALL_BUFF*UP)
|
||||||
|
|
@ -2111,7 +2111,7 @@ class CorrelationsWith35Percent(ThousandPossibleQuizzes):
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
self.quizzes = bottom_part
|
self.quizzes = bottom_part
|
||||||
self.quizzes.sort_submobjects(lambda p : p[0])
|
self.quizzes.sort(lambda p : p[0])
|
||||||
|
|
||||||
def show_second_split(self):
|
def show_second_split(self):
|
||||||
n = int(0.45*len(self.quizzes))
|
n = int(0.45*len(self.quizzes))
|
||||||
|
|
@ -2143,7 +2143,7 @@ class CorrelationsWith35Percent(ThousandPossibleQuizzes):
|
||||||
self.play(left_part.fade, 0.8)
|
self.play(left_part.fade, 0.8)
|
||||||
|
|
||||||
self.quizzes = right_part
|
self.quizzes = right_part
|
||||||
self.quizzes.sort_submobjects(lambda p : -p[1])
|
self.quizzes.sort(lambda p : -p[1])
|
||||||
|
|
||||||
def show_third_split(self):
|
def show_third_split(self):
|
||||||
quizzes = self.quizzes
|
quizzes = self.quizzes
|
||||||
|
|
|
||||||
|
|
@ -859,10 +859,6 @@ class Mobject(Container):
|
||||||
self.center()
|
self.center()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
# Just here to keep from breaking old scenes.
|
|
||||||
def arrange_submobjects(self, *args, **kwargs):
|
|
||||||
return self.arrange(*args, **kwargs)
|
|
||||||
|
|
||||||
def arrange_in_grid(self, n_rows=None, n_cols=None, **kwargs):
|
def arrange_in_grid(self, n_rows=None, n_cols=None, **kwargs):
|
||||||
submobs = self.submobjects
|
submobs = self.submobjects
|
||||||
if n_rows is None and n_cols is None:
|
if n_rows is None and n_cols is None:
|
||||||
|
|
@ -882,16 +878,16 @@ class Mobject(Container):
|
||||||
]).arrange(v2, **kwargs)
|
]).arrange(v2, **kwargs)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def sort_submobjects(self, point_to_num_func=lambda p: p[0]):
|
def sort(self, point_to_num_func=lambda p: p[0]):
|
||||||
self.submobjects.sort(
|
self.submobjects.sort(
|
||||||
key=lambda m: point_to_num_func(m.get_center())
|
key=lambda m: point_to_num_func(m.get_center())
|
||||||
)
|
)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def shuffle_submobjects(self, recursive=False):
|
def shuffle(self, recursive=False):
|
||||||
if recursive:
|
if recursive:
|
||||||
for submob in self.submobjects:
|
for submob in self.submobjects:
|
||||||
submob.shuffle_submobjects(recursive=True)
|
submob.shuffle(recursive=True)
|
||||||
random.shuffle(self.submobjects)
|
random.shuffle(self.submobjects)
|
||||||
|
|
||||||
def print_family(self, n_tabs=0):
|
def print_family(self, n_tabs=0):
|
||||||
|
|
@ -900,6 +896,16 @@ class Mobject(Container):
|
||||||
for submob in self.submobjects:
|
for submob in self.submobjects:
|
||||||
submob.print_family(n_tabs + 1)
|
submob.print_family(n_tabs + 1)
|
||||||
|
|
||||||
|
# Just here to keep from breaking old scenes.
|
||||||
|
def arrange_submobjects(self, *args, **kwargs):
|
||||||
|
return self.arrange(*args, **kwargs)
|
||||||
|
|
||||||
|
def sort_submobjects(self, *args, **kwargs):
|
||||||
|
return self.sort(*args, **kwargs)
|
||||||
|
|
||||||
|
def shuffle_submobjects(self, *args, **kwargs):
|
||||||
|
return self.shuffle(*args, **kwargs)
|
||||||
|
|
||||||
# Alignment
|
# Alignment
|
||||||
def align_data(self, mobject):
|
def align_data(self, mobject):
|
||||||
self.align_submobjects(mobject)
|
self.align_submobjects(mobject)
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ class Laptop(VGroup):
|
||||||
body.stretch(scale_factor, dim=dim)
|
body.stretch(scale_factor, dim=dim)
|
||||||
body.set_width(self.width)
|
body.set_width(self.width)
|
||||||
body.set_fill(self.shaded_body_color, opacity=1)
|
body.set_fill(self.shaded_body_color, opacity=1)
|
||||||
body.sort_submobjects(lambda p: p[2])
|
body.sort(lambda p: p[2])
|
||||||
body[-1].set_fill(self.body_color)
|
body[-1].set_fill(self.body_color)
|
||||||
screen_plate = body.copy()
|
screen_plate = body.copy()
|
||||||
keyboard = VGroup(*[
|
keyboard = VGroup(*[
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ class SingleStringTexMobject(SVGMobject):
|
||||||
return TexSymbol(path_string)
|
return TexSymbol(path_string)
|
||||||
|
|
||||||
def organize_submobjects_left_to_right(self):
|
def organize_submobjects_left_to_right(self):
|
||||||
self.sort_submobjects(lambda p: p[0])
|
self.sort(lambda p: p[0])
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -231,7 +231,7 @@ class TexMobject(SingleStringTexMobject):
|
||||||
part = self.get_part_by_tex(tex, **kwargs)
|
part = self.get_part_by_tex(tex, **kwargs)
|
||||||
return self.index_of_part(part)
|
return self.index_of_part(part)
|
||||||
|
|
||||||
def sort_submobjects_alphabetically(self):
|
def sort_alphabetically(self):
|
||||||
self.submobjects.sort(
|
self.submobjects.sort(
|
||||||
key=lambda m: m.get_tex_string()
|
key=lambda m: m.get_tex_string()
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -679,7 +679,7 @@ class StateOfBitcoin(TeacherStudentsScene):
|
||||||
third = TexMobject("1 \\over 3")
|
third = TexMobject("1 \\over 3")
|
||||||
third.next_to(kilo, LEFT)
|
third.next_to(kilo, LEFT)
|
||||||
kilogoogle = VGroup(*it.chain(third, kilo, google))
|
kilogoogle = VGroup(*it.chain(third, kilo, google))
|
||||||
kilogoogle.sort_submobjects()
|
kilogoogle.sort()
|
||||||
kilogoogle.next_to(rate, DOWN, MED_LARGE_BUFF)
|
kilogoogle.next_to(rate, DOWN, MED_LARGE_BUFF)
|
||||||
|
|
||||||
rate.save_state()
|
rate.save_state()
|
||||||
|
|
@ -818,7 +818,7 @@ class QAndA(PiCreatureScene):
|
||||||
dots.next_to(self.pi_creature, UP)
|
dots.next_to(self.pi_creature, UP)
|
||||||
dots = VGroup(*it.chain(*dots))
|
dots = VGroup(*it.chain(*dots))
|
||||||
top = dots.get_top()
|
top = dots.get_top()
|
||||||
dots.sort_submobjects(
|
dots.sort(
|
||||||
lambda p : get_norm(p-top)
|
lambda p : get_norm(p-top)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -597,7 +597,7 @@ class TransitionFromEquationSolverToZeroFinder(Introduce1DFunctionCase):
|
||||||
new_equation[2].match_style(equation[2])
|
new_equation[2].match_style(equation[2])
|
||||||
new_equation.move_to(equation, RIGHT)
|
new_equation.move_to(equation, RIGHT)
|
||||||
for tex in equation, new_equation:
|
for tex in equation, new_equation:
|
||||||
tex.sort_submobjects_alphabetically()
|
tex.sort_alphabetically()
|
||||||
|
|
||||||
self.play(ShowCreation(rect))
|
self.play(ShowCreation(rect))
|
||||||
self.play(FadeOut(rect))
|
self.play(FadeOut(rect))
|
||||||
|
|
@ -636,7 +636,7 @@ class RewriteEquationWithTeacher(AltTeacherStudentsScene):
|
||||||
TexMobject("x^2", "-", "2", "=", "0"),
|
TexMobject("x^2", "-", "2", "=", "0"),
|
||||||
)
|
)
|
||||||
for equation in root_two_equations:
|
for equation in root_two_equations:
|
||||||
equation.sort_submobjects_alphabetically()
|
equation.sort_alphabetically()
|
||||||
for part in equation.get_parts_by_tex("text"):
|
for part in equation.get_parts_by_tex("text"):
|
||||||
part[2:-1].set_color(YELLOW)
|
part[2:-1].set_color(YELLOW)
|
||||||
part[2:-1].scale(0.9)
|
part[2:-1].scale(0.9)
|
||||||
|
|
@ -1425,7 +1425,7 @@ class Rearrange2DEquation(AltTeacherStudentsScene):
|
||||||
for equation in equations:
|
for equation in equations:
|
||||||
equation.set_color_by_tex(g_tex, BLUE)
|
equation.set_color_by_tex(g_tex, BLUE)
|
||||||
equation.set_color_by_tex(h_tex, YELLOW)
|
equation.set_color_by_tex(h_tex, YELLOW)
|
||||||
equation.sort_submobjects_alphabetically()
|
equation.sort_alphabetically()
|
||||||
|
|
||||||
|
|
||||||
self.teacher_holds_up(equations[0])
|
self.teacher_holds_up(equations[0])
|
||||||
|
|
@ -2937,7 +2937,7 @@ class MentionQAndA(Scene):
|
||||||
"Sridhar" : YELLOW,
|
"Sridhar" : YELLOW,
|
||||||
})
|
})
|
||||||
patreon_logo = VGroup(*PatreonLogo().family_members_with_points())
|
patreon_logo = VGroup(*PatreonLogo().family_members_with_points())
|
||||||
patreon_logo.sort_submobjects()
|
patreon_logo.sort()
|
||||||
patreon_logo.replace(title.get_parts_by_tex("Patreon"))
|
patreon_logo.replace(title.get_parts_by_tex("Patreon"))
|
||||||
patreon_logo.scale(1.3, about_edge = LEFT)
|
patreon_logo.scale(1.3, about_edge = LEFT)
|
||||||
patreon_logo.shift(0.5*SMALL_BUFF*DOWN)
|
patreon_logo.shift(0.5*SMALL_BUFF*DOWN)
|
||||||
|
|
|
||||||
|
|
@ -3555,7 +3555,7 @@ class PrinciplesOverlay(PiCreatureScene):
|
||||||
mark.set_stroke(BLACK, 1)
|
mark.set_stroke(BLACK, 1)
|
||||||
q_marks.next_to(morty, UP)
|
q_marks.next_to(morty, UP)
|
||||||
q_marks.shift_onto_screen()
|
q_marks.shift_onto_screen()
|
||||||
q_marks.sort_submobjects(
|
q_marks.sort(
|
||||||
lambda p: get_norm(p - morty.get_top())
|
lambda p: get_norm(p - morty.get_top())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1582,12 +1582,12 @@ class VennDiagramProofByContradiction(Scene):
|
||||||
)
|
)
|
||||||
|
|
||||||
B_center = B.target.get_center()
|
B_center = B.target.get_center()
|
||||||
photons.sort_submobjects(
|
photons.sort(
|
||||||
lambda p : get_norm(p-B_center)
|
lambda p : get_norm(p-B_center)
|
||||||
)
|
)
|
||||||
in_B = VGroup(*photons[:85])
|
in_B = VGroup(*photons[:85])
|
||||||
out_of_B = VGroup(*photons[85:])
|
out_of_B = VGroup(*photons[85:])
|
||||||
out_of_B.sort_submobjects(lambda p : np.dot(p, 2*UP+LEFT))
|
out_of_B.sort(lambda p : np.dot(p, 2*UP+LEFT))
|
||||||
|
|
||||||
self.play(
|
self.play(
|
||||||
MoveToTarget(B),
|
MoveToTarget(B),
|
||||||
|
|
@ -1661,7 +1661,7 @@ class VennDiagramProofByContradiction(Scene):
|
||||||
DOWN+RIGHT, buff = SMALL_BUFF
|
DOWN+RIGHT, buff = SMALL_BUFF
|
||||||
)
|
)
|
||||||
|
|
||||||
in_B.sort_submobjects(
|
in_B.sort(
|
||||||
lambda p : get_norm(p - C_center)
|
lambda p : get_norm(p - C_center)
|
||||||
)
|
)
|
||||||
in_C = VGroup(*in_B[:-11])
|
in_C = VGroup(*in_B[:-11])
|
||||||
|
|
@ -1923,7 +1923,7 @@ class VennDiagramProofByContradiction(Scene):
|
||||||
|
|
||||||
def photons_jump_to_A_not_C_region(self):
|
def photons_jump_to_A_not_C_region(self):
|
||||||
in_C = self.in_C
|
in_C = self.in_C
|
||||||
in_C.sort_submobjects(lambda p : np.dot(p, DOWN+RIGHT))
|
in_C.sort(lambda p : np.dot(p, DOWN+RIGHT))
|
||||||
movers = VGroup(*self.in_C[:30])
|
movers = VGroup(*self.in_C[:30])
|
||||||
for mover in movers:
|
for mover in movers:
|
||||||
mover.generate_target()
|
mover.generate_target()
|
||||||
|
|
|
||||||
|
|
@ -719,7 +719,7 @@ class PointOutVSauce(CheckOutMathologer):
|
||||||
logo.to_corner(UP+LEFT)
|
logo.to_corner(UP+LEFT)
|
||||||
logo.set_stroke(width = 0)
|
logo.set_stroke(width = 0)
|
||||||
logo.set_fill(GREEN)
|
logo.set_fill(GREEN)
|
||||||
logo.sort_submobjects()
|
logo.sort()
|
||||||
return logo
|
return logo
|
||||||
|
|
||||||
def get_logo_intro_animation(self, logo):
|
def get_logo_intro_animation(self, logo):
|
||||||
|
|
@ -1569,7 +1569,7 @@ class MakeTwoJewelCaseContinuous(IntroduceStolenNecklaceProblem):
|
||||||
left_segment.parts[0],
|
left_segment.parts[0],
|
||||||
right_segment.parts[1],
|
right_segment.parts[1],
|
||||||
)
|
)
|
||||||
emerald_segments.sort_submobjects()
|
emerald_segments.sort()
|
||||||
|
|
||||||
self.play(v_lines.shift, segment_width*RIGHT/2)
|
self.play(v_lines.shift, segment_width*RIGHT/2)
|
||||||
self.play(*[
|
self.play(*[
|
||||||
|
|
@ -2158,7 +2158,7 @@ class TotalLengthOfEachJewelEquals(NecklaceDivisionSphereAssociation, ThreeDScen
|
||||||
|
|
||||||
def find_fair_division(self):
|
def find_fair_division(self):
|
||||||
segments, tick_marks = self.necklace
|
segments, tick_marks = self.necklace
|
||||||
segments.sort_submobjects()
|
segments.sort()
|
||||||
segment_colors = [
|
segment_colors = [
|
||||||
segment.get_color()
|
segment.get_color()
|
||||||
for segment in segments
|
for segment in segments
|
||||||
|
|
|
||||||
|
|
@ -4889,7 +4889,7 @@ class ShowBitcoinBlockSize(LedgerScene):
|
||||||
fill_opacity = 1,
|
fill_opacity = 1,
|
||||||
)
|
)
|
||||||
visa_logo[-1].set_color("#faa61a")
|
visa_logo[-1].set_color("#faa61a")
|
||||||
visa_logo.sort_submobjects()
|
visa_logo.sort()
|
||||||
avg_rate = TextMobject("Avg: $1{,}700$/second")
|
avg_rate = TextMobject("Avg: $1{,}700$/second")
|
||||||
max_rate = TextMobject("Max: $>24{,}000$/second")
|
max_rate = TextMobject("Max: $>24{,}000$/second")
|
||||||
rates = VGroup(avg_rate, max_rate)
|
rates = VGroup(avg_rate, max_rate)
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ class Introduction(MovingCameraScene):
|
||||||
stream_lines = StreamLines(
|
stream_lines = StreamLines(
|
||||||
div_func, **self.stream_lines_config
|
div_func, **self.stream_lines_config
|
||||||
)
|
)
|
||||||
stream_lines.shuffle_submobjects()
|
stream_lines.shuffle()
|
||||||
div_title = self.get_title("Divergence")
|
div_title = self.get_title("Divergence")
|
||||||
|
|
||||||
self.add(div_vector_field)
|
self.add(div_vector_field)
|
||||||
|
|
@ -507,7 +507,7 @@ class Introduction(MovingCameraScene):
|
||||||
stream_lines = StreamLines(
|
stream_lines = StreamLines(
|
||||||
curl_func, **self.stream_lines_config
|
curl_func, **self.stream_lines_config
|
||||||
)
|
)
|
||||||
stream_lines.shuffle_submobjects()
|
stream_lines.shuffle()
|
||||||
curl_title = self.get_title("Curl")
|
curl_title = self.get_title("Curl")
|
||||||
|
|
||||||
self.play(
|
self.play(
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ class SphereRings(SecondProof):
|
||||||
def flash_through_rings(self):
|
def flash_through_rings(self):
|
||||||
rings = self.north_rings.copy()
|
rings = self.north_rings.copy()
|
||||||
rings.fade(1)
|
rings.fade(1)
|
||||||
rings.sort_submobjects(lambda p: p[2])
|
rings.sort(lambda p: p[2])
|
||||||
|
|
||||||
for x in range(8):
|
for x in range(8):
|
||||||
self.play(LaggedStart(
|
self.play(LaggedStart(
|
||||||
|
|
|
||||||
|
|
@ -2929,7 +2929,7 @@ class WriteComplexExponentialExpression(DrawFrequencyPlot):
|
||||||
self.play(ghost_dot.move_to, ORIGIN)
|
self.play(ghost_dot.move_to, ORIGIN)
|
||||||
|
|
||||||
exp_expression[1].add(minus, f)
|
exp_expression[1].add(minus, f)
|
||||||
exp_expression[1].sort_submobjects(lambda p : p[0])
|
exp_expression[1].sort(lambda p : p[0])
|
||||||
|
|
||||||
self.set_variables_as_attrs(
|
self.set_variables_as_attrs(
|
||||||
ambient_ghost_dot_movement, ghost_dot,
|
ambient_ghost_dot_movement, ghost_dot,
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class LatticePointScene(Scene):
|
||||||
)
|
)
|
||||||
dot.r_squared = r_squared
|
dot.r_squared = r_squared
|
||||||
self.lattice_points.add(dot)
|
self.lattice_points.add(dot)
|
||||||
self.lattice_points.sort_submobjects(
|
self.lattice_points.sort(
|
||||||
lambda p : get_norm(p - self.plane_center)
|
lambda p : get_norm(p - self.plane_center)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ class LatticePointScene(Scene):
|
||||||
|
|
||||||
def get_lattice_points_on_r_squared_circle(self, r_squared):
|
def get_lattice_points_on_r_squared_circle(self, r_squared):
|
||||||
points = VGroup(*[dot for dot in self.lattice_points if dot.r_squared == r_squared])
|
points = VGroup(*[dot for dot in self.lattice_points if dot.r_squared == r_squared])
|
||||||
points.sort_submobjects(
|
points.sort(
|
||||||
lambda p : angle_of_vector(p-self.plane_center)%(2*np.pi)
|
lambda p : angle_of_vector(p-self.plane_center)%(2*np.pi)
|
||||||
)
|
)
|
||||||
return points
|
return points
|
||||||
|
|
@ -573,7 +573,7 @@ class Outline(PiCreatureScene):
|
||||||
for b in range(-10, 11)
|
for b in range(-10, 11)
|
||||||
if a**2 + b**2 <= 10**2
|
if a**2 + b**2 <= 10**2
|
||||||
])
|
])
|
||||||
lattice_points.sort_submobjects(
|
lattice_points.sort(
|
||||||
lambda p : get_norm(p - plane_center)
|
lambda p : get_norm(p - plane_center)
|
||||||
)
|
)
|
||||||
lattice_group = VGroup(plane, circle, lattice_points)
|
lattice_group = VGroup(plane, circle, lattice_points)
|
||||||
|
|
@ -4173,7 +4173,7 @@ class CountLatticePointsInBigCircle(LatticePointScene):
|
||||||
if (x**2 + y**2) > self.max_lattice_point_radius**2
|
if (x**2 + y**2) > self.max_lattice_point_radius**2
|
||||||
if (x**2 + y**2) < new_max**2
|
if (x**2 + y**2) < new_max**2
|
||||||
])
|
])
|
||||||
new_dots.sort_submobjects(get_norm)
|
new_dots.sort(get_norm)
|
||||||
|
|
||||||
self.play(*list(map(ShowCreation, [circle, arrow])))
|
self.play(*list(map(ShowCreation, [circle, arrow])))
|
||||||
self.play(*list(map(FadeOut, [circle, arrow])))
|
self.play(*list(map(FadeOut, [circle, arrow])))
|
||||||
|
|
|
||||||
|
|
@ -1017,7 +1017,7 @@ class FeynmanElementaryQuote(Scene):
|
||||||
self.add_foreground_mobjects(nothing)
|
self.add_foreground_mobjects(nothing)
|
||||||
self.play(ShowWord(nothing))
|
self.play(ShowWord(nothing))
|
||||||
self.wait(0.2)
|
self.wait(0.2)
|
||||||
nothing.sort_submobjects(lambda p: -p[0])
|
nothing.sort(lambda p: -p[0])
|
||||||
self.play(LaggedStart(
|
self.play(LaggedStart(
|
||||||
FadeOut, nothing,
|
FadeOut, nothing,
|
||||||
run_time=1
|
run_time=1
|
||||||
|
|
@ -2600,7 +2600,7 @@ class AngularMomentumArgument(KeplersSecondLaw):
|
||||||
get_force_field_func((sun_center, -1))
|
get_force_field_func((sun_center, -1))
|
||||||
)
|
)
|
||||||
vector_field.set_fill(opacity=0.8)
|
vector_field.set_fill(opacity=0.8)
|
||||||
vector_field.sort_submobjects(
|
vector_field.sort(
|
||||||
lambda p: -get_norm(p - sun_center)
|
lambda p: -get_norm(p - sun_center)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -4131,7 +4131,7 @@ class ShowSunVectorField(Scene):
|
||||||
get_force_field_func((sun_center, -1))
|
get_force_field_func((sun_center, -1))
|
||||||
)
|
)
|
||||||
vector_field.set_fill(opacity=0.8)
|
vector_field.set_fill(opacity=0.8)
|
||||||
vector_field.sort_submobjects(
|
vector_field.sort(
|
||||||
lambda p: -get_norm(p - sun_center)
|
lambda p: -get_norm(p - sun_center)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1880,7 +1880,7 @@ class EulersFormulaForGeneralPlanarGraph(LightUpNodes, ThreeDScene):
|
||||||
|
|
||||||
self.play(FadeOut(self.vertices))
|
self.play(FadeOut(self.vertices))
|
||||||
self.play(ReplacementTransform(regions, cube, run_time = 2))
|
self.play(ReplacementTransform(regions, cube, run_time = 2))
|
||||||
cube.sort_submobjects(lambda p : -p[2])
|
cube.sort(lambda p : -p[2])
|
||||||
self.add(ContinualRotation(cube, axis = UP, in_place = False))
|
self.add(ContinualRotation(cube, axis = UP, in_place = False))
|
||||||
self.wait(3)
|
self.wait(3)
|
||||||
self.play(
|
self.play(
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ class ExampleThrees(PiCreatureScene):
|
||||||
self.three_mobs = self.get_three_mobs()
|
self.three_mobs = self.get_three_mobs()
|
||||||
three_mob = self.three_mobs[0]
|
three_mob = self.three_mobs[0]
|
||||||
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(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(*[
|
||||||
|
|
@ -545,7 +545,7 @@ class WriteAProgram(Scene):
|
||||||
three_array = get_organized_images()[3][0]
|
three_array = get_organized_images()[3][0]
|
||||||
im_mob = ImageMobject(layer_to_image_array(three_array))
|
im_mob = ImageMobject(layer_to_image_array(three_array))
|
||||||
three = PixelsAsSquares(im_mob)
|
three = PixelsAsSquares(im_mob)
|
||||||
three.sort_submobjects(lambda p : np.dot(p, DOWN+RIGHT))
|
three.sort(lambda p : np.dot(p, DOWN+RIGHT))
|
||||||
three.set_height(6)
|
three.set_height(6)
|
||||||
three.next_to(ORIGIN, LEFT)
|
three.next_to(ORIGIN, LEFT)
|
||||||
three_rect = SurroundingRectangle(
|
three_rect = SurroundingRectangle(
|
||||||
|
|
|
||||||
|
|
@ -1914,7 +1914,7 @@ class OrganizeDataIntoMiniBatches(Scene):
|
||||||
|
|
||||||
def divide_into_minibatches(self):
|
def divide_into_minibatches(self):
|
||||||
examples = self.examples
|
examples = self.examples
|
||||||
examples.sort_submobjects(lambda p : -p[1])
|
examples.sort(lambda p : -p[1])
|
||||||
rows = Group(*[
|
rows = Group(*[
|
||||||
Group(*examples[i*self.n_cols:(i+1)*self.n_cols])
|
Group(*examples[i*self.n_cols:(i+1)*self.n_cols])
|
||||||
for i in range(self.n_rows)
|
for i in range(self.n_rows)
|
||||||
|
|
@ -1956,7 +1956,7 @@ class OrganizeDataIntoMiniBatches(Scene):
|
||||||
buff = SMALL_BUFF
|
buff = SMALL_BUFF
|
||||||
)
|
)
|
||||||
def indicate_row(row):
|
def indicate_row(row):
|
||||||
row.sort_submobjects(lambda p : p[0])
|
row.sort(lambda p : p[0])
|
||||||
return LaggedStart(
|
return LaggedStart(
|
||||||
ApplyFunction, row,
|
ApplyFunction, row,
|
||||||
lambda row : (
|
lambda row : (
|
||||||
|
|
|
||||||
|
|
@ -779,7 +779,7 @@ class EulerAnglesAndGimbal(ShowSeveralQuaternionRotations):
|
||||||
)
|
)
|
||||||
for u in [-1, 1]
|
for u in [-1, 1]
|
||||||
]))
|
]))
|
||||||
line.sort_submobjects(get_norm)
|
line.sort(get_norm)
|
||||||
line.set_shade_in_3d(True)
|
line.set_shade_in_3d(True)
|
||||||
line.set_stroke(YELLOW, 5)
|
line.set_stroke(YELLOW, 5)
|
||||||
line.center()
|
line.center()
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@ class RubiksCube(VGroup):
|
||||||
# return VGroup(square, back)
|
# return VGroup(square, back)
|
||||||
|
|
||||||
def get_face(self, vect):
|
def get_face(self, vect):
|
||||||
self.sort_submobjects(lambda p: np.dot(p, vect))
|
self.sort(lambda p: np.dot(p, vect))
|
||||||
return self[-(12 + 9):]
|
return self[-(12 + 9):]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1931,7 +1931,7 @@ class WalkThroughComplexMultiplication(ShowComplexMultiplicationExamples):
|
||||||
pair = VGroup(p1, p2)
|
pair = VGroup(p1, p2)
|
||||||
pair.scale(0.3)
|
pair.scale(0.3)
|
||||||
sparkly_plane.add(pair)
|
sparkly_plane.add(pair)
|
||||||
sparkly_plane.sort_submobjects(
|
sparkly_plane.sort(
|
||||||
lambda p: 0.1 * get_norm(p) + random.random()
|
lambda p: 0.1 * get_norm(p) + random.random()
|
||||||
)
|
)
|
||||||
sparkly_plane.set_color_by_gradient(YELLOW, RED, PINK, BLUE)
|
sparkly_plane.set_color_by_gradient(YELLOW, RED, PINK, BLUE)
|
||||||
|
|
|
||||||
|
|
@ -942,7 +942,7 @@ class ReframeOnLattice(PiCreatureScene):
|
||||||
for x in range(int(x_min), int(x_max)+1)
|
for x in range(int(x_min), int(x_max)+1)
|
||||||
for y in range(int(y_min), int(y_max)+1)
|
for y in range(int(y_min), int(y_max)+1)
|
||||||
])
|
])
|
||||||
result.sort_submobjects(lambda p : np.dot(p, UP+RIGHT))
|
result.sort(lambda p : np.dot(p, UP+RIGHT))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def create_pi_creature(self):
|
def create_pi_creature(self):
|
||||||
|
|
@ -1682,7 +1682,7 @@ class VisualizeZSquared(Scene):
|
||||||
for x in range(x_min, x_max+1)
|
for x in range(x_min, x_max+1)
|
||||||
for y in range(y_min, y_max+1)
|
for y in range(y_min, y_max+1)
|
||||||
])
|
])
|
||||||
dots.sort_submobjects(lambda p : np.dot(p, UP+RIGHT))
|
dots.sort(lambda p : np.dot(p, UP+RIGHT))
|
||||||
|
|
||||||
self.add_foreground_mobject(self.coordinate_labels)
|
self.add_foreground_mobject(self.coordinate_labels)
|
||||||
self.play(LaggedStart(
|
self.play(LaggedStart(
|
||||||
|
|
@ -1906,7 +1906,7 @@ class PointsWeMiss(VisualizeZSquared):
|
||||||
)
|
)
|
||||||
for z in z_list
|
for z in z_list
|
||||||
])
|
])
|
||||||
dots.sort_submobjects(get_norm)
|
dots.sort(get_norm)
|
||||||
self.add(dots)
|
self.add(dots)
|
||||||
self.dots = dots
|
self.dots = dots
|
||||||
|
|
||||||
|
|
@ -2423,7 +2423,7 @@ class ProjectPointsOntoUnitCircle(DrawRadialLines):
|
||||||
def project_all_dots(self):
|
def project_all_dots(self):
|
||||||
dots = self.dots
|
dots = self.dots
|
||||||
dots.add(*self.new_dots)
|
dots.add(*self.new_dots)
|
||||||
dots.sort_submobjects(
|
dots.sort(
|
||||||
lambda p : get_norm(p - self.plane_center)
|
lambda p : get_norm(p - self.plane_center)
|
||||||
)
|
)
|
||||||
unit_length = self.unit_circle.get_width()/2.0
|
unit_length = self.unit_circle.get_width()/2.0
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ class Diffusion(VMobject):
|
||||||
dots.arrange_in_grid(buff=SMALL_BUFF)
|
dots.arrange_in_grid(buff=SMALL_BUFF)
|
||||||
dots.center()
|
dots.center()
|
||||||
dots.set_height(self.height)
|
dots.set_height(self.height)
|
||||||
dots.sort_submobjects(lambda p: p[0])
|
dots.sort(lambda p: p[0])
|
||||||
dots[:len(dots) // 2].set_color(self.colors[0])
|
dots[:len(dots) // 2].set_color(self.colors[0])
|
||||||
dots[len(dots) // 2:].set_color(self.colors[1])
|
dots[len(dots) // 2:].set_color(self.colors[1])
|
||||||
dots.set_fill(opacity=0.8)
|
dots.set_fill(opacity=0.8)
|
||||||
|
|
|
||||||
|
|
@ -693,7 +693,7 @@ class IntroduceElectricField(PiCreatureScene):
|
||||||
)
|
)
|
||||||
VGroup(*shading_list).set_color_by_gradient(*self.vector_field_colors)
|
VGroup(*shading_list).set_color_by_gradient(*self.vector_field_colors)
|
||||||
result.set_fill(opacity = 0.75)
|
result.set_fill(opacity = 0.75)
|
||||||
result.sort_submobjects(get_norm)
|
result.sort(get_norm)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue