def rotate_wheels(self, group):
		cycle =  group.copy()

		bar = Line(cycle.get_center(), cycle.get_center()+UP*1.6)
		handle = Mobject( Dot(cycle.get_center(),radius=0.15,color=RED),
						Line(cycle.get_center(), cycle.get_center()+UP*1.6),
						Line(bar.get_end()+LEFT*0.5,bar.get_end()+RIGHT*0.5))
		self.add(cycle)
		self.play(ShowCreation(handle))

		floor = Line(cycle.get_bottom()+LEFT*16, cycle.get_bottom()+RIGHT*16,color=BLACK)
		pi_floor = TexMobject(PI).scale(0.9).move_to((cycle.get_bottom()*1.063)+RIGHT*5.2)

		hpday = TexMobject(HAPPY, color=ORANGE).scale(0.9)
		rect = SurroundingRectangle(hpday)
		holder = Line(rect.get_bottom(), rect.get_bottom()*5)
		board = VGroup(hpday,rect, holder)

		pi = Randolph().scale(0.6)
		pi.move_to(handle.get_top()+UP*0.8)
		self.play(ShowCreation(pi))
		self.play(ShowCreation(board.move_to(pi.get_top()+RIGHT)))
	
		handle.add(pi)
		handle.add(board)
		self.add(floor)
		self.add(pi_floor)
		self.add(board)
		self.play(ShowCreation(pi_floor, run_time=4),RollAlongVector(cycle,floor.points[-1]-floor.points[0], rate_func=None, run_time=13),
			MaintainPositionRelativeTo(handle, cycle), rate_func=None)
Ejemplo n.º 2
0
    def construct(self):
        self.add_cycloid_end_points()
        start = self.point_a.get_center()
        end = self.point_b.get_center()
        angle = 2 * np.pi / 3
        path = Arc(angle, radius=3)
        path.gradient_highlight(RED_D, WHITE)
        radius = Line(ORIGIN, path.points[0])
        randy = Randolph()
        randy.scale(RANDY_SCALE_FACTOR)
        randy.shift(-randy.get_bottom())
        randy_copy = randy.copy()
        words = TextMobject(
            "Circular paths are good, \\\\ but still not the best")
        words.shift(UP)

        self.play(
            ShowCreation(path),
            ApplyMethod(radius.rotate, angle, path_func=path_along_arc(angle)))
        self.play(FadeOut(radius))
        self.play(ApplyMethod(path.position_endpoints_on,
                              start,
                              end,
                              path_func=path_along_arc(-angle)),
                  run_time=3)
        self.adjust_mobject_to_index(randy_copy, 1, path.points)
        self.play(FadeIn(randy_copy))
        self.remove(randy_copy)
        self.slide(randy, path)
        self.play(ShimmerIn(words))
        self.dither()
Ejemplo n.º 3
0
    def construct(self, with_words):
        CycloidScene.construct(self)

        randy = Randolph()
        randy.scale(RANDY_SCALE_FACTOR)
        randy.shift(-randy.get_bottom())
        central_randy = randy.copy()
        start_randy = self.adjust_mobject_to_index(
            randy.copy(), 1, self.cycloid.points
        )

        if with_words:
            words1 = TextMobject("Trajectory due to gravity")
            arrow = TexMobject("\\leftrightarrow")
            words2 = TextMobject("Trajectory due \\emph{constantly} rotating wheel")
            words1.next_to(arrow, LEFT)
            words2.next_to(arrow, RIGHT)
            words = Mobject(words1, arrow, words2)
            words.scale_to_fit_width(2*SPACE_WIDTH-1)
            words.to_edge(UP, buff = 0.2)
            words.to_edge(LEFT)

        self.play(ShowCreation(self.cycloid.copy()))
        self.slide(randy, self.cycloid)
        self.add(self.slider)
        self.wait()
        self.grow_parts()
        self.draw_cycloid()
        self.wait()
        self.play(Transform(self.slider, start_randy))
        self.wait()
        self.roll_back()
        self.wait()
        if with_words:
            self.play(*map(ShimmerIn, [words1, arrow, words2]))
        self.wait()
        self.remove(self.circle)
        start_time = len(self.frames)*self.frame_duration
        self.remove(self.slider)        
        self.slide(central_randy, self.cycloid)
        end_time = len(self.frames)*self.frame_duration
        self.play_over_time_range(
            start_time,
            end_time,
            RollAlongVector(
                self.circle, 
                self.cycloid.points[-1]-self.cycloid.points[0],
                run_time = end_time-start_time,
                rate_func = None
            )
        )
        self.add(self.circle, self.slider)
        self.wait()
