def construct(self):
        # Set objets
        theta = ValueTracker(self.theta)
        line_1 = Line(ORIGIN, RIGHT * self.lines_size, color=self.line_1_color)
        line_2 = Line(ORIGIN, RIGHT * self.lines_size, color=self.line_2_color)

        line_2.rotate(theta.get_value(), about_point=ORIGIN)
        line_2.add_updater(lambda m: m.set_angle(theta.get_value()))

        angle = Arc(radius=self.radius,
                    start_angle=line_1.get_angle(),
                    angle=line_2.get_angle(),
                    color=self.radius_color)

        # Show the objects

        self.play(*[ShowCreation(obj) for obj in [line_1, line_2, angle]])

        # Set update function to angle

        angle.add_updater(lambda m: m.become(
            Arc(radius=self.radius,
                start_angle=line_1.get_angle(),
                angle=line_2.get_angle(),
                color=self.radius_color)))
        # Remember to add the objects again to the screen
        # when you add the add_updater method.
        self.add(angle)

        self.play(theta.increment_value, self.increment_theta)
        # self.play(theta.set_value,self.final_theta)

        self.wait()
Example #2
0
 def __init__(self, radius=1, center=ORIGIN, **kwargs):
     VGroup.__init__(self, **kwargs)
     theta = TAU/self.arc_num
     for i in range(self.arc_num):
         arc_i = Arc(radius=radius, angle=theta * self.arc_ratio, **self.arc_config)
         arc_i.rotate(theta * i, about_point=ORIGIN)
         self.add(arc_i)
     self.move_to(center)
Example #3
0
    def __init__(self, A, O, B, **kwargs):

        VMobject.__init__(self, **kwargs)
        OA, OB = A-O, B-O
        theta = np.angle(complex(*OA[:2])/complex(*OB[:2])) # angle of OB to OA

        self.add(Arc(start_angle=Line(O, B).get_angle(), angle=theta, radius=self.radius/2,
                     stroke_width=100 * self.radius, color=self.color).set_stroke(opacity=self.opacity).move_arc_center_to(O))
        self.add(Arc(start_angle=Line(O, B).get_angle(), angle=theta, radius=self.radius,
                     stroke_width=self.stroke_width, color=self.color).move_arc_center_to(O))
Example #4
0
    def construct(self):
        axes = Axes(x_axis_config={
            "include_ticks": False
        },
                    y_axis_config={
                        "include_ticks": False
                    },
                    number_line_config={
                        "color": self.axes_color
                    }).scale(0.9)
        self.add(axes)

        ellipse = Ellipse(width=self.width, height=self.height)
        ellipse_x_axis = DashedLine(self.width / 2 * LEFT,
                                    self.width / 2 * RIGHT,
                                    color=BLACK)
        ellipse_y_axis = DashedLine(self.height / 2 * UP,
                                    self.height / 2 * DOWN,
                                    color=BLACK)

        elipticity_line = Line(self.width / 2 * LEFT,
                               self.height / 2 * UP,
                               color=BLUE)
        elipticity_arc = Arc(0, math.atan(self.height / self.width)).shift(
            self.width / 2 * LEFT)

        ellipse_group = VGroup(ellipse, ellipse_x_axis, ellipse_y_axis,
                               elipticity_arc, elipticity_line)
        ellipse_group.rotate(self.azimuth)

        self.add(ellipse_group)

        rightest = self.get_ellipse_rightest_point(self.width / 2,
                                                   self.height / 2,
                                                   self.azimuth)
        highest = self.get_ellipse_highest_point(self.width / 2,
                                                 self.height / 2, self.azimuth)

        vertical_line = Line(rightest * RIGHT,
                             rightest * RIGHT + highest * UP,
                             color=GREEN)
        horizontal_line = Line(highest * UP,
                               highest * UP + rightest * RIGHT,
                               color=GREEN)
        self.bring_to_back(vertical_line, horizontal_line)

        azimuth_arc = Arc(0, self.azimuth)

        self.add(azimuth_arc)

        self.wait()
