Exemplo n.º 1
0
 def __init__(self, n=6, **kwargs):
     digest_config(self, kwargs, locals())
     if self.start_angle is None:
         # 0 for odd, 90 for even
         self.start_angle = (n % 2) * 90 * DEGREES
     start_vect = rotate_vector(RIGHT, self.start_angle)
     vertices = compass_directions(n, start_vect)
     super().__init__(*vertices, **kwargs)
Exemplo n.º 2
0
 def __init__(self, n=6, **kwargs):
     digest_config(self, kwargs, locals())
     if self.start_angle is None:
         if n % 2 == 0:
             self.start_angle = 0
         else:
             self.start_angle = 90 * DEGREES
     start_vect = rotate_vector(RIGHT, self.start_angle)
     vertices = compass_directions(n, start_vect)
     Polygon.__init__(self, *vertices, **kwargs)
Exemplo n.º 3
0
 def square_to_cube_faces(square: Square3D) -> list[Square3D]:
     radius = square.get_height() / 2
     square.move_to(radius * OUT)
     result = [square]
     result.extend([
         square.copy().rotate(PI / 2, axis=vect, about_point=ORIGIN)
         for vect in compass_directions(4)
     ])
     result.append(square.copy().rotate(PI, RIGHT, about_point=ORIGIN))
     return result
Exemplo n.º 4
0
 def __init__(self, n=6, **kwargs):
     digest_config(self, kwargs, locals())
     if self.start_angle is None:
         if n % 2 == 0:
             self.start_angle = 0
         else:
             self.start_angle = 90 * DEGREES
     start_vect = rotate_vector(RIGHT, self.start_angle)
     vertices = compass_directions(n, start_vect)
     Polygon.__init__(self, *vertices, **kwargs)
Exemplo n.º 5
0
    def __init__(self, n=6, *args, **kwargs):
        self.args_name = \
            ["mobject_or_point", "radius", "start_angle", "element", "normal_vector"]
        self.args = \
            [ORIGIN, 1, None, "point", "OUT"]
        self.mobject_or_point, self.radius, self.start_angle, self.element, self.normal_vector = \
            generate_args(self, args, self.args)
        kwargs = merge_config_kwargs(self, kwargs, self.args_name)

        self.mobject_or_point = Location(self.mobject_or_point)
        if self.element == "point":
            if self.start_angle is None:
                if n % 2 == 0:
                    self.start_angle = 0
                else:
                    self.start_angle = 90 * DEGREES
            start_vect = rotate_vector(self.radius*RIGHT, self.start_angle)
        vertices = np.add(compass_directions(n, start_vect),
                          np.repeat([self.mobject_or_point], n, axis=0))
        GeomPolygon.__init__(self, *vertices, **kwargs)
Exemplo n.º 6
0
 def __init__(self, n=6, **kwargs):
     #### EULERTOUR_INIT_START ####
     if not hasattr(self, "args"):
         self.args = serialize_args([])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             'n': n,
             **kwargs,
         })
     #### EULERTOUR_INIT_START ####
     digest_config(self, kwargs, locals())
     if self.start_angle is None:
         if n % 2 == 0:
             self.start_angle = 0
         else:
             self.start_angle = 90 * DEGREES
     start_vect = rotate_vector(RIGHT, self.start_angle)
     vertices = compass_directions(n, start_vect)
     Polygon.__init__(self, *vertices, **kwargs)
     #### EULERTOUR_INIT_END ####
     register_mobject(self)
Exemplo n.º 7
0
 def __init__(self, n=3, **kwargs):
     digest_config(self, kwargs, locals())
     start_vect = rotate_vector(RIGHT, self.start_angle)
     vertices = compass_directions(n, start_vect)
     Polygon.__init__(self, *vertices, **kwargs)
Exemplo n.º 8
0
 def arrange_subparts(self, *subparts):
     # VGroup(*subparts).rotate(np.pi/4)
     for part, vect in zip(subparts,
                           compass_directions(start_vect=UP + RIGHT)):
         part.next_to(ORIGIN, vect, buff=0)
     VGroup(*subparts).rotate(np.pi / 4, about_point=ORIGIN)
Exemplo n.º 9
0
 def arrange_subparts(self, *subparts):
     # VGroup(*subparts).rotate(np.pi/4)
     for part, vect in zip(subparts, compass_directions(start_vect=UP + RIGHT)):
         part.next_to(ORIGIN, vect, buff=0)
     VGroup(*subparts).rotate(np.pi / 4, about_point=ORIGIN)