Ejemplo n.º 4
0
    def construct(self):
        glass = self.get_continuous_glass()
        self.play(ApplyMethod(glass.fade, 0.8))
        self.freeze_background()

        paths = self.get_paths()
        for path in paths:
            if path.get_height() > self.total_glass_height:
                path.stretch(0.7, 1)
                path.shift(self.top - path.get_top())
            path.rgbas[:, 2] = 0
        loop = paths.pop(1)  ##Bad!
        randy = Randolph()
        randy.scale(RANDY_SCALE_FACTOR)
        randy.shift(-randy.get_bottom())
        photon_run = self.photon_run_along_path(
            loop, rate_func=lambda t: smooth(1.2 * t, 2), run_time=4.1)
        text = self.get_text().to_edge(UP, buff=0.2)

        self.play(ShowCreation(loop))
        self.dither()
        self.play(photon_run)
        self.remove(photon_run.mobject)
        randy = self.slide(randy, loop)
        self.add(randy)
        self.dither()
        self.remove(randy)
        self.play(ShimmerIn(text))
        for path in paths:
            self.play(
                Transform(loop,
                          path,
                          path_func=path_along_arc(np.pi / 2),
                          run_time=2))
Ejemplo n.º 5
0
    def construct(self):
        self.knob = Circle(color=BLUE_D)
        self.knob.add_line(UP, DOWN)
        self.knob.to_corner(UP + RIGHT)
        self.knob.shift(0.5 * DOWN)
        self.last_angle = np.pi / 2
        arrow = Vector(ORIGIN, RIGHT)
        arrow.next_to(self.knob, LEFT)
        words = TextMobject("Turn this knob over time to define the curve")
        words.next_to(arrow, LEFT)
        self.path = self.get_path()
        self.path.shift(1.5 * DOWN)
        self.path.show()
        self.path.highlight(BLACK)

        randy = Randolph()
        randy.scale(RANDY_SCALE_FACTOR)
        randy.shift(-randy.get_bottom())

        self.play(ShimmerIn(words))
        self.play(ShowCreation(arrow))
        self.play(ShowCreation(self.knob))
        self.dither()
        self.add(self.path)

        self.slide(randy, self.path)
        self.dither()
Ejemplo n.º 6
0
    def construct(self, with_words):
        CycloidScene.construct(self)

        randy = Randolph()
        randy.scale(RANDY_SCALE_VAL)
        randy.shift(-randy.get_bottom())
        central_randy = randy.copy()
        start_randy = self.adjust_mobject_to_index(
            randy.copy(), 1, self.cycloid.points
        )

        if with_words:
            words1 = TextMobject("Trajectory due to gravity")
            arrow = TexMobject("\\leftrightarrow")
            words2 = TextMobject("Trajectory due \\emph{constantly} rotating wheel")
            words1.next_to(arrow, LEFT)
            words2.next_to(arrow, RIGHT)
            words = Mobject(words1, arrow, words2)
            words.scale_to_fit_width(2*SPACE_WIDTH-1)
            words.to_edge(UP, buff = 0.2)
            words.to_edge(LEFT)

        self.play(ShowCreation(self.cycloid.copy()))
        self.slide(randy, self.cycloid)
        self.add(self.slider)
        self.dither()
        self.grow_parts()
        self.draw_cycloid()
        self.dither()
        self.play(Transform(self.slider, start_randy))
        self.dither()
        self.roll_back()
        self.dither()
        if with_words:
            self.play(*map(ShimmerIn, [words1, arrow, words2]))
        self.dither()
        self.remove(self.circle)
        start_time = len(self.frames)*self.frame_duration
        self.remove(self.slider)        
        self.slide(central_randy, self.cycloid)
        end_time = len(self.frames)*self.frame_duration
        self.play_over_time_range(
            start_time,
            end_time,
            RollAlongVector(
                self.circle, 
                self.cycloid.points[-1]-self.cycloid.points[0],
                run_time = end_time-start_time,
                rate_func = None
            )
        )
        self.add(self.circle, self.slider)
        self.dither()
Ejemplo n.º 7
0
    def construct(self):
        headphones = ImageMobject("Headphones.png")
        headphones.scale(0.1)
        headphones.stretch(2, 0)
        headphones.shift(1.2*UP+0.05*LEFT)
        headphones.highlight(GREY)
        randy = Randolph()

        self.add(randy, headphones)
        self.dither(2)
        self.play(ApplyMethod(randy.blink))
        self.dither(4)
