def get_coordinate_labels(self, x_vals=None, y_vals=None): result = [] if x_vals == None and y_vals == None: x_vals = range(-int(self.x_radius), int(self.x_radius)) y_vals = range(-int(self.y_radius), int(self.y_radius)) for index, vals in enumerate([x_vals, y_vals]): num_pair = [0, 0] for val in vals: num_pair[index] = val point = self.num_pair_to_point(num_pair) num = TexMobject(str(val)) num.scale_to_fit_height(self.written_coordinate_height) num.shift(point - num.get_corner(UP + LEFT), self.written_coordinate_nudge) result.append(num) return result
def get_coordinate_labels(self, x_vals=None, y_vals=None): result = [] nudge = 0.1 * (DOWN + RIGHT) if x_vals == None and y_vals == None: x_vals = range(-int(self.x_radius), int(self.x_radius)) y_vals = range(-int(self.y_radius), int(self.y_radius)) for index, vals in zip([0, 1], [x_vals, y_vals]): num_pair = [0, 0] for val in vals: num_pair[index] = val point = self.num_pair_to_point(num_pair) num = TexMobject(str(val)) num.scale(self.number_scale_factor) num.shift(point - num.get_corner(UP + LEFT) + nudge) result.append(num) return result
def get_coordinate_labels(self, x_vals = None, y_vals = None): result = [] if x_vals == None and y_vals == None: x_vals = range(-int(self.x_radius), int(self.x_radius)) y_vals = range(-int(self.y_radius), int(self.y_radius)) for index, vals in enumerate([x_vals, y_vals]): num_pair = [0, 0] for val in vals: num_pair[index] = val point = self.num_pair_to_point(num_pair) num = TexMobject(str(val)) num.scale_to_fit_height( self.written_coordinate_height ) num.shift( point-num.get_corner(UP+LEFT), self.written_coordinate_nudge ) result.append(num) return result
def get_coordinate_labels(self, *numbers): result = VGroup() nudge = 0.1*(DOWN+RIGHT) if len(numbers) == 0: numbers = range(-int(self.x_radius), int(self.x_radius)) numbers += [ complex(0, y) for y in range(-int(self.y_radius), int(self.y_radius)) ] for number in numbers: point = self.number_to_point(number) if number == 0: num_str = "0" else: num_str = str(number).replace("j", "i") num = TexMobject(num_str) num.scale(self.number_scale_factor) num.shift(point-num.get_corner(UP+LEFT)+nudge) result.add(num) return result
def get_coordinate_labels(self, *numbers): result = [] nudge = 0.1*(DOWN+RIGHT) if len(numbers) == 0: numbers = range(-int(self.x_radius), int(self.x_radius)) numbers += [ complex(0, y) for y in range(-int(self.y_radius), int(self.y_radius)) ] for number in numbers: point = self.number_to_point(number) if number == 0: num_str = "0" else: num_str = str(number).replace("j", "i") num = TexMobject(num_str) num.scale(self.number_scale_factor) num.shift(point-num.get_corner(UP+LEFT)+nudge) result.append(num) return result
def construct(self): top = TOP() times = top.put_in_vertex(0, TexMobject("\\times")) times.highlight(YELLOW) oplus = top.put_in_vertex(1, TexMobject("\\oplus")) oplus.highlight(BLUE) dot = top.put_in_vertex(2, Dot()) eight = top.put_on_vertex(2, TexMobject("8")) self.add(top) self.play(ShowCreation(eight)) for mob in dot, oplus, times: self.play(ShowCreation(mob)) self.wait() top.add(eight) top.add(times, oplus, dot) top1, top2, top3 = tops = [top.copy() for i in range(3)] big_oplus = TexMobject("\\oplus").scale(2).highlight(BLUE) equals = TexMobject("=") equation = VMobject(top1, big_oplus, top2, equals, top3) equation.arrange_submobjects() top3.shift(0.5 * RIGHT) x, y, xy = [ t.put_on_vertex(0, s) for t, s in zip(tops, ["x", "y", "xy"]) ] old_style_eq = TexMobject( "\\dfrac{1}{\\frac{1}{\\log_x(8)} + \\frac{1}{\\log_y(8)}} = \\log_{xy}(8)" ) old_style_eq.to_edge(UP).highlight(RED) triple_top_copy = VMobject(*[top.copy() for i in range(3)]) self.clear() self.play(Transform(triple_top_copy, VMobject(*tops)), FadeIn(VMobject(x, y, xy, big_oplus, equals))) self.remove(triple_top_copy) self.add(*tops) self.play(Write(old_style_eq)) self.wait(3) syms = VMobject(x, y, xy) new_syms = VMobject(*[ t.put_on_vertex(1, s) for t, s in zip(tops, ["x", "y", "x \\oplus y"]) ]) new_old_style_eq = TexMobject( "\\sqrt[x]{8} \\sqrt[y]{8} = \\sqrt[X]{8}") X = new_old_style_eq.split()[-4] frac = TexMobject("\\frac{1}{\\frac{1}{x} + \\frac{1}{y}}") frac.replace(X) frac_lower_right = frac.get_corner(DOWN + RIGHT) frac.scale(2) frac.shift(frac_lower_right - frac.get_corner(DOWN + RIGHT)) new_old_style_eq.submobjects[-4] = frac new_old_style_eq.to_edge(UP) new_old_style_eq.highlight(RED) big_times = TexMobject("\\times").highlight(YELLOW) big_times.shift(big_oplus.get_center()) self.play(Transform(old_style_eq, new_old_style_eq), Transform(syms, new_syms, path_arc=np.pi / 2), Transform(big_oplus, big_times)) self.wait(4)
def construct(self): top = TOP() times = top.put_in_vertex(0, TexMobject("\\times")) times.highlight(YELLOW) oplus = top.put_in_vertex(1, TexMobject("\\oplus")) oplus.highlight(BLUE) dot = top.put_in_vertex(2, Dot()) eight = top.put_on_vertex(2, TexMobject("8")) self.add(top) self.play(ShowCreation(eight)) for mob in dot, oplus, times: self.play(ShowCreation(mob)) self.dither() top.add(eight) top.add(times, oplus, dot) top1, top2, top3 = tops = [ top.copy() for i in range(3) ] big_oplus = TexMobject("\\oplus").scale(2).highlight(BLUE) equals = TexMobject("=") equation = VMobject( top1, big_oplus, top2, equals, top3 ) equation.arrange_submobjects() top3.shift(0.5*RIGHT) x, y, xy = [ t.put_on_vertex(0, s) for t, s in zip(tops, ["x", "y", "xy"]) ] old_style_eq = TexMobject( "\\dfrac{1}{\\frac{1}{\\log_x(8)} + \\frac{1}{\\log_y(8)}} = \\log_{xy}(8)" ) old_style_eq.to_edge(UP).highlight(RED) triple_top_copy = VMobject(*[ top.copy() for i in range(3) ]) self.clear() self.play( Transform(triple_top_copy, VMobject(*tops)), FadeIn(VMobject(x, y, xy, big_oplus, equals)) ) self.remove(triple_top_copy) self.add(*tops) self.play(Write(old_style_eq)) self.dither(3) syms = VMobject(x, y, xy) new_syms = VMobject(*[ t.put_on_vertex(1, s) for t, s in zip(tops, ["x", "y", "x \\oplus y"]) ]) new_old_style_eq = TexMobject( "\\sqrt[x]{8} \\sqrt[y]{8} = \\sqrt[X]{8}" ) X = new_old_style_eq.split()[-4] frac = TexMobject("\\frac{1}{\\frac{1}{x} + \\frac{1}{y}}") frac.replace(X) frac_lower_right = frac.get_corner(DOWN+RIGHT) frac.scale(2) frac.shift(frac_lower_right - frac.get_corner(DOWN+RIGHT)) new_old_style_eq.submobjects[-4] = frac new_old_style_eq.to_edge(UP) new_old_style_eq.highlight(RED) big_times = TexMobject("\\times").highlight(YELLOW) big_times.shift(big_oplus.get_center()) self.play( Transform(old_style_eq, new_old_style_eq), Transform(syms, new_syms, path_arc = np.pi/2), Transform(big_oplus, big_times) ) self.dither(4)