예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
class BalanceCompetingFactors(Scene):
    args_list = [("Short", "Steep"),
                 ("Minimal time \\\\ in water", "Short path")]

    @staticmethod
    def args_to_string(*words):
        return "".join([word.split(" ")[0] for word in words])

    def construct(self, *words):
        factor1, factor2 = [
            TextMobject("Factor %d" % x).highlight(c)
            for x, c in [(1, RED_D), (2, BLUE_D)]
        ]
        real_factor1, real_factor2 = map(TextMobject, words)
        for word in factor1, factor2, real_factor1, real_factor2:
            word.shift(0.2 * UP - word.get_bottom())
        for f1 in factor1, real_factor1:
            f1.highlight(RED_D)
            f1.shift(2 * LEFT)
        for f2 in factor2, real_factor2:
            f2.highlight(BLUE_D)
            f2.shift(2 * RIGHT)
        line = Line(factor1.get_left(), factor2.get_right())
        line.center()
        self.balancers = Mobject(factor1, factor2, line)
        self.hidden_balancers = Mobject(real_factor1, real_factor2)

        triangle = Polygon(RIGHT, np.sqrt(3) * UP, LEFT)
        triangle.next_to(line, DOWN, buff=0)

        self.add(triangle, self.balancers)
        self.rotate(1)
        self.rotate(-2)
        self.dither()
        self.play(
            Transform(factor1,
                      real_factor1,
                      path_func=path_along_arc(np.pi / 4)))
        self.rotate(2)
        self.dither()
        self.play(
            Transform(factor2,
                      real_factor2,
                      path_func=path_along_arc(np.pi / 4)))
        self.rotate(-2)
        self.dither()
        self.rotate(1)

    def rotate(self, factor):
        angle = np.pi / 11
        self.play(Rotate(self.balancers, factor * angle, run_time=abs(factor)))
        self.hidden_balancers.rotate(factor * angle)
예제 #4
0
class BalanceCompetingFactors(Scene):
    args_list = [
        ("Short", "Steep"),
        ("Minimal time \\\\ in water", "Short path")
    ]

    @staticmethod
    def args_to_string(*words):
        return "".join([word.split(" ")[0] for word in words])
        
    def construct(self, *words):
        factor1, factor2 = [
            TextMobject("Factor %d"%x).highlight(c)
            for x, c in [
                (1, RED_D),
                (2, BLUE_D)
            ]
        ]
        real_factor1, real_factor2 = map(TextMobject, words)  
        for word in factor1, factor2, real_factor1, real_factor2:
            word.shift(0.2*UP-word.get_bottom())
        for f1 in factor1, real_factor1:
            f1.highlight(RED_D)
            f1.shift(2*LEFT)
        for f2 in factor2, real_factor2:
            f2.highlight(BLUE_D)
            f2.shift(2*RIGHT)      
        line = Line(
            factor1.get_left(),
            factor2.get_right()
        )
        line.center()
        self.balancers = Mobject(factor1, factor2, line)
        self.hidden_balancers = Mobject(real_factor1, real_factor2)

        triangle = Polygon(RIGHT, np.sqrt(3)*UP, LEFT)
        triangle.next_to(line, DOWN, buff = 0)

        self.add(triangle, self.balancers)
        self.rotate(1)
        self.rotate(-2)
        self.dither()
        self.play(Transform(
            factor1, real_factor1, 
            path_func = path_along_arc(np.pi/4)
        ))
        self.rotate(2)
        self.dither()
        self.play(Transform(
            factor2, real_factor2,
            path_func = path_along_arc(np.pi/4)
        ))
        self.rotate(-2)
        self.dither()
        self.rotate(1)

    def rotate(self, factor):
        angle = np.pi/11
        self.play(Rotate(
            self.balancers, 
            factor*angle,
            run_time = abs(factor)
        ))
        self.hidden_balancers.rotate(factor*angle)