Example #5
0
    def init_points(self):
        start_angle = np.pi / 2 + self.arc_angle / 2
        end_angle = np.pi / 2 - self.arc_angle / 2
        self.add(Arc(start_angle=start_angle, angle=-self.arc_angle))
        tick_angle_range = np.linspace(start_angle, end_angle, self.num_ticks)
        for index, angle in enumerate(tick_angle_range):
            vect = rotate_vector(RIGHT, angle)
            tick = Line((1 - self.tick_length) * vect, vect)
            label = TexMobject(str(10 * index))
            label.set_height(self.tick_length)
            label.shift((1 + self.tick_length) * vect)
            self.add(tick, label)

        needle = Polygon(LEFT,
                         UP,
                         RIGHT,
                         stroke_width=0,
                         fill_opacity=1,
                         fill_color=self.needle_color)
        needle.stretch_to_fit_width(self.needle_width)
        needle.stretch_to_fit_height(self.needle_height)
        needle.rotate(start_angle - np.pi / 2, about_point=ORIGIN)
        self.add(needle)
        self.needle = needle

        self.center_offset = self.get_center()
Example #6
0
 def __init__(self, start_angle=0, angle=TAU/4, arc_center=None, ccw=1, color=GRAY, tip_length=0.1, tip_start=True, tip_end=True, reverse=False, reverse2=False, stroke_width=4, *args, **kwargs):
     # arc_center=ORIGIN
     Arc.__init__(self, **kwargs)
     tip = ArrowTip(length=tip_length,stroke_color=color)
     if angle != 0:
         ratio = tip_length/(self.radius*(angle))
     else:
         ratio = tip_length/(self.radius*(start_angle))
     if tip_start:
         tips = tip.copy().move_to(self.point_from_proportion(0)
                                   ).shift([tip.get_width()/2, 0, 0])
         angle = angle_of_vector(self.point_from_proportion(
             ratio)-self.point_from_proportion(0))
         self.add(tips.rotate(angle, about_point=self.point_from_proportion(0)))
     if tip_end:
         tips = tip.copy().move_to(self.point_from_proportion(1)
                                   ).shift([tip.get_width()/2, 0, 0])
         angle = angle_of_vector(self.point_from_proportion(
             1-ratio)-self.point_from_proportion(1))
         self.add(tips.rotate(angle, about_point=self.point_from_proportion(1)))
 def create_arcs(self, **kwargs):
     angle = self.start_angle
     colors = color_gradient(self.colors, len(self.angle_list))
     for i in range(len(self.angle_list)):
         self.add(
             Arc(radius=self.radius,
                 start_angle=angle,
                 angle=self.angle_list[i],
                 color=colors[i],
                 stroke_width=self.stroke_width,
                 **kwargs))
         angle += self.angle_list[i]
Example #8
0
    def __init__(self, **kwargs):

        VGroup.__init__(self, **kwargs)
        self.color_list = color_gradient(self.colors, self.layer_num)
        self.add(Dot(color=average_color(self.colors[0], WHITE), plot_depth=4).set_height(0.015 * self.radius))
        for i in range(self.layer_num):
            # self.add(Arc(radius= self.radius/self.layer_num * (0.5 + i), angle=TAU, color=self.color_list[i],
            #              stroke_width=100 * self.radius/self.layer_num,
            #              stroke_opacity=self.opacity_func(i/self.layer_num), plot_depth=5))
            self.add(Arc(radius= self.radius * self.rate_func((0.5 + i)/self.layer_num), angle=TAU, color=self.color_list[i],
                         stroke_width=101 * (self.rate_func((i + 1)/self.layer_num) - self.rate_func(i/self.layer_num)) * self.radius,
                         stroke_opacity=self.opacity_func(self.rate_func(i/self.layer_num)), plot_depth=5))
Example #9
0
 def __init__(self, radius=1, **kwargs):
     super().__init__(**kwargs)
     self.append_vectorized_mobject(Line())
     self.append_vectorized_mobject(Arc(angle=PI))
     self.scale(radius)