Ejemplo n.º 8
0
    def add_title(self):
        title = TextMobject("Clicky Stuffs")
        title.scale(1.5)
        title.to_edge(UP, buff = MED_SMALL_BUFF)

        randy, morty = Randolph(), Mortimer()
        for pi, vect in (randy, LEFT), (morty, RIGHT):
            pi.scale_to_fit_height(title.get_height())
            pi.change_mode("thinking")
            pi.look(DOWN)
            pi.next_to(title, vect, buff = MED_LARGE_BUFF)
        self.add_foreground_mobjects(title, randy, morty)
Ejemplo n.º 9
0
    def construct(self):
        self.knob = Circle(color = BLUE_D)
        self.knob.add_line(UP, DOWN)
        self.knob.to_corner(UP+RIGHT)
        self.knob.shift(0.5*DOWN)
        self.last_angle = np.pi/2
        arrow = Vector(ORIGIN, RIGHT)
        arrow.next_to(self.knob, LEFT)
        words = TextMobject("Turn this knob over time to define the curve")
        words.next_to(arrow, LEFT)
        self.path = self.get_path()
        self.path.shift(1.5*DOWN)
        self.path.show()
        self.path.highlight(BLACK)        

        randy = Randolph()
        randy.scale(RANDY_SCALE_VAL)
        randy.shift(-randy.get_bottom())

        self.play(ShimmerIn(words))
        self.play(ShowCreation(arrow))
        self.play(ShowCreation(self.knob))
        self.dither()
        self.add(self.path)

        self.slide(randy, self.path)
        self.dither()
Ejemplo n.º 10
0
    def construct(self):
        randy = Randolph()
        randy.scale(RANDY_SCALE_FACTOR)
        randy.shift(-randy.get_bottom())
        self.add_cycloid_end_points()   

        self.add(self.cycloid)
        self.slide(randy, self.cycloid)
        self.play(self.photon_run_along_path(self.cycloid))

        self.wait()
Ejemplo n.º 11
0
 def construct(self):
     randy = Randolph()
     randy.shift(-randy.get_bottom())
     self.slider = randy.copy()  
     randy.scale(RANDY_SCALE_FACTOR)
     paths = self.get_paths()
     point_a = Dot(paths[0].points[0])
     point_b = Dot(paths[0].points[-1])
     A = TexMobject("A").next_to(point_a, LEFT)
     B = TexMobject("B").next_to(point_b, RIGHT)
     for point, tex in [(point_a, A), (point_b, B)]:
         self.play(ShowCreation(point))
         self.play(ShimmerIn(tex))
         self.wait()
     curr_path = None        
     for path in paths:
         new_slider = self.adjust_mobject_to_index(
             randy.copy(), 1, path.points
         )
         if curr_path is None:
             curr_path = path
             self.play(ShowCreation(curr_path))
         else:
             self.play(Transform(curr_path, path))
         self.play(Transform(self.slider, new_slider))
         self.wait()
         self.remove(self.slider)
         self.slide(randy, curr_path)
     self.clear()
     self.add(point_a, point_b, A, B, curr_path)
     text = self.get_text()
     text.to_edge(UP)
     self.play(ShimmerIn(text))
     for path in paths:
         self.play(Transform(
             curr_path, path,
             path_func = path_along_arc(np.pi/2),
             run_time = 3
         ))
Ejemplo n.º 12
0
    def construct(self):
        randy = Randolph()
        randy.scale(RANDY_SCALE_FACTOR)
        randy.shift(-randy.get_bottom())
        self.add_cycloid_end_points()   

        self.add(self.cycloid)
        self.slide(randy, self.cycloid)
        self.play(self.photon_run_along_path(self.cycloid))

        self.dither()
