def construct(self): words, s = TextMobject(["Pseudo-Hilbert Curve", "s"]).split() pre_words = TextMobject("Order 1") pre_words.next_to(words, LEFT, buff = 0.5) s.next_to(words, RIGHT, buff = 0.05, aligned_edge = DOWN) cluster = Mobject(pre_words, words, s) cluster.center() cluster.scale(0.7) cluster.to_edge(UP, buff = 0.3) cluster.highlight(GREEN) grid1 = Grid(1, 1) grid2 = Grid(2, 2) curve = HilbertCurve(order = 1) self.add(words, s) self.dither() self.play(Transform( s, pre_words, path_func = path_along_arc(-np.pi/3) )) self.dither() self.play(ShowCreation(grid1)) self.dither() self.play(ShowCreation(grid2)) self.dither() kwargs = { "run_time" : 5, "rate_func" : None } self.play(ShowCreation(curve, **kwargs)) self.dither()
def show_pendulum(self, arc_angle = np.pi, arc_color = GREEN): words = TextMobject(": Instantaneous center of rotation") words.next_to(self.c_label) line = Line(self.p_point, self.c_point) line_angle = line.get_angle()+np.pi line_length = line.get_length() line.add(self.p_dot.copy()) line.get_center = lambda : self.c_point tangent_line = Line(3*LEFT, 3*RIGHT) tangent_line.rotate(line_angle-np.pi/2) tangent_line.shift(self.p_point) tangent_line.highlight(arc_color) right_angle_symbol = Mobject( Line(UP, UP+RIGHT), Line(UP+RIGHT, RIGHT) ) right_angle_symbol.scale(0.3) right_angle_symbol.rotate(tangent_line.get_angle()+np.pi) right_angle_symbol.shift(self.p_point) self.play(ShowCreation(line)) self.play(ShimmerIn(words)) self.dither() pairs = [ (line_angle, arc_angle/2), (line_angle+arc_angle/2, -arc_angle), (line_angle-arc_angle/2, arc_angle/2), ] arcs = [] for start, angle in pairs: arc = Arc( angle = angle, radius = line_length, start_angle = start, color = GREEN ) arc.shift(self.c_point) self.play( ShowCreation(arc), ApplyMethod( line.rotate_in_place, angle, path_func = path_along_arc(angle) ), run_time = 2 ) arcs.append(arc) self.dither() self.play(Transform(arcs[1], tangent_line)) self.add(tangent_line) self.play(ShowCreation(right_angle_symbol)) self.dither() self.tangent_line = tangent_line self.right_angle_symbol = right_angle_symbol self.pc_line = line self.remove(words, *arcs)
def show_pendulum(self, arc_angle = np.pi, arc_color = GREEN): words = TextMobject(": Instantaneous center of rotation") words.next_to(self.c_label) line = Line(self.p_point, self.c_point) line_angle = line.get_angle()+np.pi line_length = line.get_length() line.add(self.p_dot.copy()) line.get_center = lambda : self.c_point tangent_line = Line(3*LEFT, 3*RIGHT) tangent_line.rotate(line_angle-np.pi/2) tangent_line.shift(self.p_point) tangent_line.highlight(arc_color) right_angle_symbol = Mobject( Line(UP, UP+RIGHT), Line(UP+RIGHT, RIGHT) ) right_angle_symbol.scale(0.3) right_angle_symbol.rotate(tangent_line.get_angle()+np.pi) right_angle_symbol.shift(self.p_point) self.play(ShowCreation(line)) self.play(ShimmerIn(words)) self.wait() pairs = [ (line_angle, arc_angle/2), (line_angle+arc_angle/2, -arc_angle), (line_angle-arc_angle/2, arc_angle/2), ] arcs = [] for start, angle in pairs: arc = Arc( angle = angle, radius = line_length, start_angle = start, color = GREEN ) arc.shift(self.c_point) self.play( ShowCreation(arc), ApplyMethod( line.rotate_in_place, angle, path_func = path_along_arc(angle) ), run_time = 2 ) arcs.append(arc) self.wait() self.play(Transform(arcs[1], tangent_line)) self.add(tangent_line) self.play(ShowCreation(right_angle_symbol)) self.wait() self.tangent_line = tangent_line self.right_angle_symbol = right_angle_symbol self.pc_line = line self.remove(words, *arcs)