Exemplo n.º 1
0
def calc_new_agc_info(agc1, agc2, agc3, known_agc=None):
    k1, k2, k3 = [agc.get_curvature() for agc in (agc1, agc2, agc3)]
    z1, z2, z3 = [agc.get_complex_center() for agc in (agc1, agc2, agc3)]
    sum_k = k1 + k2 + k3
    sum_kz = k1 * z1 + k2 * z2 + k3 * z3
    if known_agc is not None:
        kc = known_agc.get_curvature()
        zc = known_agc.get_complex_center()
        k4 = 2 * sum_k - kc
        z4 = (2 * sum_kz - kc * zc) / k4
        return k4, complex_to_R3(z4)
    else:
        # Calculate the curvatures of new circles
        sum_k2 = k1**2 + k2**2 + k3**2
        sum_k_cycle_prod = k1 * k2 + k2 * k3 + k3 * k1
        b = (-2) * sum_k
        c = sum_k2 - 2 * sum_k_cycle_prod
        delta = b**2 - 4 * c
        k4_1 = (-b + np.sqrt(delta)) / 2
        k4_2 = (-b - np.sqrt(delta)) / 2
        # Calculate the centers of new circles
        # arxiv.org/abs/math/0101066v1 - Eqn 2.3
        sum_k2z = k1**2 * z1 + k2**2 * z2 + k3**2 * z3
        coeff_1 = (sum_k - k4_1) * k4_1
        const_1 = 2 * sum_k2z - (sum_k + k4_1) * sum_kz
        z4_1 = const_1 / coeff_1
        coeff_2 = (sum_k - k4_2) * k4_2
        const_2 = 2 * sum_k2z - (sum_k + k4_2) * sum_kz
        z4_2 = const_2 / coeff_2
        return [(k4_1, complex_to_R3(z4_1)), (k4_2, complex_to_R3(z4_2))]
 def __init__(self, function, mobject, **kwargs):
     if "path_func" not in kwargs:
         self.path_func = path_along_arc(np.log(function(complex(1))).imag)
     ApplyPointwiseFunction.__init__(
         self,
         lambda x_y_z: complex_to_R3(function(complex(x_y_z[0], x_y_z[1]))),
         instantiate(mobject), **kwargs)
Exemplo n.º 3
0
    def __init__(self, **kwargs):
        circle = Circle(color=WHITE)
        ticks = []
        for x in range(12):
            alpha = x / 12.
            point = complex_to_R3(np.exp(2 * np.pi * alpha * complex(0, 1)))
            length = 0.2 if x % 3 == 0 else 0.1
            ticks.append(Line(point, (1 - length) * point))
        self.hour_hand = Line(ORIGIN, 0.3 * UP)
        self.minute_hand = Line(ORIGIN, 0.6 * UP)
        # for hand in self.hour_hand, self.minute_hand:
        #     #Balance out where the center is
        #     hand.add(VectorizedPoint(-hand.get_end()))

        VGroup.__init__(self, circle, self.hour_hand, self.minute_hand, *ticks)
Exemplo n.º 4
0
    def __init__(self, **kwargs):
        circle = Circle(color=WHITE)
        ticks = []
        for x in range(12):
            alpha = x / 12.
            point = complex_to_R3(
                np.exp(2 * np.pi * alpha * complex(0, 1))
            )
            length = 0.2 if x % 3 == 0 else 0.1
            ticks.append(
                Line(point, (1 - length) * point)
            )
        self.hour_hand = Line(ORIGIN, 0.3 * UP)
        self.minute_hand = Line(ORIGIN, 0.6 * UP)
        # for hand in self.hour_hand, self.minute_hand:
        #     #Balance out where the center is
        #     hand.add(VectorizedPoint(-hand.get_end()))

        VGroup.__init__(
            self, circle,
            self.hour_hand, self.minute_hand,
            *ticks
        )