Пример #1
0
    def add_tips(self):
        linea_referencia = Line(self[0][0].get_start(), self[0][-1].get_end())
        vector_unitario = linea_referencia.get_unit_vector()

        punto_final1 = self[0][-1].get_end()
        punto_inicial1 = punto_final1 - vector_unitario * self.size_arrows

        punto_inicial2 = self[0][0].get_start()
        punto_final2 = punto_inicial2 + vector_unitario * self.size_arrows

        lin1_1 = Line(punto_inicial1,
                      punto_final1).set_color(self[0].get_color()).set_stroke(
                          None, self.stroke)
        lin1_2 = lin1_1.copy()
        lin2_1 = Line(punto_inicial2,
                      punto_final2).set_color(self[0].get_color()).set_stroke(
                          None, self.stroke)
        lin2_2 = lin2_1.copy()

        lin1_1.rotate(self.ang_arrows,
                      about_point=punto_final1,
                      about_edge=punto_final1)
        lin1_2.rotate(-self.ang_arrows,
                      about_point=punto_final1,
                      about_edge=punto_final1)

        lin2_1.rotate(self.ang_arrows,
                      about_point=punto_inicial2,
                      about_edge=punto_inicial2)
        lin2_2.rotate(-self.ang_arrows,
                      about_point=punto_inicial2,
                      about_edge=punto_inicial2)

        return self.add(lin1_1, lin1_2, lin2_1, lin2_2)
Пример #2
0
 def add_treds_to_tires(self):
     for tire in self.get_tires():
         radius = tire.get_width() / 2
         center = tire.get_center()
         tred = Line(0.7 * radius * RIGHT,
                     1.1 * radius * RIGHT,
                     stroke_width=2,
                     color=BLACK)
         tred.rotate(PI / 5, about_point=tred.get_end())
         for theta in np.arange(0, 2 * np.pi, np.pi / 4):
             new_tred = tred.copy()
             new_tred.rotate(theta, about_point=ORIGIN)
             new_tred.shift(center)
             tire.add(new_tred)
     return self
Пример #3
0
 def add_treds_to_tires(self):
     for tire in self.get_tires():
         radius = tire.get_width() / 2
         center = tire.get_center()
         tred = Line(
             0.7 * radius * RIGHT, 1.1 * radius * RIGHT,
             stroke_width=2,
             color=BLACK
         )
         tred.rotate(PI / 5, about_point=tred.get_end())
         for theta in np.arange(0, 2 * np.pi, np.pi / 4):
             new_tred = tred.copy()
             new_tred.rotate(theta, about_point=ORIGIN)
             new_tred.shift(center)
             tire.add(new_tred)
     return self
    def get_lines_parallel_to_axis(self, axis1, axis2):
        freq = axis1.x_step
        ratio = self.faded_line_ratio
        line = Line(axis1.get_start(), axis1.get_end())
        dense_freq = (1 + ratio)
        step = (1 / dense_freq) * freq

        lines1 = VGroup()
        lines2 = VGroup()
        inputs = np.arange(axis2.x_min, axis2.x_max + step, step)
        for i, x in enumerate(inputs):
            new_line = line.copy()
            new_line.shift(axis2.n2p(x) - axis2.n2p(0))
            if i % (1 + ratio) == 0:
                lines1.add(new_line)
            else:
                lines2.add(new_line)
        return lines1, lines2
    def get_lines_parallel_to_axis(self, axis1, axis2, freq, ratio):
        line = Line(axis1.get_start(), axis1.get_end())
        dense_freq = (1 + ratio)
        step = (1 / dense_freq) * freq

        lines1 = VGroup()
        lines2 = VGroup()
        ranges = (
            np.arange(0, axis2.x_max, step),
            np.arange(0, axis2.x_min, -step),
        )
        for inputs in ranges:
            for k, x in enumerate(inputs):
                new_line = line.copy()
                new_line.move_to(axis2.number_to_point(x))
                if k % (1 + ratio) == 0:
                    lines1.add(new_line)
                else:
                    lines2.add(new_line)
        return lines1, lines2
    def get_lines_parallel_to_axis(self, axis1, axis2, freq, ratio):
        freq = axis1.x_step
        ratio = self.faded_line_ratio
        line = Line(axis1.get_start(), axis1.get_end())
        dense_freq = (1 + ratio)
        step = (1 / dense_freq) * freq

        lines1 = VGroup()
        lines2 = VGroup()
        #'''
        if axis2.x_min == -FRAME_X_RADIUS and axis2.x_max == FRAME_X_RADIUS:
            axis2x_min = int(axis2.x_min)
            axis2x_max = int(axis2.x_max)
        else:
            axis2x_min = axis2.x_min
            axis2x_max = axis2.x_max
        inputs = np.arange(axis2x_min, axis2x_max + step, step)
        for i, x in enumerate(inputs):
            new_line = line.copy()
            new_line.shift(axis2.n2p(x) - axis2.n2p(0))
            if i % (1 + ratio) == 0:
                lines1.add(new_line)
            else:
                lines2.add(new_line)
        '''
        ranges = (
            np.arange(0, axis2.x_max, step),
            np.arange(0, axis2.x_min, -step),
        )
        for inputs in ranges:
            for k, x in enumerate(inputs):
                new_line = line.copy()
                new_line.move_to(axis2.number_to_point(x))
                if k % (1 + ratio) == 0:
                    lines1.add(new_line)
                else:
                    lines2.add(new_line)
        '''
        return lines1, lines2
Пример #7
0
    def __init__(self, mob, **kwargs):
        VGroup.__init__(self, **kwargs)
        if self.dashed == True:
            medicion = DashedLine(
                ORIGIN,
                mob.get_length() * RIGHT,
                dashed_segment_length=self.dashed_segment_length).set_color(
                    self.color)
        else:
            medicion = Line(ORIGIN, mob.get_length() * RIGHT)

        medicion.set_stroke(None, self.stroke)

        pre_medicion = Line(ORIGIN,
                            self.lateral * RIGHT).rotate(PI / 2).set_stroke(
                                None, self.stroke)
        pos_medicion = pre_medicion.copy()

        pre_medicion.move_to(medicion.get_start())
        pos_medicion.move_to(medicion.get_end())

        angulo = mob.get_angle()
        matriz_rotacion = rotation_matrix(PI / 2, OUT)
        vector_unitario = mob.get_unit_vector()
        direccion = np.matmul(matriz_rotacion, vector_unitario)
        self.direccion = direccion

        self.add(medicion, pre_medicion, pos_medicion)
        self.rotate(angulo)
        self.move_to(mob)

        if self.invert == True:
            self.shift(-direccion * self.buff)
        else:
            self.shift(direccion * self.buff)
        self.set_color(self.color)
        self.tip_point_index = -np.argmin(self.get_all_points()[-1, :])