コード例 #1
0
ファイル: cycloid.py プロジェクト: GodotMisogi/manim
    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()
コード例 #2
0
ファイル: cycloid.py プロジェクト: yanqinqiang/manim
    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()
コード例 #3
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()
コード例 #4
0
ファイル: curves.py プロジェクト: GodotMisogi/manim
 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
         ))
コード例 #5
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
         ))
コード例 #6
0
ファイル: curves.py プロジェクト: GodotMisogi/manim
    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()