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