More chapter 5, plus some renaming fun

This commit is contained in:
Grant Sanderson
2016-08-02 15:50:32 -07:00
parent 6fe057c0f9
commit 4f42f62b3c
19 changed files with 162 additions and 102 deletions

View File

@ -893,7 +893,7 @@ class VectorAdditionNumerically(VectorScene):
var.highlight(X_COLOR) var.highlight(X_COLOR)
else: else:
var.highlight(Y_COLOR) var.highlight(Y_COLOR)
var.scale(VECTOR_LABEL_SCALE_VAL) var.scale(VECTOR_LABEL_SCALE_FACTOR)
var.move_to(starter) var.move_to(starter)
self.play( self.play(
Transform( Transform(
@ -1050,7 +1050,7 @@ class ScalingNumerically(VectorScene):
VMobject(x_sym, two_x_sym).highlight(X_COLOR) VMobject(x_sym, two_x_sym).highlight(X_COLOR)
VMobject(y_sym, two_y_sym).highlight(Y_COLOR) VMobject(y_sym, two_y_sym).highlight(Y_COLOR)
syms = [x_sym, y_sym, two_x_sym, two_y_sym] syms = [x_sym, y_sym, two_x_sym, two_y_sym]
VMobject(*syms).scale(VECTOR_LABEL_SCALE_VAL) VMobject(*syms).scale(VECTOR_LABEL_SCALE_FACTOR)
for sym, num in zip(syms, [x, y] + list(two_v_elems)): for sym, num in zip(syms, [x, y] + list(two_v_elems)):
sym.move_to(num) sym.move_to(num)
self.play( self.play(

View File

@ -134,13 +134,13 @@ class CoordinatesAsScalars(VectorScene):
i_hat_label = self.label_vector( i_hat_label = self.label_vector(
i_hat, "\\hat{\\imath}", i_hat, "\\hat{\\imath}",
color = X_COLOR, color = X_COLOR,
label_scale_val = 1 label_scale_factor = 1
) )
self.add_vector(j_hat) self.add_vector(j_hat)
j_hat_label = self.label_vector( j_hat_label = self.label_vector(
j_hat, "\\hat{\\jmath}", j_hat, "\\hat{\\jmath}",
color = Y_COLOR, color = Y_COLOR,
label_scale_val = 1 label_scale_factor = 1
) )
self.dither() self.dither()
@ -287,7 +287,7 @@ class ShowVaryingLinearCombinations(VectorScene):
"direction" : LEFT, "direction" : LEFT,
"buff" : 0.1 "buff" : 0.1
}, },
scale_val = 0.75, scale_factor = 0.75,
value_function = get_val_func(v) value_function = get_val_func(v)
) )
for v, label in (v1, v1_label), (v2, v2_label) for v, label in (v1, v1_label), (v2, v2_label)
@ -414,11 +414,11 @@ class ShowVaryingLinearCombinations(VectorScene):
sum_anims = self.get_sum_animations(v1, v2) sum_anims = self.get_sum_animations(v1, v2)
aux_anims = list(sum_anims) + label_anims + scalar_anims aux_anims = list(sum_anims) + label_anims + scalar_anims
scale_val = 2 scale_factor = 2
for w1, w2 in (v2, v1), (v1, v2): for w1, w2 in (v2, v1), (v1, v2):
w1_vect = w1.get_end()-w1.get_start() w1_vect = w1.get_end()-w1.get_start()
w2_vect = w2.get_end()-w2.get_start() w2_vect = w2.get_end()-w2.get_start()
for num in scale_val, -1, -1./scale_val: for num in scale_factor, -1, -1./scale_factor:
curr_tip = self.sum_vector.get_end() curr_tip = self.sum_vector.get_end()
line = Line(ORIGIN, curr_tip) line = Line(ORIGIN, curr_tip)
self.play( self.play(

View File

@ -588,13 +588,13 @@ class FollowIHatJHat(LinearTransformationScene):
i_label = self.label_vector( i_label = self.label_vector(
i_hat, "\\hat{\\imath}", i_hat, "\\hat{\\imath}",
color = X_COLOR, color = X_COLOR,
label_scale_val = 1 label_scale_factor = 1
) )
j_hat = self.add_vector([0, 1], color = Y_COLOR) j_hat = self.add_vector([0, 1], color = Y_COLOR)
j_label = self.label_vector( j_label = self.label_vector(
j_hat, "\\hat{\\jmath}", j_hat, "\\hat{\\jmath}",
color = Y_COLOR, color = Y_COLOR,
label_scale_val = 1 label_scale_factor = 1
) )
self.dither() self.dither()
@ -648,7 +648,7 @@ class TrackBasisVectorsExample(LinearTransformationScene):
def introduce_vector(self): def introduce_vector(self):
v = self.add_vector(self.v_coords) v = self.add_vector(self.v_coords)
coords = Matrix(self.v_coords) coords = Matrix(self.v_coords)
coords.scale(VECTOR_LABEL_SCALE_VAL) coords.scale(VECTOR_LABEL_SCALE_FACTOR)
coords.next_to(v.get_end(), np.sign(self.v_coords[0])*RIGHT) coords.next_to(v.get_end(), np.sign(self.v_coords[0])*RIGHT)
self.play(Write(coords, run_time = 1)) self.play(Write(coords, run_time = 1))

View File

@ -328,25 +328,84 @@ class BreakBlobIntoGridSquaresVeryGranular(BreakBlobIntoGridSquares):
class NameDeterminant(LinearTransformationScene): class NameDeterminant(LinearTransformationScene):
CONFIG = { CONFIG = {
"t_matrix" : [[1, 0], [2, 1]] "t_matrix" : [[3, 0], [2, 2]]
} }
def construct(self): def construct(self):
self.setup() self.setup()
self.add_unit_square() self.plane.fade(0.3)
self.add_title(["The", "``determinant''", "of a transformation"]) self.add_unit_square(color = YELLOW_E, opacity = 0.5)
self.add_title(
["The", "``determinant''", "of a transformation"],
scale_factor = 1
)
self.title.split()[1].split()[1].highlight(YELLOW) self.title.split()[1].split()[1].highlight(YELLOW)
text = TextMobject("Area $=1$") matrix_background, matrix, det_text = self.get_matrix()
text.move_to(self.square) self.add_foreground_mobject(matrix_background, matrix)
A = TexMobject("A")
area_label = VMobject(A.copy(), A.copy(), A)
area_label.move_to(self.square)
det = np.linalg.det(self.t_matrix) det = np.linalg.det(self.t_matrix)
self.add_moving_mobject(text, TextMobject("Area $=%d$"%det)) if np.round(det) == det:
self.show_frame() det = int(det)
area_label_target = VMobject(
TexMobject(str(det)), TexMobject("\\cdot"), A.copy()
)
if det < 1 and det > 0:
area_label_target.scale(det)
area_label_target.arrange_submobjects(RIGHT, buff = 0.1)
self.add_moving_mobject(area_label, area_label_target)
self.dither()
self.apply_transposed_matrix(self.t_matrix)
self.dither()
det_mob_copy = area_label.split()[0].copy()
new_det_mob = det_mob_copy.copy().scale_to_fit_height(
det_text.split()[0].get_height()
)
new_det_mob.next_to(det_text, RIGHT, buff = 0.2)
new_det_mob.add_background_rectangle()
det_mob_copy.add_background_rectangle(opacity = 0)
self.play(Write(det_text))
self.play(Transform(det_mob_copy, new_det_mob))
self.dither()
def get_matrix(self):
matrix = Matrix(np.array(self.t_matrix).transpose())
matrix.highlight_columns(X_COLOR, Y_COLOR)
matrix.next_to(self.title, DOWN, buff = 0.5)
matrix.shift(2*LEFT)
matrix_background = BackgroundRectangle(matrix)
braces = TexMobject("()")
braces.scale(2)
braces.stretch_to_fit_height(matrix.get_height())
l_brace, r_brace = braces.split()
l_brace.next_to(matrix, LEFT, buff = 0.1)
r_brace.next_to(matrix, RIGHT, buff = 0.1)
det = TextMobject("det").next_to(l_brace, LEFT, buff = 0.1)
det.add_background_rectangle()
eq = TexMobject("=").next_to(r_brace, RIGHT, buff = 0.1)
det_text = VMobject(det, l_brace, r_brace, eq)
return matrix_background, matrix, det_text
class DeterminantIsOneHalf(NameDeterminant):
CONFIG = {
"t_matrix" : [[0.5, -0.5], [0.5, 0.5]],
"foreground_plane_kwargs" : {
"x_radius" : 2*SPACE_WIDTH,
"y_radius" : 2*SPACE_WIDTH,
"secondary_line_ratio" : 0
},
}
class DeterminantIsZero(NameDeterminant):
CONFIG = {
"t_matrix" : [[2, 1], [2, 1]],
}

View File

@ -12,7 +12,7 @@ from topics.geometry import Vector, Line, Circle, Arrow, Dot, BackgroundRectangl
from helpers import * from helpers import *
VECTOR_LABEL_SCALE_VAL = 0.8 VECTOR_LABEL_SCALE_FACTOR = 0.8
def matrix_to_tex_string(matrix): def matrix_to_tex_string(matrix):
matrix = np.array(matrix).astype("string") matrix = np.array(matrix).astype("string")
@ -39,7 +39,7 @@ def vector_coordinate_label(vector_mob, integer_labels = True,
vect = vect[:n_dim] vect = vect[:n_dim]
vect = vect.reshape((n_dim, 1)) vect = vect.reshape((n_dim, 1))
label = Matrix(vect, add_background_rectangles = True) label = Matrix(vect, add_background_rectangles = True)
label.scale(VECTOR_LABEL_SCALE_VAL) label.scale(VECTOR_LABEL_SCALE_FACTOR)
shift_dir = np.array(vector_mob.get_end()) shift_dir = np.array(vector_mob.get_end())
if shift_dir[0] >= 0: #Pointing right if shift_dir[0] >= 0: #Pointing right

View File

@ -13,7 +13,7 @@ from topics.geometry import Vector, Line, Circle, Arrow, Dot, \
BackgroundRectangle, Square BackgroundRectangle, Square
from helpers import * from helpers import *
from eola.matrix import Matrix, VECTOR_LABEL_SCALE_VAL, vector_coordinate_label from eola.matrix import Matrix, VECTOR_LABEL_SCALE_FACTOR, vector_coordinate_label
X_COLOR = GREEN_C X_COLOR = GREEN_C
@ -78,7 +78,7 @@ class VectorScene(Scene):
return [ return [
self.get_vector_label( self.get_vector_label(
vect, label, color = color, vect, label, color = color,
label_scale_val = 1, label_scale_factor = 1,
**kwargs **kwargs
) )
for vect, label , color in [ for vect, label , color in [
@ -91,12 +91,13 @@ class VectorScene(Scene):
direction = "left", direction = "left",
rotate = False, rotate = False,
color = WHITE, color = WHITE,
label_scale_val = VECTOR_LABEL_SCALE_VAL): label_scale_factor = VECTOR_LABEL_SCALE_FACTOR):
if len(label) == 1: if not isinstance(label, TexMobject):
label = "\\vec{\\textbf{%s}}"%label if len(label) == 1:
label = TexMobject(label) label = "\\vec{\\textbf{%s}}"%label
label.highlight(color) label = TexMobject(label)
label.scale(label_scale_val) label.highlight(color)
label.scale(label_scale_factor)
label.add_background_rectangle() label.add_background_rectangle()
angle = vector.get_angle() angle = vector.get_angle()
@ -346,9 +347,9 @@ class LinearTransformationScene(VectorScene):
self.transformable_labels.append(label_mob) self.transformable_labels.append(label_mob)
return label_mob return label_mob
def add_title(self, title, scale_val = 1.5, animate = False): def add_title(self, title, scale_factor = 1.5, animate = False):
if not isinstance(title, Mobject): if not isinstance(title, Mobject):
title = TextMobject(title).scale(scale_val) title = TextMobject(title).scale(scale_factor)
title.to_edge(UP) title.to_edge(UP)
title.add_background_rectangle() title.add_background_rectangle()
if animate: if animate:

View File

@ -17,7 +17,7 @@ class ImageMobject(PMobject):
"invert" : True, "invert" : True,
"use_cache" : True, "use_cache" : True,
"stroke_width" : 1, "stroke_width" : 1,
"scale_value" : 1.0, "scale_factorue" : 1.0,
"should_center" : True, "should_center" : True,
} }
def __init__(self, image_file, **kwargs): def __init__(self, image_file, **kwargs):
@ -36,7 +36,7 @@ class ImageMobject(PMobject):
for path in possible_paths: for path in possible_paths:
if os.path.exists(path): if os.path.exists(path):
self.generate_points_from_file(path) self.generate_points_from_file(path)
self.scale(self.scale_value) self.scale(self.scale_factorue)
if self.should_center: if self.should_center:
self.center() self.center()
return return

View File

@ -7,7 +7,7 @@ from helpers import *
class SVGMobject(VMobject): class SVGMobject(VMobject):
CONFIG = { CONFIG = {
"initial_scale_val" : 1, "initial_scale_factor" : 1,
"should_center" : True, "should_center" : True,
} }
def __init__(self, svg_file, **kwargs): def __init__(self, svg_file, **kwargs):
@ -129,7 +129,7 @@ class SVGMobject(VMobject):
def move_into_position(self): def move_into_position(self):
if self.should_center: if self.should_center:
self.center() self.center()
self.scale_in_place(self.initial_scale_val) self.scale_in_place(self.initial_scale_factor)

View File

@ -4,8 +4,8 @@ from topics.geometry import BackgroundRectangle
from helpers import * from helpers import *
import collections import collections
TEX_MOB_SCALE_VAL = 0.05 TEX_MOB_SCALE_FACTOR = 0.05
TEXT_MOB_SCALE_VAL = 0.05 TEXT_MOB_SCALE_FACTOR = 0.05
class TexSymbol(VMobjectFromSVGPathstring): class TexSymbol(VMobjectFromSVGPathstring):
@ -35,7 +35,7 @@ class TexMobject(SVGMobject):
"should_center" : True, "should_center" : True,
"separate_list_arg_with_spaces" : True, "separate_list_arg_with_spaces" : True,
"enforce_new_line_structure" : False, "enforce_new_line_structure" : False,
"initial_scale_val" : TEX_MOB_SCALE_VAL, "initial_scale_factor" : TEX_MOB_SCALE_FACTOR,
"organize_left_to_right" : False, "organize_left_to_right" : False,
"propogate_style_to_family" : True, "propogate_style_to_family" : True,
} }
@ -103,7 +103,7 @@ class TexMobject(SVGMobject):
) )
def add_background_rectangle(self, color = BLACK, opacity = 0.75): def add_background_rectangle(self, color = BLACK, opacity = 0.75):
rect = BackgroundRectangle(self) rect = BackgroundRectangle(self, color = color, opacity = opacity)
letters = VMobject(*self.submobjects) letters = VMobject(*self.submobjects)
self.submobjects = [rect, letters] self.submobjects = [rect, letters]
return self return self
@ -111,7 +111,7 @@ class TexMobject(SVGMobject):
class TextMobject(TexMobject): class TextMobject(TexMobject):
CONFIG = { CONFIG = {
"template_tex_file" : TEMPLATE_TEXT_FILE, "template_tex_file" : TEMPLATE_TEXT_FILE,
"initial_scale_val" : TEXT_MOB_SCALE_VAL, "initial_scale_factor" : TEXT_MOB_SCALE_FACTOR,
"enforce_new_line_structure" : True, "enforce_new_line_structure" : True,
} }

View File

@ -20,7 +20,7 @@ from topics.number_line import *
from mobject.region import Region, region_from_polygon_vertices from mobject.region import Region, region_from_polygon_vertices
from scene import Scene from scene import Scene
RANDY_SCALE_VAL = 0.3 RANDY_SCALE_FACTOR = 0.3
@ -239,7 +239,7 @@ class TryManyPaths(PathSlidingScene):
randy = Randolph() randy = Randolph()
randy.shift(-randy.get_bottom()) randy.shift(-randy.get_bottom())
self.slider = randy.copy() self.slider = randy.copy()
randy.scale(RANDY_SCALE_VAL) randy.scale(RANDY_SCALE_FACTOR)
paths = self.get_paths() paths = self.get_paths()
point_a = Dot(paths[0].points[0]) point_a = Dot(paths[0].points[0])
point_b = Dot(paths[0].points[-1]) point_b = Dot(paths[0].points[-1])
@ -317,7 +317,7 @@ class TryManyPaths(PathSlidingScene):
class RollingRandolph(PathSlidingScene): class RollingRandolph(PathSlidingScene):
def construct(self): def construct(self):
randy = Randolph() randy = Randolph()
randy.scale(RANDY_SCALE_VAL) randy.scale(RANDY_SCALE_FACTOR)
randy.shift(-randy.get_bottom()) randy.shift(-randy.get_bottom())
self.add_cycloid_end_points() self.add_cycloid_end_points()
self.slide(randy, self.cycloid, roll = True) self.slide(randy, self.cycloid, roll = True)
@ -334,7 +334,7 @@ class NotTheCircle(PathSlidingScene):
path.gradient_highlight(RED_D, WHITE) path.gradient_highlight(RED_D, WHITE)
radius = Line(ORIGIN, path.points[0]) radius = Line(ORIGIN, path.points[0])
randy = Randolph() randy = Randolph()
randy.scale(RANDY_SCALE_VAL) randy.scale(RANDY_SCALE_FACTOR)
randy.shift(-randy.get_bottom()) randy.shift(-randy.get_bottom())
randy_copy = randy.copy() randy_copy = randy.copy()
words = TextMobject("Circular paths are good, \\\\ but still not the best") words = TextMobject("Circular paths are good, \\\\ but still not the best")
@ -367,7 +367,7 @@ class NotTheCircle(PathSlidingScene):
class TransitionAwayFromSlide(PathSlidingScene): class TransitionAwayFromSlide(PathSlidingScene):
def construct(self): def construct(self):
randy = Randolph() randy = Randolph()
randy.scale(RANDY_SCALE_VAL) randy.scale(RANDY_SCALE_FACTOR)
randy.shift(-randy.get_bottom()) randy.shift(-randy.get_bottom())
self.add_cycloid_end_points() self.add_cycloid_end_points()
arrow = Arrow(ORIGIN, 2*RIGHT) arrow = Arrow(ORIGIN, 2*RIGHT)
@ -469,7 +469,7 @@ class WhatGovernsSpeed(PathSlidingScene):
} }
def construct(self): def construct(self):
randy = Randolph() randy = Randolph()
randy.scale(RANDY_SCALE_VAL) randy.scale(RANDY_SCALE_FACTOR)
randy.shift(-randy.get_bottom()) randy.shift(-randy.get_bottom())
self.add_cycloid_end_points() self.add_cycloid_end_points()
points = self.cycloid.points points = self.cycloid.points
@ -652,7 +652,7 @@ class DefineCurveWithKnob(PathSlidingScene):
self.path.highlight(BLACK) self.path.highlight(BLACK)
randy = Randolph() randy = Randolph()
randy.scale(RANDY_SCALE_VAL) randy.scale(RANDY_SCALE_FACTOR)
randy.shift(-randy.get_bottom()) randy.shift(-randy.get_bottom())
self.play(ShimmerIn(words)) self.play(ShimmerIn(words))

