def show_sin_thetas(self): pc = Line(self.p_point, self.c_point) mob = Mobject(self.theta, self.d_mob).copy() mob.ingest_submobjects() triplets = [ (pc, "D\\sin(\\theta)", 0.5), (self.y_line, "D\\sin^2(\\theta)", 0.7), ] for line, tex, scale in triplets: trig_mob = TexMobject(tex) trig_mob.scale_to_fit_width( scale*line.get_length() ) trig_mob.shift(-1.2*trig_mob.get_top()) trig_mob.rotate(line.get_angle()) trig_mob.shift(line.get_center()) if line is self.y_line: trig_mob.shift(0.1*UP) self.play(Transform(mob, trig_mob)) self.add(trig_mob) self.dither() self.remove(mob) self.d_sin_squared_theta = trig_mob
def get_vector_label(self, vector, label, direction="left", rotate=False, color=None, label_scale_factor=VECTOR_LABEL_SCALE_FACTOR): if not isinstance(label, TexMobject): if len(label) == 1: label = "\\vec{\\textbf{%s}}" % label label = TexMobject(label) if color is None: color = vector.get_color() label.highlight(color) label.scale(label_scale_factor) label.add_background_rectangle() angle = vector.get_angle() if not rotate: label.rotate(-angle) if direction is "left": label.shift(-label.get_bottom() + 0.1 * UP) else: label.shift(-label.get_top() + 0.1 * DOWN) label.rotate(angle) label.shift((vector.get_end() - vector.get_start()) / 2) return label
def get_vector_label(self, vector, label, direction = "left", rotate = False, color = None, label_scale_factor = VECTOR_LABEL_SCALE_FACTOR): if not isinstance(label, TexMobject): if len(label) == 1: label = "\\vec{\\textbf{%s}}"%label label = TexMobject(label) if color is None: color = vector.get_color() label.highlight(color) label.scale(label_scale_factor) label.add_background_rectangle() angle = vector.get_angle() if not rotate: label.rotate(-angle) if direction is "left": label.shift(-label.get_bottom() + 0.1*UP) else: label.shift(-label.get_top() + 0.1*DOWN) label.rotate(angle) label.shift((vector.get_end() - vector.get_start())/2) return label
def show_sin_thetas(self): pc = Line(self.p_point, self.c_point) mob = Mobject(self.theta, self.d_mob).copy() mob.ingest_submobjects() triplets = [ (pc, "D\\sin(\\theta)", 0.5), (self.y_line, "D\\sin^2(\\theta)", 0.7), ] for line, tex, scale in triplets: trig_mob = TexMobject(tex) trig_mob.scale_to_fit_width( scale*line.get_length() ) trig_mob.shift(-1.2*trig_mob.get_top()) trig_mob.rotate(line.get_angle()) trig_mob.shift(line.get_center()) if line is self.y_line: trig_mob.shift(0.1*UP) self.play(Transform(mob, trig_mob)) self.add(trig_mob) self.wait() self.remove(mob) self.d_sin_squared_theta = trig_mob
def ask_about_probability_p3_lands_in_this_arc(self): arc = self.arc arrow = Vector(LEFT, color = BLUE) arrow.next_to(arc.get_center(), RIGHT, MED_LARGE_BUFF) question = TextMobject("Probability of landing \\\\ in this arc?") question.scale(0.8) question.next_to(arrow, RIGHT) question.shift_onto_screen() question.shift(SMALL_BUFF*UP) answer = TexMobject( "{\\text{Length of arc}", "\\over", "\\text{Circumference}}" ) answer.highlight_by_tex("arc", BLUE) answer.scale(0.8) answer.next_to(arrow, RIGHT) equals = TexMobject("=") equals.rotate(np.pi/2) equals.next_to(answer, UP, buff = 0.35) self.play(FadeIn(question), GrowArrow(arrow)) self.have_p3_jump_around_randomly(15) self.play( question.next_to, answer, UP, LARGE_BUFF, Write(equals), FadeIn(answer) ) self.have_p3_jump_around_randomly(4) angles = self.get_point_mob_angles() self.change_point_mobs( [0, 0, 1.35*np.pi - angles[2]], run_time = 0, ) self.dither() question.add(equals) self.arc_prob_question = question self.arc_prob = answer self.arc_size_arrow = arrow
def draw_triangle(self): hyp_length = TexMobject("u", "^2", "+", "v", "^2") hyp_length.highlight_by_tex("u", U_COLOR) hyp_length.highlight_by_tex("v", V_COLOR) hyp_length.add_background_rectangle() line = self.square_line hyp_length.next_to(line.get_center(), UP, SMALL_BUFF) hyp_length.rotate(line.get_angle(), about_point=line.get_center()) triangle = Polygon( ORIGIN, RIGHT, RIGHT + UP, stroke_width=0, fill_color=MAROON_B, fill_opacity=0.5, ) triangle.replace(line, stretch=True) self.play(Write(hyp_length)) self.dither() self.play(FadeIn(triangle)) self.dither()
def construct(self): #self.force_skipping() bubble = SVGMobject(file_name = "thought_bubble", initial_scale_factor = 0.31) bubble.set_color(WHITE) bubble.stretch(1.25, 0) bubble.to_corner(DOWN+RIGHT) self.play(ShowCreation(VGroup(*bubble[:2]))) self.play(ShowCreation(bubble[2])) self.dither() subbubbles = self.make_fractal(bubble[-1], [0.8*LEFT, 0.8*RIGHT]) self.play(ShowCreation(subbubbles, submobject_mode = "all_at_once", run_time = 2)) self.dither() main_rect = Rectangle(width = 2*SPACE_WIDTH-1, height = 2*SPACE_HEIGHT-1) rect_template = main_rect.copy() rect_template.stretch_about_point(0.5, 1, rect_template.get_edge_center(UP)) subrects = self.make_fractal(rect_template, [0.9*LEFT, 0.9*RIGHT], ratio = (0.45, 0.8, 0.6)) self.play(ReplacementTransform(bubble[-1], main_rect), ReplacementTransform(subbubbles, subrects), bubble[0].behind_edge, DOWN, bubble[1].behind_edge, DOWN, run_time = 2) #self.dither() implications = TexMobject("\Rightarrow\Leftarrow") implications.arrange_submobjects(DOWN, buff = 0.5) implications.rotate(-np.pi/2) contradiction = VGroup( TexMobject("X\\in X"), implications, TexMobject("X\\not\\in X"), ) contradiction.arrange_submobjects(DOWN) contradiction.to_corner(LEFT+DOWN, buff = 1) contradiction.shift(RIGHT) contradiction.add(implications[1]) implications.remove(implications[1]) self.revert_to_original_skipping_status() #self.dither() self.play(FadeIn(contradiction, submobject_mode = "lagged_start")) #self.dither() questionmarks = TextMobject("???") questionmarks.next_to(contradiction, buff = 0.5) #self.play(Write(questionmarks)) #self.dither() #contradiction.add(questionmarks) cross = Cross().set_color(RED) cross.scale(( contradiction.get_width() / cross.get_width(), contradiction.get_height() / cross.get_height(), 1, )) cross.move_to(contradiction) title = TextMobject("Set Theory").scale(1.3).to_edge(UP) division = DashedLine(title.get_edge_center(DOWN) + 0.2*DOWN, SPACE_HEIGHT*DOWN) self.play( contradiction.highlight, DARK_GREY, ShowCreation(cross), ) axioms = TextMobject("Axioms") axioms.next_to(division) self.play(Write(axioms)) self.dither() left_rect, right_rect = [], [] for rect in subrects: if rect.get_center()[0] < 0: left_rect.append(rect) else: right_rect.append(rect) left_rect = VGroup(*left_rect) right_rect = VGroup(*right_rect) self.play(FadeOut(VGroup(right_rect, main_rect, contradiction, cross))) self.play( ShowCreation(division), UnapplyMethod(title.behind_edge, UP), left_rect.to_edge, DOWN, 0.8, ) self.dither() theory_of_infinity = TextMobject("Theory of Infinity").highlight(BLUE) foundations_of_mathematics = TextMobject("Foundations of\\\\ Mathematics", alignment = "\\raggedright") theory_of_infinity.next_to(division, LEFT, aligned_edge = UP) foundations_of_mathematics.next_to(division, RIGHT, aligned_edge = UP) VGroup(theory_of_infinity, foundations_of_mathematics).shift(0.2*DOWN) self.play(FadeIn(theory_of_infinity), run_time = 2, submobject_mode = "lagged_start") self.dither() self.play(FadeIn(foundations_of_mathematics), run_time = 2, submobject_mode = "lagged_start") self.dither()