mirror of
https://github.com/3b1b/manim.git
synced 2025-07-30 05:24:22 +08:00
Bug fixes after last scene update + some renaming
This commit is contained in:
@ -126,11 +126,11 @@ class FadeOut(Transform):
|
||||
class FadeIn(Transform):
|
||||
def __init__(self, mobject, **kwargs):
|
||||
target = mobject.copy()
|
||||
mobject.fade(1)
|
||||
if isinstance(mobject, VMobject):
|
||||
mobject.set_stroke(width = 0)
|
||||
mobject.set_fill(opacity = 0)
|
||||
Transform.__init__(self, mobject, target, **kwargs)
|
||||
self.starting_mobject.fade(1)
|
||||
if isinstance(self.starting_mobject, VMobject):
|
||||
self.starting_mobject.set_stroke(width = 0)
|
||||
self.starting_mobject.set_fill(opacity = 0)
|
||||
|
||||
|
||||
class ShimmerIn(DelayByOrder):
|
||||
|
@ -179,17 +179,17 @@ class ShowNumericalDotProduct(Scene):
|
||||
v1 = Matrix(self.v1)
|
||||
v2 = Matrix(self.v2)
|
||||
inter_array_dot = TexMobject("\\cdot").scale(1.5)
|
||||
dot_product = Group(v1, inter_array_dot, v2)
|
||||
dot_product = VGroup(v1, inter_array_dot, v2)
|
||||
dot_product.arrange_submobjects(RIGHT, buff = MED_BUFF/2)
|
||||
dot_product.to_edge(LEFT)
|
||||
pairs = zip(v1.get_entries(), v2.get_entries())
|
||||
|
||||
for pair, color in zip(pairs, [X_COLOR, Y_COLOR, Z_COLOR, PINK]):
|
||||
Group(*pair).highlight(color)
|
||||
VGroup(*pair).highlight(color)
|
||||
|
||||
dot = TexMobject("\\cdot")
|
||||
products = Group(*[
|
||||
Group(
|
||||
products = VGroup(*[
|
||||
VGroup(
|
||||
p1.copy(), dot.copy(), p2.copy()
|
||||
).arrange_submobjects(RIGHT, buff = SMALL_BUFF)
|
||||
for p1, p2 in pairs
|
||||
@ -200,8 +200,8 @@ class ShowNumericalDotProduct(Scene):
|
||||
|
||||
products.target = products.copy()
|
||||
plusses = ["+"]*(len(self.v1)-1)
|
||||
symbols = Group(*map(TexMobject, ["="] + plusses))
|
||||
final_sum = Group(*it.chain(*zip(
|
||||
symbols = VGroup(*map(TexMobject, ["="] + plusses))
|
||||
final_sum = VGroup(*it.chain(*zip(
|
||||
symbols, products.target
|
||||
)))
|
||||
final_sum.arrange_submobjects(RIGHT, buff = SMALL_BUFF)
|
||||
@ -231,7 +231,7 @@ class ShowNumericalDotProduct(Scene):
|
||||
)
|
||||
self.dither()
|
||||
self.play(Transform(
|
||||
Group(*it.starmap(Group, pairs)).copy(),
|
||||
VGroup(*it.starmap(Group, pairs)).copy(),
|
||||
products,
|
||||
path_arc = -np.pi/2,
|
||||
run_time = 2
|
||||
@ -619,15 +619,15 @@ class SymmetricVAndW(VectorScene):
|
||||
v.proj.save_state()
|
||||
v.proj_line.save_state()
|
||||
self.play(Transform(*[
|
||||
Group(mob, mob.label)
|
||||
VGroup(mob, mob.label)
|
||||
for mob in v, new_v
|
||||
]), run_time = 2)
|
||||
last_mob = self.get_mobjects_from_last_animation()[0]
|
||||
self.remove(last_mob)
|
||||
self.add(*last_mob)
|
||||
Transform(
|
||||
Group(v.proj, v.proj_line),
|
||||
Group(new_v.proj, new_v.proj_line)
|
||||
VGroup(v.proj, v.proj_line),
|
||||
VGroup(new_v.proj, new_v.proj_line)
|
||||
).update(1)##Hacky
|
||||
|
||||
self.play(Write(words))
|
||||
@ -905,7 +905,7 @@ class AdditivityProperty(TwoDToOneDScene):
|
||||
if not self.sum_before:
|
||||
sum_vect = self.play_sum(v, w)
|
||||
symbols.target = symbols.copy().next_to(sum_vect, UP)
|
||||
Group(L, r_paren).highlight(BLACK)
|
||||
VGroup(L, r_paren).highlight(BLACK)
|
||||
self.play(Transform(symbols, symbols.target))
|
||||
self.dither()
|
||||
|
||||
@ -931,16 +931,16 @@ class AdditivityProperty(TwoDToOneDScene):
|
||||
tex_mob = TexMobject(
|
||||
"L(", v_tex, "+", w_tex, ")"
|
||||
)
|
||||
result = Group(
|
||||
result = VGroup(
|
||||
tex_mob[0],
|
||||
Group(*tex_mob[1:4]),
|
||||
VGroup(*tex_mob[1:4]),
|
||||
tex_mob[4]
|
||||
)
|
||||
else:
|
||||
tex_mob = TexMobject(
|
||||
"L(", v_tex, ")", "+", "L(", w_tex, ")"
|
||||
)
|
||||
result = Group(
|
||||
result = VGroup(
|
||||
VectorizedPoint(tex_mob.get_left()),
|
||||
tex_mob,
|
||||
VectorizedPoint(tex_mob.get_right()),
|
||||
@ -1304,12 +1304,12 @@ class AssociationBetweenMatricesAndVectors(Scene):
|
||||
vectors_words = TextMobject("2d vectors")
|
||||
vectors_words.highlight(YELLOW)
|
||||
arrow = DoubleArrow(LEFT, RIGHT, color = WHITE)
|
||||
Group(
|
||||
VGroup(
|
||||
matrices_words, arrow, vectors_words
|
||||
).arrange_submobjects(buff = MED_BUFF)
|
||||
|
||||
matrices = Group(*map(Matrix, self.matrices))
|
||||
vectors = Group(*map(Matrix, [m[0] for m in self.matrices]))
|
||||
matrices = VGroup(*map(Matrix, self.matrices))
|
||||
vectors = VGroup(*map(Matrix, [m[0] for m in self.matrices]))
|
||||
for m in list(matrices) + list(vectors):
|
||||
x, y = m.get_entries()
|
||||
x.highlight(X_COLOR)
|
||||
@ -1455,7 +1455,7 @@ class ProjectOntoUnitVectorNumberline(VectorScene):
|
||||
|
||||
number_line = NumberLine(x_min = -9, x_max = 9)
|
||||
numbers = number_line.get_numbers()
|
||||
Group(number_line, numbers).rotate(u_hat.get_angle())
|
||||
VGroup(number_line, numbers).rotate(u_hat.get_angle())
|
||||
if self.animate_setup:
|
||||
self.play(
|
||||
ShowCreation(number_line),
|
||||
@ -1519,7 +1519,7 @@ class ProjectOntoUnitVectorNumberline(VectorScene):
|
||||
y_vals = np.linspace(y_max, -y_max, num_vectors)
|
||||
if randomize:
|
||||
random.shuffle(y_vals)
|
||||
vectors = Group(*[
|
||||
vectors = VGroup(*[
|
||||
Vector(x*RIGHT + y*UP)
|
||||
for x, y in zip(x_vals, y_vals)
|
||||
])
|
||||
@ -1527,13 +1527,13 @@ class ProjectOntoUnitVectorNumberline(VectorScene):
|
||||
return vectors
|
||||
|
||||
def get_dots(self, vectors):
|
||||
return Group(*[
|
||||
return VGroup(*[
|
||||
Dot(v.get_end(), color = v.get_color(), radius = 0.075)
|
||||
for v in vectors
|
||||
])
|
||||
|
||||
def get_proj_dots(self, dots):
|
||||
return Group(*[
|
||||
return VGroup(*[
|
||||
dot.copy().move_to(get_projection(
|
||||
dot.get_center(), self.u_hat.get_end()
|
||||
))
|
||||
@ -1541,7 +1541,7 @@ class ProjectOntoUnitVectorNumberline(VectorScene):
|
||||
])
|
||||
|
||||
def get_proj_lines(self, dots, proj_dots):
|
||||
return Group(*[
|
||||
return VGroup(*[
|
||||
DashedLine(
|
||||
d1.get_center(), d2.get_center(),
|
||||
buff = 0, color = d1.get_color(),
|
||||
@ -1568,8 +1568,8 @@ class ProjectionFunctionSymbol(Scene):
|
||||
color = BLUE
|
||||
)
|
||||
|
||||
self.add(Group(*equation[:3]))
|
||||
self.play(Write(Group(*equation[3:])))
|
||||
self.add(VGroup(*equation[:3]))
|
||||
self.play(Write(VGroup(*equation[3:])))
|
||||
self.dither()
|
||||
self.play(Write(words), ShowCreation(arrow))
|
||||
self.dither()
|
||||
@ -1665,7 +1665,7 @@ class ProjectBasisVectors(ProjectOntoUnitVectorNumberline):
|
||||
proj_lines = self.get_proj_lines(dots, proj_dots)
|
||||
for dot in proj_dots:
|
||||
dot.scale_in_place(0.1)
|
||||
proj_basis = Group(*[
|
||||
proj_basis = VGroup(*[
|
||||
get_vect_mob_projection(vector, self.u_hat)
|
||||
for vector in basis_vectors
|
||||
])
|
||||
@ -1678,7 +1678,7 @@ class ProjectBasisVectors(ProjectOntoUnitVectorNumberline):
|
||||
question.highlight_by_tex(j_tex, Y_COLOR)
|
||||
question.add_background_rectangle()
|
||||
matrix = Matrix([["u_x", "u_y"]])
|
||||
Group(question, matrix).arrange_submobjects(DOWN).to_corner(
|
||||
VGroup(question, matrix).arrange_submobjects(DOWN).to_corner(
|
||||
UP+LEFT, buff = MED_BUFF/2
|
||||
)
|
||||
matrix_rect = BackgroundRectangle(matrix)
|
||||
@ -1748,7 +1748,7 @@ class ProjectBasisVectors(ProjectOntoUnitVectorNumberline):
|
||||
words.shift(LEFT)
|
||||
words.add_background_rectangle()
|
||||
angle = np.mean([vect.get_angle(), self.u_hat.get_angle()])
|
||||
Group(line, words).rotate(angle)
|
||||
VGroup(line, words).rotate(angle)
|
||||
|
||||
self.play(ShowCreation(line))
|
||||
if vect.get_end()[0] > 0.1:#is ihat
|
||||
@ -1832,7 +1832,7 @@ class GeneralTwoDOneDMatrixMultiplication(TwoDOneDMatrixMultiplication):
|
||||
}
|
||||
def construct(self):
|
||||
TwoDOneDMatrixMultiplication.construct(self)
|
||||
everything = Group(*self.get_mobjects())
|
||||
everything = VGroup(*self.get_mobjects())
|
||||
to_fade = filter(
|
||||
lambda m : isinstance(m, Brace) or isinstance(m, TextMobject),
|
||||
everything
|
||||
@ -1841,10 +1841,10 @@ class GeneralTwoDOneDMatrixMultiplication(TwoDOneDMatrixMultiplication):
|
||||
u = Matrix(self.matrix[0])
|
||||
v = Matrix(self.vector)
|
||||
self.color_matrix_and_vector(u, v)
|
||||
dot_product = Group(u, TexMobject("\\cdot"), v)
|
||||
dot_product = VGroup(u, TexMobject("\\cdot"), v)
|
||||
dot_product.arrange_submobjects()
|
||||
dot_product.shift(2*RIGHT+DOWN)
|
||||
words = Group(
|
||||
words = VGroup(
|
||||
TextMobject("Matrix-vector product"),
|
||||
TexMobject("\\Updownarrow"),
|
||||
TextMobject("Dot product")
|
||||
@ -1945,7 +1945,7 @@ class ScaleUpUHat(ProjectOntoUnitVectorNumberline) :
|
||||
words.highlight_by_tex("transformation", BLUE)
|
||||
words.add_background_rectangle()
|
||||
brace.put_at_tip(words)
|
||||
Group(matrix, brace, words).to_corner(UP+LEFT)
|
||||
VGroup(matrix, brace, words).to_corner(UP+LEFT)
|
||||
|
||||
self.play(Transform(
|
||||
self.u_hat.coords, matrix
|
||||
@ -2154,7 +2154,7 @@ class LooseDualityDescription(Scene):
|
||||
arrow = TexMobject("\\Leftrightarrow")
|
||||
words = TextMobject("Natural-but-surprising", "correspondence")
|
||||
words[1].gradient_highlight(BLUE, YELLOW)
|
||||
Group(duality, arrow, words).arrange_submobjects(buff = MED_BUFF)
|
||||
VGroup(duality, arrow, words).arrange_submobjects(buff = MED_BUFF)
|
||||
|
||||
self.add(duality)
|
||||
self.play(Write(arrow))
|
||||
@ -2189,7 +2189,7 @@ class TranslateToTheWorldOfTransformations(TwoDOneDMatrixMultiplication):
|
||||
matrix = Matrix([["x_1", "y_1"]])
|
||||
matrix.highlight_columns(X_COLOR, Y_COLOR)
|
||||
|
||||
dot_product = Group(v1, dot, v2)
|
||||
dot_product = VGroup(v1, dot, v2)
|
||||
dot_product.arrange_submobjects(RIGHT)
|
||||
matrix.next_to(v2, LEFT)
|
||||
|
||||
@ -2310,7 +2310,7 @@ class NextVideo(Scene):
|
||||
rect = Rectangle(width = 16, height = 9, color = BLUE)
|
||||
rect.scale_to_fit_height(6)
|
||||
rect.next_to(title, DOWN)
|
||||
Group(title, rect).show()
|
||||
VGroup(title, rect).show()
|
||||
|
||||
self.add(title)
|
||||
self.play(ShowCreation(rect))
|
||||
|
102
eola/chapter8.py
102
eola/chapter8.py
@ -89,7 +89,7 @@ class ListSteps(Scene):
|
||||
step_1 = TextMobject("This video: Standard introduction")
|
||||
step_2 = TextMobject("Next video: Deeper understanding with ", "linear transformations")
|
||||
step_2.highlight_by_tex("linear transformations", BLUE)
|
||||
steps = Group(step_1, step_2)
|
||||
steps = VGroup(step_1, step_2)
|
||||
steps.arrange_submobjects(DOWN, aligned_edge = LEFT, buff = LARGE_BUFF)
|
||||
steps.next_to(randy, UP)
|
||||
steps.to_edge(LEFT, buff = LARGE_BUFF)
|
||||
@ -178,7 +178,7 @@ class SimpleDefine2dCrossProduct(LinearTransformationScene):
|
||||
for vect in self.v, self.w:
|
||||
vect.label.target = vect.label.copy()
|
||||
vect.label.target.save_state()
|
||||
cross = Group(self.v.label.target, times, self.w.label.target)
|
||||
cross = VGroup(self.v.label.target, times, self.w.label.target)
|
||||
cross.arrange_submobjects(aligned_edge = DOWN)
|
||||
cross.scale(1.5)
|
||||
cross.shift(2.5*UP).to_edge(LEFT)
|
||||
@ -249,7 +249,7 @@ class SimpleDefine2dCrossProduct(LinearTransformationScene):
|
||||
word.get_top(), word.get_top() + 1.5*UP,
|
||||
color = word.get_color()
|
||||
)
|
||||
Group(word, word.arrow).next_to(
|
||||
VGroup(word, word.arrow).next_to(
|
||||
self.area_words, DOWN,
|
||||
aligned_edge = LEFT,
|
||||
buff = SMALL_BUFF
|
||||
@ -347,7 +347,7 @@ class CrossBasisVectors(LinearTransformationScene):
|
||||
self.dither()
|
||||
|
||||
times = TexMobject("\\times")
|
||||
cross = Group(i_label.target, times, j_label.target)
|
||||
cross = VGroup(i_label.target, times, j_label.target)
|
||||
cross.arrange_submobjects()
|
||||
cross.next_to(ORIGIN).shift(1.5*UP)
|
||||
cross_rect = BackgroundRectangle(cross)
|
||||
@ -470,22 +470,22 @@ class ContrastDotAndCross(Scene):
|
||||
for entry, color in zip(matrix.get_entries(), colors):
|
||||
entry.highlight(color)
|
||||
entry.target = entry.copy()
|
||||
syms = Group(*map(TexMobject, ["="] + ["+"]*(dim-1)))
|
||||
syms = VGroup(*map(TexMobject, ["="] + ["+"]*(dim-1)))
|
||||
def get_dot():
|
||||
dot = TexMobject("\\cdot")
|
||||
syms.add(dot)
|
||||
return dot
|
||||
result = Group(*it.chain(*zip(
|
||||
result = VGroup(*it.chain(*zip(
|
||||
syms,
|
||||
[
|
||||
Group(
|
||||
VGroup(
|
||||
e1.target, get_dot(), e2.target
|
||||
).arrange_submobjects()
|
||||
for e1, e2 in zip(m1.get_entries(), m2.get_entries())
|
||||
]
|
||||
)))
|
||||
result.arrange_submobjects(RIGHT)
|
||||
dot_prod = Group(
|
||||
dot_prod = VGroup(
|
||||
m1, TexMobject("\\cdot"), m2, result
|
||||
)
|
||||
dot_prod.arrange_submobjects(RIGHT)
|
||||
@ -525,11 +525,11 @@ class ContrastDotAndCross(Scene):
|
||||
for entry, color in zip(matrix.get_entries(), colors):
|
||||
entry.highlight(color)
|
||||
m1, m2 = matrices
|
||||
cross_product = Group(m1, TexMobject("\\times"), m2)
|
||||
cross_product = VGroup(m1, TexMobject("\\times"), m2)
|
||||
cross_product.arrange_submobjects()
|
||||
|
||||
index_to_cross_enty = {}
|
||||
syms = Group()
|
||||
syms = VGroup()
|
||||
movement_sets = []
|
||||
for a, b, c in it.permutations(range(3)):
|
||||
e1, e2 = m1.get_entries()[b], m2.get_entries()[c]
|
||||
@ -538,7 +538,7 @@ class ContrastDotAndCross(Scene):
|
||||
movement_sets.append([e1, e1.target, e2, e2.target])
|
||||
dot = TexMobject("\\cdot")
|
||||
syms.add(dot)
|
||||
cross_entry = Group(e1.target, dot, e2.target)
|
||||
cross_entry = VGroup(e1.target, dot, e2.target)
|
||||
cross_entry.arrange_submobjects()
|
||||
if a not in index_to_cross_enty:
|
||||
index_to_cross_enty[a] = []
|
||||
@ -551,12 +551,12 @@ class ContrastDotAndCross(Scene):
|
||||
prod2.arrange_submobjects(LEFT)
|
||||
minus = TexMobject("-")
|
||||
syms.add(minus)
|
||||
entry = Group(prod1, minus, prod2)
|
||||
entry = VGroup(prod1, minus, prod2)
|
||||
entry.arrange_submobjects(RIGHT)
|
||||
result_entries.append(entry)
|
||||
|
||||
result = Matrix(result_entries)
|
||||
full_cross_product = Group(
|
||||
full_cross_product = VGroup(
|
||||
cross_product, TexMobject("="), result
|
||||
)
|
||||
full_cross_product.arrange_submobjects()
|
||||
@ -600,7 +600,7 @@ class ContrastDotAndCross(Scene):
|
||||
for m in matrices:
|
||||
for e, color in zip(m.get_entries(), [X_COLOR, Y_COLOR]):
|
||||
e.highlight(color)
|
||||
cross_product = Group(m1, TexMobject("\\times"), m2)
|
||||
cross_product = VGroup(m1, TexMobject("\\times"), m2)
|
||||
cross_product.arrange_submobjects()
|
||||
(x1, x2), (x3, x4) = tuple(m1.get_entries()), tuple(m2.get_entries())
|
||||
entries = [x1, x2, x3, x4]
|
||||
@ -609,26 +609,26 @@ class ContrastDotAndCross(Scene):
|
||||
eq, dot1, minus, dot2 = syms = map(TexMobject,
|
||||
["=", "\\cdot", "-", "\\cdot"]
|
||||
)
|
||||
result = Group(
|
||||
result = VGroup(
|
||||
eq, x1.target, dot1, x4.target,
|
||||
minus, x3.target, dot2, x2.target,
|
||||
)
|
||||
result.arrange_submobjects(RIGHT)
|
||||
full_cross_product = Group(cross_product, result)
|
||||
full_cross_product = VGroup(cross_product, result)
|
||||
full_cross_product.arrange_submobjects(RIGHT)
|
||||
full_cross_product.next_to(h_line, DOWN, buff = MED_BUFF/2)
|
||||
|
||||
self.play(ShowCreation(h_line))
|
||||
self.play(Write(cross_product))
|
||||
self.play(
|
||||
Write(Group(*syms)),
|
||||
Write(VGroup(*syms)),
|
||||
*[
|
||||
Transform(entry.copy(), entry.target)
|
||||
for entry in entries
|
||||
]
|
||||
)
|
||||
self.dither()
|
||||
self.two_d_result = Group(*result[1:])
|
||||
self.two_d_result = VGroup(*result[1:])
|
||||
|
||||
def emphasize_output_type(self):
|
||||
three_d_brace = Brace(self.cross_result)
|
||||
@ -701,7 +701,7 @@ class Define2dCrossProduct(LinearTransformationScene):
|
||||
for mover in movers:
|
||||
mover.target = mover.copy()
|
||||
times = TexMobject("\\times")
|
||||
cross_product = Group(
|
||||
cross_product = VGroup(
|
||||
v.label.target, times, w.label.target
|
||||
)
|
||||
|
||||
@ -711,9 +711,9 @@ class Define2dCrossProduct(LinearTransformationScene):
|
||||
list(w.coords.target)
|
||||
]).T)
|
||||
det_text = get_det_text(matrix)
|
||||
full_det = Group(det_text, matrix)
|
||||
full_det = VGroup(det_text, matrix)
|
||||
equals = TexMobject("=")
|
||||
equation = Group(cross_product, equals, full_det)
|
||||
equation = VGroup(cross_product, equals, full_det)
|
||||
equation.arrange_submobjects()
|
||||
equation.to_corner(UP+LEFT)
|
||||
|
||||
@ -789,7 +789,7 @@ class Define2dCrossProduct(LinearTransformationScene):
|
||||
transform_words.add_background_rectangle()
|
||||
|
||||
col1, col2 = [
|
||||
Group(*matrix.get_mob_matrix()[i,:])
|
||||
VGroup(*matrix.get_mob_matrix()[i,:])
|
||||
for i in 0, 1
|
||||
]
|
||||
|
||||
@ -854,7 +854,7 @@ class Define2dCrossProduct(LinearTransformationScene):
|
||||
self.play(Write(self.det_text))
|
||||
self.matrix.add(self.det_text)
|
||||
|
||||
vect_stuffs = Group(*it.chain(*[
|
||||
vect_stuffs = VGroup(*it.chain(*[
|
||||
[m, m.label, m.coord_array]
|
||||
for m in self.v, self.w
|
||||
]))
|
||||
@ -897,7 +897,7 @@ class Define2dCrossProduct(LinearTransformationScene):
|
||||
)
|
||||
self.dither()
|
||||
|
||||
pm = Group(*map(TexMobject, ["+", "-"]))
|
||||
pm = VGroup(*map(TexMobject, ["+", "-"]))
|
||||
pm.gradient_highlight(GREEN, RED)
|
||||
pm.arrange_submobjects(DOWN, buff = SMALL_BUFF)
|
||||
pm.add_to_back(BackgroundRectangle(pm))
|
||||
@ -930,8 +930,8 @@ class Define2dCrossProduct(LinearTransformationScene):
|
||||
])
|
||||
self.square.target.apply_function(transform)
|
||||
|
||||
movers = Group(self.square, self.v, self.w)
|
||||
movers.target = Group(*[m.target for m in movers])
|
||||
movers = VGroup(self.square, self.v, self.w)
|
||||
movers.target = VGroup(*[m.target for m in movers])
|
||||
movers.save_state()
|
||||
self.remove(self.square)
|
||||
self.play(Transform(movers, movers.target))
|
||||
@ -1042,9 +1042,9 @@ class TwoDCrossProductExample(Define2dCrossProduct):
|
||||
cross_product.highlight_by_tex(v_tex, V_COLOR)
|
||||
cross_product.highlight_by_tex(w_tex, W_COLOR)
|
||||
cross_product.add_background_rectangle()
|
||||
equation_start = Group(
|
||||
equation_start = VGroup(
|
||||
cross_product,
|
||||
Group(matrix_background, det_text, matrix)
|
||||
VGroup(matrix_background, det_text, matrix)
|
||||
)
|
||||
equation_start.arrange_submobjects()
|
||||
equation_start.next_to(ORIGIN, DOWN).to_edge(LEFT)
|
||||
@ -1074,12 +1074,12 @@ class TwoDCrossProductExample(Define2dCrossProduct):
|
||||
for entry in entries:
|
||||
entry.target = entry.copy()
|
||||
det = np.linalg.det([self.v_coords, self.w_coords])
|
||||
equals, dot1, minus, dot2, equals_result = syms = Group(*map(
|
||||
equals, dot1, minus, dot2, equals_result = syms = VGroup(*map(
|
||||
TexMobject,
|
||||
["=", "\\cdot", "-", "\\cdot", "=%d"%det]
|
||||
))
|
||||
|
||||
equation_end = Group(
|
||||
equation_end = VGroup(
|
||||
equals, v1.target, dot1, w2.target,
|
||||
minus, w1.target, dot2, v2.target, equals_result
|
||||
)
|
||||
@ -1093,12 +1093,12 @@ class TwoDCrossProductExample(Define2dCrossProduct):
|
||||
self.play(
|
||||
Write(syms),
|
||||
Transform(
|
||||
Group(v1, w2).copy(), Group(v1.target, w2.target),
|
||||
VGroup(v1, w2).copy(), VGroup(v1.target, w2.target),
|
||||
rate_func = squish_rate_func(smooth, 0, 1./3),
|
||||
path_arc = np.pi/2
|
||||
),
|
||||
Transform(
|
||||
Group(v2, w1).copy(), Group(v2.target, w1.target),
|
||||
VGroup(v2, w1).copy(), VGroup(v2.target, w1.target),
|
||||
rate_func = squish_rate_func(smooth, 2./3, 1),
|
||||
path_arc = np.pi/2
|
||||
),
|
||||
@ -1165,7 +1165,7 @@ class BiggerWhenPerpendicular(LinearTransformationScene):
|
||||
smaller.scale(0.75)
|
||||
bigger.highlight(PINK)
|
||||
smaller.highlight(TEAL)
|
||||
group = Group(start_words, arrow, cross_is, bigger)
|
||||
group = VGroup(start_words, arrow, cross_is, bigger)
|
||||
group.arrange_submobjects()
|
||||
group.to_edge(UP)
|
||||
end_words.move_to(start_words, aligned_edge = RIGHT)
|
||||
@ -1234,7 +1234,7 @@ class ScalingRule(LinearTransformationScene):
|
||||
[self.v_coords, self.w_coords]
|
||||
)
|
||||
square.apply_function(transform)
|
||||
new_squares = Group(*[
|
||||
new_squares = VGroup(*[
|
||||
square.copy().shift(m*v.get_end())
|
||||
for m in range(3)
|
||||
])
|
||||
@ -1246,7 +1246,7 @@ class ScalingRule(LinearTransformationScene):
|
||||
for tex_mob in cross_product, rhs, three_v:
|
||||
tex_mob.highlight_by_tex(v_tex, V_COLOR)
|
||||
tex_mob.highlight_by_tex(w_tex, W_COLOR)
|
||||
equation = Group(cross_product, rhs)
|
||||
equation = VGroup(cross_product, rhs)
|
||||
equation.arrange_submobjects()
|
||||
equation.to_edge(UP)
|
||||
v_tex_mob = cross_product[0]
|
||||
@ -1327,7 +1327,7 @@ class WriteCrossProductProperties(Scene):
|
||||
length_words.highlight_by_tex(p_cash, P_COLOR)
|
||||
length_words.scale_to_fit_width(SPACE_WIDTH - 1)
|
||||
length_words.highlight_by_tex("(parallelogram's area)", BLUE)
|
||||
length_words.next_to(Group(cross_product, vector), DOWN, buff = LARGE_BUFF)
|
||||
length_words.next_to(VGroup(cross_product, vector), DOWN, buff = LARGE_BUFF)
|
||||
perpendicular = TextMobject(
|
||||
"\\centering Perpendicular to",
|
||||
v_cash, "and", w_cash
|
||||
@ -1409,7 +1409,7 @@ class ShowCrossProductFormula(Scene):
|
||||
for entry, color in zip(matrix.get_entries(), colors):
|
||||
entry.highlight(color)
|
||||
m1, m2 = matrices
|
||||
cross_product = Group(m1, TexMobject("\\times"), m2)
|
||||
cross_product = VGroup(m1, TexMobject("\\times"), m2)
|
||||
cross_product.arrange_submobjects()
|
||||
cross_product.shift(2*LEFT)
|
||||
|
||||
@ -1421,16 +1421,16 @@ class ShowCrossProductFormula(Scene):
|
||||
for e in e1, e2:
|
||||
e.target = e.copy()
|
||||
dot = TexMobject("\\cdot")
|
||||
syms = Group(dot)
|
||||
syms = VGroup(dot)
|
||||
|
||||
if sign < 0:
|
||||
minus = TexMobject("-")
|
||||
syms.add(minus)
|
||||
cross_entry = Group(minus, e2.target, dot, e1.target)
|
||||
cross_entry = VGroup(minus, e2.target, dot, e1.target)
|
||||
cross_entry.arrange_submobjects()
|
||||
entry_dicts[a]["negative"] = cross_entry
|
||||
else:
|
||||
cross_entry = Group(e1.target, dot, e2.target)
|
||||
cross_entry = VGroup(e1.target, dot, e2.target)
|
||||
cross_entry.arrange_submobjects()
|
||||
entry_dicts[a]["positive"] = cross_entry
|
||||
cross_entry.arrange_submobjects()
|
||||
@ -1441,7 +1441,7 @@ class ShowCrossProductFormula(Scene):
|
||||
])
|
||||
|
||||
result = Matrix([
|
||||
Group(
|
||||
VGroup(
|
||||
entry_dict["positive"],
|
||||
entry_dict["negative"],
|
||||
).arrange_submobjects()
|
||||
@ -1508,17 +1508,17 @@ class DeterminantTrick(Scene):
|
||||
##Really should fix Matrix mobject...
|
||||
j.shift(0.1*UP)
|
||||
k.shift(0.2*UP)
|
||||
Group(v2, w2).shift(0.1*DOWN)
|
||||
Group(v3, w3).shift(0.2*DOWN)
|
||||
VGroup(v2, w2).shift(0.1*DOWN)
|
||||
VGroup(v3, w3).shift(0.2*DOWN)
|
||||
##
|
||||
|
||||
for color, entry in zip(colors, col1):
|
||||
entry.highlight(color)
|
||||
det_text = get_det_text(matrix)
|
||||
equals = TexMobject("=")
|
||||
equation = Group(
|
||||
equation = VGroup(
|
||||
v, TexMobject("\\times"), w,
|
||||
equals, Group(det_text, matrix)
|
||||
equals, VGroup(det_text, matrix)
|
||||
)
|
||||
equation.arrange_submobjects()
|
||||
|
||||
@ -1583,8 +1583,8 @@ class DeterminantTrick(Scene):
|
||||
mob.save_state()
|
||||
basis = quint[0]
|
||||
basis.t.scale(1/0.8)
|
||||
lp, minus, rp = syms = Group(*map(TexMobject, "(-)"))
|
||||
term = Group(
|
||||
lp, minus, rp = syms = VGroup(*map(TexMobject, "(-)"))
|
||||
term = VGroup(
|
||||
basis.t, lp,
|
||||
quint[1].t, quint[2].t, minus,
|
||||
quint[3].t, quint[4].t, rp
|
||||
@ -1615,7 +1615,7 @@ class DeterminantTrick(Scene):
|
||||
run_time = 2
|
||||
)
|
||||
self.dither()
|
||||
paren_sets.append(Group(lp, rp))
|
||||
paren_sets.append(VGroup(lp, rp))
|
||||
self.dither()
|
||||
self.play(randy.change_mode, "pondering")
|
||||
for parens in paren_sets:
|
||||
@ -1695,11 +1695,11 @@ class CrossAndDualWords(Scene):
|
||||
)
|
||||
dot_with_cross.highlight_by_tex(v_tex, U_COLOR)
|
||||
dot_with_cross.highlight_by_tex(w_tex, W_COLOR)
|
||||
transform = Group(func, det_text)
|
||||
transform = VGroup(func, det_text)
|
||||
transform.arrange_submobjects()
|
||||
|
||||
Group(transform, dot_with_cross).scale(0.7)
|
||||
Group(vector_word, cross).arrange_submobjects(
|
||||
VGroup(transform, dot_with_cross).scale(0.7)
|
||||
VGroup(vector_word, cross).arrange_submobjects(
|
||||
RIGHT, buff = MED_BUFF
|
||||
).center().shift(LEFT).to_edge(UP)
|
||||
transform_word.next_to(vector_word, DOWN, buff = MED_BUFF, aligned_edge = LEFT)
|
||||
|
@ -77,7 +77,7 @@ class BruteForceVerification(Scene):
|
||||
v.highlight(V_COLOR)
|
||||
w.highlight(W_COLOR)
|
||||
def get_term(e1, e2, e3, e4):
|
||||
group = Group(
|
||||
group = VGroup(
|
||||
e1.copy(), e2.copy(),
|
||||
TexMobject("-"),
|
||||
e3.copy(), e4.copy(),
|
||||
@ -89,7 +89,7 @@ class BruteForceVerification(Scene):
|
||||
(v3, w1, v1, w3),
|
||||
(v2, w3, v3, w2),
|
||||
])))
|
||||
cross_product = Group(
|
||||
cross_product = VGroup(
|
||||
v.copy(), TexMobject("\\times"), w.copy(),
|
||||
TexMobject("="), cross.copy()
|
||||
)
|
||||
@ -221,12 +221,12 @@ class DotProductToTransformSymbol(Scene):
|
||||
_input.get_entries().gradient_highlight(X_COLOR, Y_COLOR)
|
||||
left_input, right_input = [_input.copy() for x in range(2)]
|
||||
dot, equals = map(TexMobject, ["\\cdot", "="])
|
||||
equation = Group(
|
||||
equation = VGroup(
|
||||
vector, dot, left_input, equals,
|
||||
matrix, right_input
|
||||
)
|
||||
equation.arrange_submobjects()
|
||||
left_brace = Brace(Group(vector, left_input))
|
||||
left_brace = Brace(VGroup(vector, left_input))
|
||||
right_brace = Brace(matrix, UP)
|
||||
left_words = left_brace.get_text("Dot product")
|
||||
right_words = right_brace.get_text("Transform")
|
||||
@ -332,7 +332,7 @@ class ThreeStepPlan(Scene):
|
||||
steps[0].highlight_by_tex(w_text, W_COLOR)
|
||||
steps[1][1].gradient_highlight(BLUE, YELLOW)
|
||||
steps[2].highlight_by_tex(cross_text, P_COLOR)
|
||||
Group(*steps).arrange_submobjects(
|
||||
VGroup(*steps).arrange_submobjects(
|
||||
DOWN, aligned_edge = LEFT, buff = LARGE_BUFF
|
||||
).next_to(h_line, DOWN, buff = MED_BUFF)
|
||||
|
||||
@ -355,7 +355,7 @@ class ThreeStepPlan(Scene):
|
||||
steps[0].remove(linear, transformation)
|
||||
self.play(
|
||||
Transform(
|
||||
Group(linear, transformation),
|
||||
VGroup(linear, transformation),
|
||||
linear_transformation
|
||||
),
|
||||
*map(FadeOut, steps)
|
||||
@ -375,8 +375,8 @@ class ThreeStepPlan(Scene):
|
||||
matrix.highlight_columns(X_COLOR, V_COLOR, W_COLOR)
|
||||
matrix.get_mob_matrix()[1, 0].highlight(Y_COLOR)
|
||||
matrix.get_mob_matrix()[2, 0].highlight(Z_COLOR)
|
||||
Group(*matrix.get_mob_matrix()[1, 1:]).shift(0.15*DOWN)
|
||||
Group(*matrix.get_mob_matrix()[2, 1:]).shift(0.35*DOWN)
|
||||
VGroup(*matrix.get_mob_matrix()[1, 1:]).shift(0.15*DOWN)
|
||||
VGroup(*matrix.get_mob_matrix()[2, 1:]).shift(0.35*DOWN)
|
||||
det_text = get_det_text(matrix)
|
||||
det_text.add(matrix)
|
||||
return det_text
|
||||
@ -408,13 +408,13 @@ class DefineDualTransform(Scene):
|
||||
Matrix(["%s_%d"%(s, d) for d in range(1, 4)])
|
||||
for s in "uvw"
|
||||
]
|
||||
defs_equals = Group()
|
||||
definitions = Group()
|
||||
defs_equals = VGroup()
|
||||
definitions = VGroup()
|
||||
for array, tex_mob, color in zip(arrays, tex_mobs, colors):
|
||||
array.highlight_columns(color)
|
||||
tex_mob.highlight(color)
|
||||
equals = TexMobject("=")
|
||||
definition = Group(tex_mob, equals, array)
|
||||
definition = VGroup(tex_mob, equals, array)
|
||||
definition.arrange_submobjects(RIGHT)
|
||||
definitions.add(definition)
|
||||
defs_equals.add(equals)
|
||||
@ -435,12 +435,12 @@ class DefineDualTransform(Scene):
|
||||
TexMobject(sym)
|
||||
for sym in "\\times", "\\times", "=",
|
||||
]
|
||||
triple_cross = Group(
|
||||
triple_cross = VGroup(
|
||||
u_tex.target, times1, v_tex.target, times2, w_tex.target, equals
|
||||
)
|
||||
triple_cross.arrange_submobjects()
|
||||
|
||||
final_mobs = Group(triple_cross, Group(det_text, matrix))
|
||||
final_mobs = VGroup(triple_cross, VGroup(det_text, matrix))
|
||||
final_mobs.arrange_submobjects()
|
||||
final_mobs.next_to(self.title, DOWN, buff = MED_BUFF)
|
||||
|
||||
@ -522,14 +522,14 @@ class DefineDualTransform(Scene):
|
||||
)
|
||||
func_tex.scale(0.7)
|
||||
func_input = Matrix(list("xyz"))
|
||||
func_input_template = Group(*func_tex[3:-2])
|
||||
func_input_template = VGroup(*func_tex[3:-2])
|
||||
func_input.scale_to_fit_height(func_input_template.get_height())
|
||||
func_input.next_to(Group(*func_tex[:3]), RIGHT)
|
||||
Group(*func_tex[-2:]).next_to(func_input, RIGHT)
|
||||
func_input.next_to(VGroup(*func_tex[:3]), RIGHT)
|
||||
VGroup(*func_tex[-2:]).next_to(func_input, RIGHT)
|
||||
func_tex[0].scale_in_place(1.5)
|
||||
|
||||
func_tex = Group(
|
||||
Group(*[func_tex[i] for i in 0, 1, 2, -2, -1]),
|
||||
func_tex = VGroup(
|
||||
VGroup(*[func_tex[i] for i in 0, 1, 2, -2, -1]),
|
||||
func_input
|
||||
)
|
||||
func_tex.next_to(self.equals, LEFT)
|
||||
@ -547,7 +547,7 @@ class DefineDualTransform(Scene):
|
||||
for mob in self.u_entries
|
||||
])
|
||||
self.play(*[
|
||||
Write(Group(vect_brace, vect_brace.tex))
|
||||
Write(VGroup(vect_brace, vect_brace.tex))
|
||||
for vect_brace in v_brace, w_brace
|
||||
])
|
||||
self.dither()
|
||||
@ -555,16 +555,16 @@ class DefineDualTransform(Scene):
|
||||
self.dither()
|
||||
|
||||
self.func_tex = func_tex
|
||||
self.variables_text = Group(brace, number_text)
|
||||
self.variables_text = VGroup(brace, number_text)
|
||||
|
||||
def introduce_dual_vector(self):
|
||||
everything = Group(*self.get_mobjects())
|
||||
everything = VGroup(*self.get_mobjects())
|
||||
colors = [X_COLOR, Y_COLOR, Z_COLOR]
|
||||
q_marks = Group(*map(TextMobject, "???"))
|
||||
q_marks = VGroup(*map(TextMobject, "???"))
|
||||
q_marks.scale(2)
|
||||
q_marks.gradient_highlight(*colors)
|
||||
|
||||
title = Group(TextMobject("This function is linear"))
|
||||
title = VGroup(TextMobject("This function is linear"))
|
||||
title.highlight(GREEN)
|
||||
title.to_edge(UP)
|
||||
matrix = Matrix([list(q_marks.copy())])
|
||||
@ -574,7 +574,7 @@ class DefineDualTransform(Scene):
|
||||
dual_vector.get_brackets()[0].shift(0.2*LEFT)
|
||||
dual_vector.get_entries().shift(0.1*LEFT)
|
||||
dual_vector.scale(1.25)
|
||||
dual_dot = Group(
|
||||
dual_dot = VGroup(
|
||||
dual_vector,
|
||||
TexMobject("\\cdot").next_to(dual_vector)
|
||||
)
|
||||
@ -623,7 +623,7 @@ class DefineDualTransform(Scene):
|
||||
)
|
||||
self.dither()
|
||||
|
||||
p_coords = Group(*map(TexMobject, [
|
||||
p_coords = VGroup(*map(TexMobject, [
|
||||
"p_%d"%d for d in range(1, 4)
|
||||
]))
|
||||
p_coords.highlight(RED)
|
||||
@ -654,15 +654,15 @@ class DefineDualTransform(Scene):
|
||||
self.input_array = func_input
|
||||
|
||||
def expand_dot_product(self):
|
||||
everything = Group(*self.get_mobjects())
|
||||
everything = VGroup(*self.get_mobjects())
|
||||
self.play(everything.to_edge, UP)
|
||||
self.remove(everything)
|
||||
self.add(*everything)
|
||||
to_fade = Group()
|
||||
to_fade = VGroup()
|
||||
|
||||
p_entries = self.p_array.get_entries()
|
||||
input_entries = self.input_array.get_entries()
|
||||
dot_components = Group()
|
||||
dot_components = VGroup()
|
||||
for p, x, i in zip(p_entries, input_entries, it.count()):
|
||||
if i == 2:
|
||||
x.sym = TexMobject("=")
|
||||
@ -671,7 +671,7 @@ class DefineDualTransform(Scene):
|
||||
p.sym = TexMobject("\\cdot")
|
||||
p.target = p.copy().scale(2)
|
||||
x.target = x.copy().scale(2)
|
||||
component = Group(p.target, p.sym, x.target, x.sym)
|
||||
component = VGroup(p.target, p.sym, x.target, x.sym)
|
||||
component.arrange_submobjects()
|
||||
dot_components.add(component)
|
||||
dot_components.arrange_submobjects()
|
||||
@ -680,7 +680,7 @@ class DefineDualTransform(Scene):
|
||||
dot_arrow = Arrow(self.p_array.get_corner(DOWN+RIGHT), dot_components)
|
||||
to_fade.add(dot_arrow)
|
||||
self.play(ShowCreation(dot_arrow))
|
||||
new_ps = Group()
|
||||
new_ps = VGroup()
|
||||
for p, x in zip(p_entries, input_entries):
|
||||
self.play(
|
||||
MoveToTarget(p.copy()),
|
||||
@ -696,7 +696,7 @@ class DefineDualTransform(Scene):
|
||||
x, y, z = self.u_entries
|
||||
v1, v2, v3 = self.v_entries
|
||||
w1, w2, w3 = self.w_entries
|
||||
cross_components = Group()
|
||||
cross_components = VGroup()
|
||||
quints = [
|
||||
(x, v2, w3, v3, w2),
|
||||
(y, v3, w1, v1, w3),
|
||||
@ -716,7 +716,7 @@ class DefineDualTransform(Scene):
|
||||
mob.target.scale(1.5)
|
||||
mob.sym = sym
|
||||
quint_targets = [mob.target for mob in quint]
|
||||
component = Group(*it.chain(*zip(quint_targets, syms)))
|
||||
component = VGroup(*it.chain(*zip(quint_targets, syms)))
|
||||
component.arrange_submobjects()
|
||||
cross_components.add(component)
|
||||
to_fade.add(syms[0], syms[-1], quint[0])
|
||||
@ -754,14 +754,14 @@ class DefineDualTransform(Scene):
|
||||
|
||||
everything = everything.copy()
|
||||
self.play(
|
||||
FadeOut(Group(*self.get_mobjects())),
|
||||
FadeOut(VGroup(*self.get_mobjects())),
|
||||
Animation(everything)
|
||||
)
|
||||
self.clear()
|
||||
self.add(everything)
|
||||
|
||||
def ask_question(self):
|
||||
everything = Group(*self.get_mobjects())
|
||||
everything = VGroup(*self.get_mobjects())
|
||||
p_tex = "$%s$"%get_vect_tex("p")
|
||||
question = TextMobject(
|
||||
"What vector",
|
||||
@ -828,11 +828,11 @@ class DotProductWords(Scene):
|
||||
p_mob.scale(1.5)
|
||||
p_mob.highlight(P_COLOR)
|
||||
input_array = Matrix(list("xyz"))
|
||||
dot_product = Group(p_mob, Dot(radius = 0.07), input_array)
|
||||
dot_product = VGroup(p_mob, Dot(radius = 0.07), input_array)
|
||||
dot_product.arrange_submobjects(buff = MED_BUFF/2)
|
||||
equals = TexMobject("=")
|
||||
dot_product.next_to(equals, LEFT)
|
||||
words = Group(*it.starmap(TextMobject, [
|
||||
words = VGroup(*it.starmap(TextMobject, [
|
||||
("(Length of projection)",),
|
||||
("(Length of ", p_tex, ")",)
|
||||
]))
|
||||
@ -842,7 +842,7 @@ class DotProductWords(Scene):
|
||||
words[1].next_to(words[0], DOWN, aligned_edge = LEFT)
|
||||
times.next_to(words[0], RIGHT)
|
||||
|
||||
everyone = Group(dot_product, equals, times, words)
|
||||
everyone = VGroup(dot_product, equals, times, words)
|
||||
everyone.center().scale_to_fit_width(SPACE_WIDTH - 1)
|
||||
self.add(dot_product)
|
||||
self.play(Write(equals))
|
||||
@ -864,7 +864,7 @@ class GeometricVolumeWords(Scene):
|
||||
for s in get_vect_tex(*"vw")
|
||||
]
|
||||
|
||||
words = Group(
|
||||
words = VGroup(
|
||||
TextMobject("(Area of", "parallelogram", ")$\\times$"),
|
||||
TextMobject(
|
||||
"(Component of $%s$"%matrix_to_tex_string(list("xyz")),
|
||||
|
@ -75,7 +75,7 @@ class LinearCombinationScene(LinearTransformationScene):
|
||||
)
|
||||
if coord_mobs is None:
|
||||
coord_mobs = map(TexMobject, map(str, numerical_coords))
|
||||
Group(*coord_mobs).set_fill(opacity = 0)
|
||||
VGroup(*coord_mobs).set_fill(opacity = 0)
|
||||
for coord, basis in zip(coord_mobs, basis_vectors):
|
||||
coord.next_to(basis.label, LEFT)
|
||||
for coord, basis in zip(coord_mobs, basis_vectors):
|
||||
@ -86,10 +86,10 @@ class LinearCombinationScene(LinearTransformationScene):
|
||||
coord, basis, basis.label
|
||||
]))
|
||||
self.dither()
|
||||
self.play(
|
||||
Group(*self.get_mobjects_from_last_animation()).shift,
|
||||
basis_vectors[0].get_end()
|
||||
)
|
||||
self.play(*[
|
||||
ApplyMethod(m.shift, basis_vectors[0].get_end())
|
||||
for m in self.get_mobjects_from_last_animation()
|
||||
])
|
||||
if show_sum_vect:
|
||||
sum_vect = Vector(
|
||||
basis_vectors[1].get_end(),
|
||||
@ -97,16 +97,12 @@ class LinearCombinationScene(LinearTransformationScene):
|
||||
)
|
||||
self.play(ShowCreation(sum_vect))
|
||||
self.dither(2)
|
||||
self.play(*[
|
||||
basis.restore for basis in basis_vectors
|
||||
]+[
|
||||
basis.label.restore for basis in basis_vectors
|
||||
]+[
|
||||
FadeOut(coord) for coord in coord_mobs
|
||||
]+[
|
||||
FadeOut(sum_vect) for x in [1] if show_sum_vect
|
||||
])
|
||||
|
||||
self.play(*it.chain(
|
||||
[basis.restore for basis in basis_vectors],
|
||||
[basis.label.restore for basis in basis_vectors],
|
||||
[FadeOut(coord) for coord in coord_mobs],
|
||||
[FadeOut(sum_vect) for x in [1] if show_sum_vect],
|
||||
))
|
||||
|
||||
|
||||
|
||||
@ -119,11 +115,12 @@ class RemindOfCoordinates(LinearCombinationScene):
|
||||
|
||||
v = self.add_vector(self.vector_coords, color = V_COLOR)
|
||||
coords = self.write_vector_coordinates(v)
|
||||
|
||||
self.show_standard_coord_meaning(*coords.get_entries().copy())
|
||||
self.show_abstract_scalar_idea(*coords.get_entries().copy())
|
||||
self.scale_basis_vectors(*coords.get_entries().copy())
|
||||
|
||||
|
||||
|
||||
def show_standard_coord_meaning(self, x_coord, y_coord):
|
||||
x, y = self.vector_coords
|
||||
x_line = Line(ORIGIN, x*RIGHT, color = GREEN)
|
||||
@ -145,31 +142,30 @@ class RemindOfCoordinates(LinearCombinationScene):
|
||||
to_save = x_coord, y_coord, self.i_hat, self.j_hat
|
||||
for mob in to_save:
|
||||
mob.save_state()
|
||||
everything = self.get_mobjects()
|
||||
everything = VGroup(*self.get_mobjects())
|
||||
|
||||
x, y = self.vector_coords
|
||||
scaled_i = self.i_hat.copy().scale(x)
|
||||
scaled_j = self.j_hat.copy().scale(y)
|
||||
Group(self.i_hat, scaled_i).shift(x_shift)
|
||||
Group(self.j_hat, scaled_j).shift(y_shift)
|
||||
|
||||
VGroup(self.i_hat, scaled_i).shift(x_shift)
|
||||
VGroup(self.j_hat, scaled_j).shift(y_shift)
|
||||
|
||||
self.play(
|
||||
*map(FadeOut, everything) + [
|
||||
FadeOut(everything),
|
||||
x_coord.scale_in_place, 1.5,
|
||||
x_coord.move_to, x_shift + 3*UP,
|
||||
y_coord.scale_in_place, 1.5,
|
||||
y_coord.move_to, y_shift + 3*UP,
|
||||
])
|
||||
)
|
||||
self.play(*map(FadeIn, [self.i_hat, self.j_hat]))
|
||||
self.dither()
|
||||
self.play(Transform(self.i_hat, scaled_i))
|
||||
self.play(Transform(self.j_hat, scaled_j))
|
||||
self.dither()
|
||||
self.play(*it.chain(
|
||||
map(FadeIn, everything),
|
||||
[mob.restore for mob in to_save]
|
||||
))
|
||||
self.play(
|
||||
FadeIn(everything),
|
||||
*[mob.restore for mob in to_save]
|
||||
)
|
||||
self.dither()
|
||||
|
||||
def scale_basis_vectors(self, x_coord, y_coord):
|
||||
|
@ -2,7 +2,7 @@ import numpy as np
|
||||
|
||||
from scene import Scene
|
||||
from mobject import Mobject
|
||||
from mobject.vectorized_mobject import VMobject, Group
|
||||
from mobject.vectorized_mobject import VMobject, VGroup
|
||||
from mobject.tex_mobject import TexMobject, TextMobject
|
||||
from animation import Animation
|
||||
from animation.transform import ApplyPointwiseFunction, Transform, \
|
||||
@ -75,7 +75,7 @@ class VectorScene(Scene):
|
||||
|
||||
def get_basis_vector_labels(self, **kwargs):
|
||||
i_hat, j_hat = self.get_basis_vectors()
|
||||
return Group(*[
|
||||
return VGroup(*[
|
||||
self.get_vector_label(
|
||||
vect, label, color = color,
|
||||
label_scale_factor = 1,
|
||||
|
@ -25,6 +25,8 @@ class Mobject(object):
|
||||
}
|
||||
def __init__(self, *submobjects, **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
if not all(map(lambda m : isinstance(m, Mobject), submobjects)):
|
||||
raise Exception("All submobjects must be of type Mobject")
|
||||
self.submobjects = list(submobjects)
|
||||
self.color = Color(self.color)
|
||||
if self.name is None:
|
||||
@ -627,7 +629,11 @@ class Mobject(object):
|
||||
|
||||
|
||||
|
||||
|
||||
class Group(Mobject):
|
||||
#Alternate name to improve readibility in cases where
|
||||
#the mobject is used primarily for its submobject housing
|
||||
#functionality.
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
@ -347,7 +347,7 @@ class VMobject(Mobject):
|
||||
self.set_points(points)
|
||||
return self
|
||||
|
||||
class Group(VMobject):
|
||||
class VGroup(VMobject):
|
||||
#Alternate name to improve readability during use
|
||||
pass
|
||||
|
||||
|
@ -59,9 +59,10 @@ class Scene(object):
|
||||
return self.camera.get_image()
|
||||
|
||||
def update_frame(self, mobjects = None, background = None, **kwargs):
|
||||
if "include_submobjects" not in kwargs:
|
||||
kwargs["include_submobjects"] = False
|
||||
if mobjects is None:
|
||||
mobjects = self.mobjects
|
||||
kwargs["include_submobjects"] = False
|
||||
if background is not None:
|
||||
self.camera.set_image(background)
|
||||
else:
|
||||
@ -75,27 +76,25 @@ class Scene(object):
|
||||
###
|
||||
|
||||
def extract_mobject_family_members(self, *mobjects):
|
||||
return list(it.chain(*[
|
||||
m.submobject_family()
|
||||
for m in mobjects
|
||||
]))
|
||||
return remove_list_redundancies(list(
|
||||
it.chain(*[
|
||||
m.submobject_family()
|
||||
for m in mobjects
|
||||
])
|
||||
))
|
||||
|
||||
def add(self, *mobjects_to_add):
|
||||
"""
|
||||
Mobjects will be displayed, from background to foreground,
|
||||
in the order with which they are entered.
|
||||
|
||||
Scene class keep track not just of the mobject directly added,
|
||||
Scene class keeps track not just of the mobject directly added,
|
||||
but also of every family member therein.
|
||||
"""
|
||||
if not all_elements_are_instances(mobjects_to_add, Mobject):
|
||||
raise Exception("Adding something which is not a mobject")
|
||||
mobjects_to_add = self.extract_mobject_family_members(*mobjects_to_add)
|
||||
old_mobjects = filter(
|
||||
lambda m : m not in mobjects_to_add,
|
||||
self.mobjects
|
||||
)
|
||||
self.mobjects = old_mobjects + mobjects_to_add
|
||||
self.mobjects = list_update(self.mobjects, mobjects_to_add)
|
||||
return self
|
||||
|
||||
def add_mobjects_among(self, values):
|
||||
@ -223,7 +222,7 @@ class Scene(object):
|
||||
|
||||
def play(self, *args, **kwargs):
|
||||
if len(args) == 0:
|
||||
raise Exception("Called Scene.play with no animations")
|
||||
warnings.warn("Called Scene.play with no animations")
|
||||
if self.skip_animations:
|
||||
kwargs["run_time"] = 0
|
||||
|
||||
@ -241,19 +240,16 @@ class Scene(object):
|
||||
animation.update(t / animation.run_time)
|
||||
self.update_frame(moving_mobjects, static_image)
|
||||
self.add_frames(self.get_frame())
|
||||
|
||||
self.add(*moving_mobjects)
|
||||
self.mobjects_from_last_animation = moving_mobjects
|
||||
self.clean_up_animations(*animations)
|
||||
return self
|
||||
|
||||
def clean_up_animations(self, *animations):
|
||||
self.mobjects_from_last_animation = []
|
||||
for animation in animations:
|
||||
animation.clean_up()
|
||||
if animation.is_remover():
|
||||
self.remove(animation.mobject)
|
||||
else:
|
||||
self.add(animation.mobject)
|
||||
self.mobjects_from_last_animation.append(animation.mobject)
|
||||
return self
|
||||
|
||||
def get_mobjects_from_last_animation(self):
|
||||
|
Reference in New Issue
Block a user