Ejemplo n.º 13
0
 def construct(self):
     randy = Randolph()
     randy.shift(-randy.get_bottom())
     self.slider = randy.copy()  
     randy.scale(RANDY_SCALE_VAL)
     paths = self.get_paths()
     point_a = Dot(paths[0].points[0])
     point_b = Dot(paths[0].points[-1])
     A = TexMobject("A").next_to(point_a, LEFT)
     B = TexMobject("B").next_to(point_b, RIGHT)
     for point, tex in [(point_a, A), (point_b, B)]:
         self.play(ShowCreation(point))
         self.play(ShimmerIn(tex))
         self.dither()
     curr_path = None        
     for path in paths:
         new_slider = self.adjust_mobject_to_index(
             randy.copy(), 1, path.points
         )
         if curr_path is None:
             curr_path = path
             self.play(ShowCreation(curr_path))
         else:
             self.play(Transform(curr_path, path))
         self.play(Transform(self.slider, new_slider))
         self.dither()
         self.remove(self.slider)
         self.slide(randy, curr_path)
     self.clear()
     self.add(point_a, point_b, A, B, curr_path)
     text = self.get_text()
     text.to_edge(UP)
     self.play(ShimmerIn(text))
     for path in paths:
         self.play(Transform(
             curr_path, path,
             path_func = path_along_arc(np.pi/2),
             run_time = 3
         ))
Ejemplo n.º 14
0
    def construct(self):
        randy = Randolph()
        randy.scale(RANDY_SCALE_FACTOR)
        randy.shift(-randy.get_bottom())
        self.add_cycloid_end_points()
        arrow = Arrow(ORIGIN, 2 * RIGHT)
        arrows = Mobject(
            *
            [arrow.copy().shift(vect) for vect in 3 * LEFT, ORIGIN, 3 * RIGHT])
        arrows.shift(2 * SPACE_WIDTH * RIGHT)
        self.add(arrows)

        self.add(self.cycloid)
        self.slide(randy, self.cycloid)
        everything = Mobject(*self.mobjects)
        self.play(
            ApplyMethod(everything.shift,
                        4 * SPACE_WIDTH * LEFT,
                        run_time=2,
                        rate_func=rush_into))
Ejemplo n.º 15
0
    def construct(self):
        randy = Randolph()
        randy.scale(RANDY_SCALE_FACTOR)
        randy.shift(-randy.get_bottom())
        self.add_cycloid_end_points()
        points = self.cycloid.points
        ceiling = points[0, 1]
        n = len(points)
        broken_points = [
            points[k * n / self.num_pieces:(k + 1) * n / self.num_pieces]
            for k in range(self.num_pieces)
        ]
        words = TextMobject("""
            What determines the speed\\\\
            at each point?
        """)
        words.to_edge(UP)

        self.add(self.cycloid)
        sliders, vectors = [], []
        for points in broken_points:
            path = Mobject().add_points(points)
            vect = points[-1] - points[-2]
            magnitude = np.sqrt(ceiling - points[-1, 1])
            vect = magnitude * vect / np.linalg.norm(vect)
            slider = self.slide(randy, path, ceiling=ceiling)
            vector = Vector(slider.get_center(), vect)
            self.add(slider, vector)
            sliders.append(slider)
            vectors.append(vector)
        self.dither()
        self.play(ShimmerIn(words))
        self.dither(3)
        slider = sliders.pop(1)
        vector = vectors.pop(1)
        faders = sliders + vectors + [words]
        self.play(*map(FadeOut, faders))
        self.remove(*faders)
        self.show_geometry(slider, vector)
Ejemplo n.º 16
0
    def construct(self):
        self.add_cycloid_end_points()
        start = self.point_a.get_center()
        end   = self.point_b.get_center()
        angle = 2*np.pi/3
        path = Arc(angle, radius = 3)
        path.gradient_highlight(RED_D, WHITE)
        radius = Line(ORIGIN, path.points[0])
        randy = Randolph()
        randy.scale(RANDY_SCALE_VAL)
        randy.shift(-randy.get_bottom())
        randy_copy = randy.copy()
        words = TextMobject("Circular paths are good, \\\\ but still not the best")
        words.shift(UP)

        self.play(
            ShowCreation(path),
            ApplyMethod(
                radius.rotate, 
                angle,
                path_func = path_along_arc(angle)
            )
        )
        self.play(FadeOut(radius))
        self.play(
            ApplyMethod(
                path.position_endpoints_on, start, end,
                path_func = path_along_arc(-angle)
            ),
            run_time = 3
        )
        self.adjust_mobject_to_index(randy_copy, 1, path.points)
        self.play(FadeIn(randy_copy))
        self.remove(randy_copy)
        self.slide(randy, path)
        self.play(ShimmerIn(words))
        self.dither()
Ejemplo n.º 17
0
    def construct(self):
        randy = Randolph()
        randy.scale(RANDY_SCALE_VAL)
        randy.shift(-randy.get_bottom())
        self.add_cycloid_end_points()
        arrow = Arrow(ORIGIN, 2*RIGHT)
        arrows = Mobject(*[
            arrow.copy().shift(vect)
            for vect in 3*LEFT, ORIGIN, 3*RIGHT
        ])
        arrows.shift(2*SPACE_WIDTH*RIGHT)
        self.add(arrows)

        self.add(self.cycloid)
        self.slide(randy, self.cycloid)
        everything = Mobject(*self.mobjects)
        self.play(ApplyMethod(
            everything.shift, 4*SPACE_WIDTH*LEFT,
            run_time = 2,
            rate_func = rush_into
        ))
Ejemplo n.º 18
0
    def construct(self):
        randy = Randolph()
        randy.scale(RANDY_SCALE_VAL)
        randy.shift(-randy.get_bottom())
        self.add_cycloid_end_points()
        points = self.cycloid.points
        ceiling = points[0, 1]
        n = len(points)
        broken_points = [
            points[k*n/self.num_pieces:(k+1)*n/self.num_pieces]
            for k in range(self.num_pieces)
        ]
        words = TextMobject("""
            What determines the speed\\\\
            at each point?
        """)
        words.to_edge(UP)

        self.add(self.cycloid)
        sliders, vectors = [], []
        for points in broken_points:
            path = Mobject().add_points(points)
            vect = points[-1] - points[-2]
            magnitude = np.sqrt(ceiling - points[-1, 1])
            vect = magnitude*vect/np.linalg.norm(vect)
            slider = self.slide(randy, path, ceiling = ceiling)
            vector = Vector(slider.get_center(), vect)
            self.add(slider, vector)
            sliders.append(slider)
            vectors.append(vector)
        self.dither()
        self.play(ShimmerIn(words))
        self.dither(3)
        slider = sliders.pop(1)
        vector = vectors.pop(1)
        faders = sliders+vectors+[words]
        self.play(*map(FadeOut, faders))
        self.remove(*faders)
        self.show_geometry(slider, vector)
Ejemplo n.º 19
0
    def construct(self):
        glass = self.get_continuous_glass()
        self.play(ApplyMethod(glass.fade, 0.8))
        self.freeze_background()

        paths = self.get_paths()
        for path in paths:
            if path.get_height() > self.total_glass_height:
                path.stretch(0.7, 1)
                path.shift(self.top - path.get_top())
            path.rgbs[:,2] = 0
        loop = paths.pop(1) ##Bad!
        randy = Randolph()
        randy.scale(RANDY_SCALE_VAL)
        randy.shift(-randy.get_bottom())
        photon_run = self.photon_run_along_path(
            loop, 
            rate_func = lambda t : smooth(1.2*t, 2),
            run_time = 4.1
        )
        text = self.get_text().to_edge(UP, buff = 0.2)

        self.play(ShowCreation(loop))
        self.dither()
        self.play(photon_run)
        self.remove(photon_run.mobject)
        randy = self.slide(randy, loop)
        self.add(randy)
        self.dither()
        self.remove(randy)
        self.play(ShimmerIn(text))
        for path in paths:
            self.play(Transform(
                loop, path,
                path_func = path_along_arc(np.pi/2),
                run_time = 2
            ))
Ejemplo n.º 20
0
 def construct(self):
     randy = Randolph()
     randy.scale(RANDY_SCALE_VAL)
     randy.shift(-randy.get_bottom())
     self.add_cycloid_end_points()        
     self.slide(randy, self.cycloid, roll = True)
Ejemplo n.º 21
0
 def construct(self):
     randy = Randolph()
     randy.scale(RANDY_SCALE_FACTOR)
     randy.shift(-randy.get_bottom())
     self.add_cycloid_end_points()
     self.slide(randy, self.cycloid, roll=True)
Ejemplo n.º 22
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.scale_to_fit_height(self.height)
        self.set_stroke(color = WHITE, width = 0)
        self.set_fill(self.color, opacity = 1)

        from topics.characters import Randolph
        randy = Randolph(mode = "happy")
        randy.scale_to_fit_height(0.6*self.get_height())
        randy.stretch(0.8, 0)
        randy.look(RIGHT)
        randy.move_to(self)
        randy.shift(0.07*self.height*(RIGHT+UP))
        self.randy = self.pi_creature = randy
        self.add_to_back(randy)

        orientation_line = Line(self.get_left(), self.get_right())
        orientation_line.set_stroke(width = 0)
        self.add(orientation_line)
        self.orientation_line = orientation_line

        for light, color in zip(self.get_lights(), self.light_colors):
            light.set_fill(color, 1)
            light.is_subpath = False

        self.add_treds_to_tires()