View File

@ -536,7 +536,7 @@ class SlidingObject(CycloidScene, PathSlidingScene):
CycloidScene.construct(self) CycloidScene.construct(self)
randy = Randolph() randy = Randolph()
randy.scale(RANDY_SCALE_VAL) randy.scale(RANDY_SCALE_FACTOR)
randy.shift(-randy.get_bottom()) randy.shift(-randy.get_bottom())
central_randy = randy.copy() central_randy = randy.copy()
start_randy = self.adjust_mobject_to_index( start_randy = self.adjust_mobject_to_index(

View File

@ -22,7 +22,7 @@ from scene import Scene
from scene.zoomed_scene import ZoomedScene from scene.zoomed_scene import ZoomedScene
from brachistochrone.curves import \ from brachistochrone.curves import \
Cycloid, PathSlidingScene, RANDY_SCALE_VAL, TryManyPaths Cycloid, PathSlidingScene, RANDY_SCALE_FACTOR, TryManyPaths
class Lens(Arc): class Lens(Arc):
@ -846,7 +846,7 @@ class SpringSetup(ShowMultiplePathsInWater):
class WhatGovernsTheSpeedOfLight(PhotonScene, PathSlidingScene): class WhatGovernsTheSpeedOfLight(PhotonScene, PathSlidingScene):
def construct(self): def construct(self):
randy = Randolph() randy = Randolph()
randy.scale(RANDY_SCALE_VAL) randy.scale(RANDY_SCALE_FACTOR)
randy.shift(-randy.get_bottom()) randy.shift(-randy.get_bottom())
self.add_cycloid_end_points() self.add_cycloid_end_points()

View File

@ -337,7 +337,7 @@ class ShowLightAndSlidingObject(MultilayeredScene, TryManyPaths, PhotonScene):
path.rgbs[:,2] = 0 path.rgbs[:,2] = 0
loop = paths.pop(1) ##Bad! loop = paths.pop(1) ##Bad!
randy = Randolph() randy = Randolph()
randy.scale(RANDY_SCALE_VAL) randy.scale(RANDY_SCALE_FACTOR)
randy.shift(-randy.get_bottom()) randy.shift(-randy.get_bottom())
photon_run = self.photon_run_along_path( photon_run = self.photon_run_along_path(
loop, loop,

View File

@ -17,8 +17,8 @@ from moser_main import EulersFormula
from script_wrapper import command_line_create_scene from script_wrapper import command_line_create_scene
MOVIE_PREFIX = "ecf_graph_scenes/" MOVIE_PREFIX = "ecf_graph_scenes/"
RANDOLPH_SCALE_VAL = 0.3 RANDOLPH_SCALE_FACTOR = 0.3
EDGE_ANNOTATION_SCALE_VAL = 0.7 EDGE_ANNOTATION_SCALE_FACTOR = 0.7
DUAL_CYCLE = [3, 4, 5, 6, 1, 0, 2, 3] DUAL_CYCLE = [3, 4, 5, 6, 1, 0, 2, 3]
class EulersFormulaWords(Scene): class EulersFormulaWords(Scene):
@ -162,7 +162,7 @@ class OldIntroduceGraphs(GraphScene):
self.clear() self.clear()
self.add(*self.edges) self.add(*self.edges)
self.replace_vertices_with(Face().scale(0.4)) self.replace_vertices_with(Face().scale(0.4))
friends = TextMobject("Friends").scale(EDGE_ANNOTATION_SCALE_VAL) friends = TextMobject("Friends").scale(EDGE_ANNOTATION_SCALE_FACTOR)
self.annotate_edges(friends.shift((0, friends.get_height()/2, 0))) self.annotate_edges(friends.shift((0, friends.get_height()/2, 0)))
self.play(*[ self.play(*[
CounterclockwiseTransform(vertex, Dot(point)) CounterclockwiseTransform(vertex, Dot(point))
@ -282,11 +282,11 @@ class ThreePiecesOfTerminology(GraphScene):
] ]
] ]
self.generate_spanning_tree() self.generate_spanning_tree()
scale_val = 1.2 scale_factor = 1.2
def accent(mobject, color = "yellow"): def accent(mobject, color = "yellow"):
return mobject.scale_in_place(scale_val).highlight(color) return mobject.scale_in_place(scale_factor).highlight(color)
def tone_down(mobject): def tone_down(mobject):
return mobject.scale_in_place(1.0/scale_val).highlight("white") return mobject.scale_in_place(1.0/scale_factor).highlight("white")
self.add(accent(cycles)) self.add(accent(cycles))
self.trace_cycle(run_time = 1.0) self.trace_cycle(run_time = 1.0)
@ -332,7 +332,7 @@ class WalkingRandolph(GraphScene):
GraphScene.construct(self) GraphScene.construct(self)
point_path = [self.points[i] for i in self.path] point_path = [self.points[i] for i in self.path]
randy = Randolph() randy = Randolph()
randy.scale(RANDOLPH_SCALE_VAL) randy.scale(RANDOLPH_SCALE_FACTOR)
randy.move_to(point_path[0]) randy.move_to(point_path[0])
for next, last in zip(point_path[1:], point_path): for next, last in zip(point_path[1:], point_path):
self.play( self.play(
@ -416,7 +416,7 @@ class IntroduceRandolph(GraphScene):
name = TextMobject("Randolph") name = TextMobject("Randolph")
self.play(Transform( self.play(Transform(
randy, randy,
deepcopy(randy).scale(RANDOLPH_SCALE_VAL).move_to(self.points[0]), deepcopy(randy).scale(RANDOLPH_SCALE_FACTOR).move_to(self.points[0]),
)) ))
self.dither() self.dither()
name.shift((0, 1, 0)) name.shift((0, 1, 0))
@ -427,15 +427,15 @@ class DefineSpanningTree(GraphScene):
def construct(self): def construct(self):
GraphScene.construct(self) GraphScene.construct(self)
randy = Randolph() randy = Randolph()
randy.scale(RANDOLPH_SCALE_VAL).move_to(self.points[0]) randy.scale(RANDOLPH_SCALE_FACTOR).move_to(self.points[0])
dollar_signs = TextMobject("\\$\\$") dollar_signs = TextMobject("\\$\\$")
dollar_signs.scale(EDGE_ANNOTATION_SCALE_VAL) dollar_signs.scale(EDGE_ANNOTATION_SCALE_FACTOR)
dollar_signs = Mobject(*[ dollar_signs = Mobject(*[
deepcopy(dollar_signs).shift(edge.get_center()) deepcopy(dollar_signs).shift(edge.get_center())
for edge in self.edges for edge in self.edges
]) ])
unneeded = TextMobject("unneeded!") unneeded = TextMobject("unneeded!")
unneeded.scale(EDGE_ANNOTATION_SCALE_VAL) unneeded.scale(EDGE_ANNOTATION_SCALE_FACTOR)
self.generate_spanning_tree() self.generate_spanning_tree()
def green_dot_at_index(index): def green_dot_at_index(index):
return Dot( return Dot(
@ -546,7 +546,7 @@ class FacebookGraph(GraphScene):
account.shift(0.2*LEFT + 0.1*UP) account.shift(0.2*LEFT + 0.1*UP)
friends = TexMobject( friends = TexMobject(
"\\leftarrow \\text{friends} \\rightarrow" "\\leftarrow \\text{friends} \\rightarrow"
).scale(0.5*EDGE_ANNOTATION_SCALE_VAL) ).scale(0.5*EDGE_ANNOTATION_SCALE_FACTOR)
self.clear() self.clear()
accounts = [ accounts = [
@ -873,7 +873,7 @@ class CyclesCorrespondWithConnectedComponents(GraphScene):
dual_cycle = DUAL_CYCLE dual_cycle = DUAL_CYCLE
enclosed_vertices = [0, 1] enclosed_vertices = [0, 1]
randy = Randolph() randy = Randolph()
randy.scale(RANDOLPH_SCALE_VAL) randy.scale(RANDOLPH_SCALE_FACTOR)
randy.move_to(self.points[cycle[0]]) randy.move_to(self.points[cycle[0]])
lines_to_remove = [] lines_to_remove = []
@ -933,8 +933,8 @@ class IntroduceMortimer(GraphScene):
self.add(morty, name) self.add(morty, name)
self.dither() self.dither()
self.remove(name) self.remove(name)
small_randy = deepcopy(randy).scale(RANDOLPH_SCALE_VAL) small_randy = deepcopy(randy).scale(RANDOLPH_SCALE_FACTOR)
small_morty = deepcopy(morty).scale(RANDOLPH_SCALE_VAL) small_morty = deepcopy(morty).scale(RANDOLPH_SCALE_FACTOR)
small_randy.move_to(self.points[randy_path[0]]) small_randy.move_to(self.points[randy_path[0]])
small_morty.move_to(self.dual_points[morty_path[0]]) small_morty.move_to(self.dual_points[morty_path[0]])
self.play(*[ self.play(*[
@ -978,8 +978,8 @@ class RandolphMortimerSpanningTreeGame(GraphScene):
self.generate_spanning_tree() self.generate_spanning_tree()
self.generate_dual_graph() self.generate_dual_graph()
self.generate_regions() self.generate_regions()
randy = Randolph().scale(RANDOLPH_SCALE_VAL) randy = Randolph().scale(RANDOLPH_SCALE_FACTOR)
morty = Mortimer().scale(RANDOLPH_SCALE_VAL) morty = Mortimer().scale(RANDOLPH_SCALE_FACTOR)
randy.move_to(self.points[0]) randy.move_to(self.points[0])
morty.move_to(self.dual_points[0]) morty.move_to(self.dual_points[0])
attempted_dual_point_index = 2 attempted_dual_point_index = 2
@ -1028,7 +1028,7 @@ class MortimerCannotTraverseCycle(GraphScene):
self.generate_dual_graph() self.generate_dual_graph()
dual_cycle = DUAL_CYCLE dual_cycle = DUAL_CYCLE
trapped_points = [0, 1] trapped_points = [0, 1]
morty = Mortimer().scale(RANDOLPH_SCALE_VAL) morty = Mortimer().scale(RANDOLPH_SCALE_FACTOR)
morty.move_to(self.dual_points[dual_cycle[0]]) morty.move_to(self.dual_points[dual_cycle[0]])
time_per_edge = 0.5 time_per_edge = 0.5
text = TextMobject(""" text = TextMobject("""
@ -1105,10 +1105,10 @@ class DualSpanningTree(GraphScene):
self.generate_dual_graph() self.generate_dual_graph()
self.generate_spanning_tree() self.generate_spanning_tree()
randy = Randolph() randy = Randolph()
randy.scale(RANDOLPH_SCALE_VAL) randy.scale(RANDOLPH_SCALE_FACTOR)
randy.move_to(self.points[0]) randy.move_to(self.points[0])
morty = Mortimer() morty = Mortimer()
morty.scale(RANDOLPH_SCALE_VAL) morty.scale(RANDOLPH_SCALE_FACTOR)
morty.move_to(self.dual_points[0]) morty.move_to(self.dual_points[0])
dual_edges = [1, 3, 4, 7, 11, 9, 13] dual_edges = [1, 3, 4, 7, 11, 9, 13]
words = TextMobject(""" words = TextMobject("""

View File

@ -806,26 +806,26 @@ class ZoomInOnOne(Scene):
) )
num_levels = 3 num_levels = 3
scale_val = 10 scale_factor = 10
number_lines = [ number_lines = [
NumberLine( NumberLine(
interval_size = 1, interval_size = 1,
density = scale_val*DEFAULT_POINT_DENSITY_1D density = scale_factor*DEFAULT_POINT_DENSITY_1D
).filter_out( ).filter_out(
lambda (x, y, z):abs(y)>0.1 lambda (x, y, z):abs(y)>0.1
).scale(1.0/scale_val**x) ).scale(1.0/scale_factor**x)
for x in range(num_levels) for x in range(num_levels)
] ]
kwargs = {"rate_func" : None} kwargs = {"rate_func" : None}
self.play(*[ self.play(*[
ApplyMethod(number_lines[x].scale, scale_val, **kwargs) ApplyMethod(number_lines[x].scale, scale_factor, **kwargs)
for x in range(1, num_levels) for x in range(1, num_levels)
]+[ ]+[
ApplyMethod(number_lines[0].stretch, scale_val, 0, **kwargs), ApplyMethod(number_lines[0].stretch, scale_factor, 0, **kwargs),
]+[ ]+[
ApplyMethod( ApplyMethod(
all_numbers[i].shift, all_numbers[i].shift,
2*LEFT*(scale_val-1)*(-1)**i, 2*LEFT*(scale_factor-1)*(-1)**i,
**kwargs **kwargs
) )
for i in 0, 1 for i in 0, 1

View File

@ -97,7 +97,7 @@ class Piano(ImageMobject):
CONFIG = { CONFIG = {
"stroke_width" : 1, "stroke_width" : 1,
"invert" : False, "invert" : False,
"scale_value" : 0.5 "scale_factorue" : 0.5
} }
def __init__(self, **kwargs): def __init__(self, **kwargs):
digest_config(self, kwargs) digest_config(self, kwargs)
@ -1213,25 +1213,25 @@ class StepsToSolution(IntervalScene):
def add_terms(self): def add_terms(self):
self.ones = [] self.ones = []
scale_val = 0.6 scale_factor = 0.6
plus = None plus = None
for count in range(1, 10): for count in range(1, 10):
frac_bottom = TexMobject("\\over %d"%(2**count)) frac_bottom = TexMobject("\\over %d"%(2**count))
frac_bottom.scale(scale_val) frac_bottom.scale(scale_factor)
one = TexMobject("1").scale(scale_val) one = TexMobject("1").scale(scale_factor)
one.next_to(frac_bottom, UP, buff = 0.1) one.next_to(frac_bottom, UP, buff = 0.1)
compound = Mobject(frac_bottom, one) compound = Mobject(frac_bottom, one)
if plus: if plus:
compound.next_to(plus) compound.next_to(plus)
else: else:
compound.to_edge(LEFT) compound.to_edge(LEFT)
plus = TexMobject("+").scale(scale_val) plus = TexMobject("+").scale(scale_factor)
plus.next_to(compound) plus.next_to(compound)
frac_bottom, one = compound.split() frac_bottom, one = compound.split()
self.ones.append(one) self.ones.append(one)
self.add(frac_bottom, one, plus) self.add(frac_bottom, one, plus)
self.dither(0.2) self.dither(0.2)
dots = TexMobject("\\dots").scale(scale_val).next_to(plus) dots = TexMobject("\\dots").scale(scale_factor).next_to(plus)
arrow = Arrow(ORIGIN, RIGHT).next_to(dots) arrow = Arrow(ORIGIN, RIGHT).next_to(dots)
one = TexMobject("1").next_to(arrow) one = TexMobject("1").next_to(arrow)
self.ones.append(one) self.ones.append(one)

View File

@ -13,7 +13,7 @@ A_COLOR = BLUE
B_COLOR = MAROON_D B_COLOR = MAROON_D
C_COLOR = YELLOW C_COLOR = YELLOW
TEX_MOB_SCALE_VAL = 0.5 TEX_MOB_SCALE_FACTOR = 0.5
POINTS = np.array([ POINTS = np.array([
DOWN, DOWN,
2*UP, 2*UP,
@ -47,7 +47,7 @@ class Triangle(Polygon):
return self return self
def add_letter(self, char, nudge = 0.3): def add_letter(self, char, nudge = 0.3):
mob = TexMobject(char).scale(TEX_MOB_SCALE_VAL) mob = TexMobject(char).scale(TEX_MOB_SCALE_FACTOR)
if char == "a": if char == "a":
points = self.get_vertices()[[0, 2, 1]] points = self.get_vertices()[[0, 2, 1]]
elif char == "b": elif char == "b":
@ -89,7 +89,7 @@ def c_square(**kwargs):
class DrawPointsReference(Scene): class DrawPointsReference(Scene):
def construct(self): def construct(self):
for point, count in zip(POINTS, it.count()): for point, count in zip(POINTS, it.count()):
mob = TexMobject(str(count)).scale(TEX_MOB_SCALE_VAL) mob = TexMobject(str(count)).scale(TEX_MOB_SCALE_FACTOR)
mob.shift(POINTS[count]) mob.shift(POINTS[count])
self.add(mob) self.add(mob)
@ -104,7 +104,7 @@ class DrawAllThreeSquares(Scene):
c = c_square() c = c_square()
self.add(Triangle(), a, b, c) self.add(Triangle(), a, b, c)
for letter, mob in zip("abc", [a, b, c]): for letter, mob in zip("abc", [a, b, c]):
char_mob = TexMobject(letter+"^2").scale(TEX_MOB_SCALE_VAL) char_mob = TexMobject(letter+"^2").scale(TEX_MOB_SCALE_FACTOR)
char_mob.shift(mob.get_center()) char_mob.shift(mob.get_center())
self.add(char_mob) self.add(char_mob)
@ -235,8 +235,8 @@ class ShowBigRectangleDimensions(DrawAllThreeSquaresWithMoreTriangles):
for brace in u_brace, side_brace: for brace in u_brace, side_brace:
brace.shift(0.2*DOWN) brace.shift(0.2*DOWN)
side_brace.rotate(-np.pi/2) side_brace.rotate(-np.pi/2)
a_plus_2b = TexMobject("a+2b").scale(TEX_MOB_SCALE_VAL) a_plus_2b = TexMobject("a+2b").scale(TEX_MOB_SCALE_FACTOR)
b_plus_2a = TexMobject("b+2a").scale(TEX_MOB_SCALE_VAL) b_plus_2a = TexMobject("b+2a").scale(TEX_MOB_SCALE_FACTOR)
a_plus_2b.next_to(u_brace, DOWN) a_plus_2b.next_to(u_brace, DOWN)
b_plus_2a.next_to(side_brace, LEFT) b_plus_2a.next_to(side_brace, LEFT)
self.add_mobjects_among(locals().values()) self.add_mobjects_among(locals().values())
@ -263,7 +263,7 @@ class DrawOnlyABSquares(Scene):
a = a_square() a = a_square()
b = b_square() b = b_square()
for char, mob in zip("ab", [a, b]): for char, mob in zip("ab", [a, b]):
symobl = TexMobject(char+"^2").scale(TEX_MOB_SCALE_VAL) symobl = TexMobject(char+"^2").scale(TEX_MOB_SCALE_FACTOR)
symobl.shift(mob.get_center()) symobl.shift(mob.get_center())
self.add(symobl) self.add(symobl)
triangle = Triangle() triangle = Triangle()
@ -394,8 +394,8 @@ class ZoomInOnTroublePoint(Scene):
for mob in self.mobjects: for mob in self.mobjects:
mob.rotate(np.pi/2) mob.rotate(np.pi/2)
if with_labels: if with_labels:
alpha = TexMobject("\\alpha").scale(TEX_MOB_SCALE_VAL) alpha = TexMobject("\\alpha").scale(TEX_MOB_SCALE_FACTOR)
beta = TexMobject("90-\\alpha").scale(TEX_MOB_SCALE_VAL) beta = TexMobject("90-\\alpha").scale(TEX_MOB_SCALE_FACTOR)
if rotate: if rotate:
alpha.next_to(angle1_arc, UP+0.1*LEFT) alpha.next_to(angle1_arc, UP+0.1*LEFT)
beta.next_to(angle2_arc, DOWN+0.5*LEFT) beta.next_to(angle2_arc, DOWN+0.5*LEFT)
@ -446,7 +446,7 @@ class LabelLargeSquare(DrawCSquareWithAllTraingles):
u_brace.shift(0.2*DOWN) u_brace.shift(0.2*DOWN)
side_brace = deepcopy(u_brace).rotate(np.pi/2) side_brace = deepcopy(u_brace).rotate(np.pi/2)
upper_brace = deepcopy(u_brace).rotate(np.pi) upper_brace = deepcopy(u_brace).rotate(np.pi)
a_plus_b = TexMobject("a+b").scale(TEX_MOB_SCALE_VAL) a_plus_b = TexMobject("a+b").scale(TEX_MOB_SCALE_FACTOR)
upper_brace.add(a_plus_b.next_to(upper_brace, UP)) upper_brace.add(a_plus_b.next_to(upper_brace, UP))
side_brace.add(a_plus_b.next_to(side_brace, RIGHT)) side_brace.add(a_plus_b.next_to(side_brace, RIGHT))
self.add(upper_brace, side_brace) self.add(upper_brace, side_brace)

View File

@ -11,7 +11,7 @@ from scene import Scene
PI_CREATURE_DIR = os.path.join(IMAGE_DIR, "PiCreature") PI_CREATURE_DIR = os.path.join(IMAGE_DIR, "PiCreature")
PI_CREATURE_SCALE_VAL = 0.5 PI_CREATURE_SCALE_FACTOR = 0.5
MOUTH_INDEX = 5 MOUTH_INDEX = 5
BODY_INDEX = 4 BODY_INDEX = 4
@ -26,7 +26,7 @@ class PiCreature(SVGMobject):
"color" : BLUE_E, "color" : BLUE_E,
"stroke_width" : 0, "stroke_width" : 0,
"fill_opacity" : 1.0, "fill_opacity" : 1.0,
"initial_scale_val" : 0.01, "initial_scale_factor" : 0.01,
"corner_scale_factor" : 0.75, "corner_scale_factor" : 0.75,
"flip_at_start" : False, "flip_at_start" : False,
} }

View File

@ -40,7 +40,7 @@ class RangingValues(Animation):
"value_function" : None, "value_function" : None,
"tracked_mobject" : None, "tracked_mobject" : None,
"tracked_mobject_next_to_kwargs" : {}, "tracked_mobject_next_to_kwargs" : {},
"scale_val" : None "scale_factor" : None
} }
def __init__(self, start_val = 0, end_val = 1, **kwargs): def __init__(self, start_val = 0, end_val = 1, **kwargs):
digest_config(self, kwargs, locals()) digest_config(self, kwargs, locals())
@ -60,8 +60,8 @@ class RangingValues(Animation):
self.get_number(alpha), self.get_number(alpha),
num_decimal_points=self.num_decimal_points num_decimal_points=self.num_decimal_points
) )
if self.scale_val: if self.scale_factor:
mob.scale(self.scale_val) mob.scale(self.scale_factor)
if self.tracking_function: if self.tracking_function:
self.tracking_function(alpha, mob) self.tracking_function(alpha, mob)
elif self.tracked_mobject: elif self.tracked_mobject: