
    ljBj                    6   d Z ddlmZ g dZddlmZ ddlmZmZm	Z	 ddl
ZddlT ddlmZ dd	lmZ dd
lmZmZ ddlmZmZmZ ddlmZmZ ddlmZ ddlmZmZm Z  erddlm!Z! ddl"mZ# ddl$m%Z%m&Z&m'Z'm(Z( ddlmZ  G d dee          Z) G d de)          Z* G d de)          Z+ G d de+          Z, G d de*          Z- G d de,          Z. G d d e*          Z/ G d! d"e/          Z0 G d# d$e/          Z1 G d% d&ee          Z2 G d' d(e)          Z3dS ))z*Mobjects that are simple geometric shapes.    )annotations)PolygramPolygonRegularPolygramRegularPolygonStarTriangle	RectangleSquareRoundedRectangleCutout
ConvexHull)ceil)TYPE_CHECKINGAnyLiteralN)*)ArcBetweenPoints)ConvertToOpenGL)VGroupVMobject)BLUEWHITEParsableManimColor)adjacent_n_tuplesadjacent_pairs)	QuickHull)angle_between_vectors	normalizeregular_vertices)Self)Point3DPoint3D_ArrayPoint3DLikePoint3DLike_Array)r   c                  J     e Zd ZdZedd fd	ZddZddZ	 	 	 dddZ xZ	S )r   a  A generalized :class:`Polygon`, allowing for disconnected sets of edges.

    Parameters
    ----------
    vertex_groups
        The groups of vertices making up the :class:`Polygram`.

        The first vertex in each group is repeated to close the shape.
        Each point must be 3-dimensional: ``[x,y,z]``
    color
        The color of the :class:`Polygram`.
    kwargs
        Forwarded to the parent constructor.

    Examples
    --------
    .. manim:: PolygramExample

        import numpy as np

        class PolygramExample(Scene):
            def construct(self):
                hexagram = Polygram(
                    [[0, 2, 0], [-np.sqrt(3), -1, 0], [np.sqrt(3), -1, 0]],
                    [[-np.sqrt(3), 1, 0], [0, -2, 0], [np.sqrt(3), 1, 0]],
                )
                self.add(hexagram)

                dot = Dot()
                self.play(MoveAlongPath(dot, hexagram), run_time=5, rate_func=linear)
                self.remove(dot)
                self.wait()
    colorvertex_groupsr%   r(   r   kwargsr   c                    t                      j        dd|i| |D ]R}|^}}t          j        |          }|                     |           |                     g d |D             |           Sd S )Nr(   c              3  >   K   | ]}t          j        |          V  d S N)nparray).0vertexs     Z/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/mobject/geometry/polygram.py	<genexpr>z$Polygram.__init__.<locals>.<genexpr>c   s,      ;;28F##;;;;;;     )super__init__r.   r/   start_new_pathadd_points_as_corners)selfr(   r)   r*   verticesfirst_vertex	__class__s         r2   r7   zPolygram.__init__S   s     	//u////% 		 		H '/#L88L11L---&&J;;(;;;J\J   		 		r4   returnr#   c                *    |                                  S )a  Gets the vertices of the :class:`Polygram`.

        Returns
        -------
        :class:`numpy.ndarray`
            The vertices of the :class:`Polygram`.

        Examples
        --------
        ::

            >>> sq = Square()
            >>> sq.get_vertices()
            array([[ 1.,  1.,  0.],
                   [-1.,  1.,  0.],
                   [-1., -1.,  0.],
                   [ 1., -1.,  0.]])
        )get_start_anchorsr:   s    r2   get_verticeszPolygram.get_verticesf   s    & %%'''r4   list[Point3D_Array]c                :   g }g }t          |                                 |                                 d          D ]_\  }}|                    |           |                     ||d                   r)|                    t          j        |                     g }`|S )a  Gets the vertex groups of the :class:`Polygram`.

        Returns
        -------
        list[Point3D_Array]
            The list of vertex groups of the :class:`Polygram`.

        Examples
        --------
        ::

            >>> poly = Polygram([ORIGIN, RIGHT, UP, LEFT + UP], [LEFT, LEFT + UP, 2 * LEFT])
            >>> groups = poly.get_vertex_groups()
            >>> len(groups)
            2
            >>> groups[0]
            array([[ 0.,  0.,  0.],
                   [ 1.,  0.,  0.],
                   [ 0.,  1.,  0.],
                   [-1.,  1.,  0.]])
            >>> groups[1]
            array([[-1.,  0.,  0.],
                   [-1.,  1.,  0.],
                   [-2.,  0.,  0.]])
        Tstrictr   )zipr@   get_end_anchorsappendconsider_points_equalsr.   r/   )r:   r)   groupstartends        r2   get_vertex_groupszPolygram.get_vertex_groups{   s    4  ""$$d&:&:&<&<T
 
 
 	 	JE3 LL**3a99 $$RXe__555r4         ?F   radiusfloat | list[float]evenly_distribute_anchorsboolcomponents_per_rounded_cornerintr!   c                   |dk    r| S g }|                                  D ]}g }t          |t          t          f          r|gt	          |          z  }n/|t          t	          |          t	          |          z            z  }t          |t          |d          d          D ]\  }\  }	}
}|
|	z
  }||
z
  }t          |          }t          |          }t          ||          }|t          j        |          z  }|t          j        |dz            z  }t          j        t          j        ||          d                   }t          |
||z  z
  |
||z  z   ||z  |          }|                    |           |r\d |D             }t	          |          dk    r;t!          d |D                       }t!          d	 |D                       d
z  }||z  }nd}|d         g|dd         }ddlm} t'          |          D ]\  }}|                    |j                    ||                                |                                          }|r7|                    t          |                                |z                       |                    |j                   |                     t          j        |                     | S )a	  Rounds off the corners of the :class:`Polygram`.

        Parameters
        ----------
        radius
            The curvature of the corners of the :class:`Polygram`.
        evenly_distribute_anchors
            Break long line segments into proportionally-sized segments.
        components_per_rounded_corner
            The number of points used to represent the rounded corner curve.


        .. seealso::
            :class:`.~RoundedRectangle`

        .. note::
            If `radius` is supplied as a single value, then the same radius
            will be applied to all corners.  If `radius` is a list, then the
            individual values will be applied sequentially, with the first
            corner receiving `radius[0]`, the second corner receiving
            `radius[1]`, etc.  The radius list will be repeated as necessary.

            The `components_per_rounded_corner` value is provided so that the
            fidelity of the rounded corner may be fine-tuned as needed.  2 is
            an appropriate value for most shapes, however a larger value may be
            need if the rounded corner is particularly large.  2 is the minimum
            number allowed, representing the start and end of the curve.  3 will
            result in a start, middle, and end point, meaning 2 curves will be
            generated.

            The option to `evenly_distribute_anchors` is provided so that the
            line segments (the part part of each line remaining after rounding
            off the corners) can be subdivided to a density similar to that of
            the average density of the rounded corners.  This may be desirable
            in situations in which an even distribution of curves is desired
            for use in later transformation animations.  Be aware, though, that
            enabling this option can result in an an object containing
            significantly more points than the original, especially when the
            rounded corner curves are small.

        Examples
        --------
        .. manim:: PolygramRoundCorners
            :save_last_frame:

            class PolygramRoundCorners(Scene):
                def construct(self):
                    star = Star(outer_radius=2)

                    shapes = VGroup(star)
                    shapes.add(star.copy().round_corners(radius=0.1))
                    shapes.add(star.copy().round_corners(radius=0.25))

                    shapes.arrange(RIGHT)
                    self.add(shapes)
        r      TrE   rP   )anglenum_componentsc                B    g | ]}t          |j                  d k    |S )   lenpointsr0   arcs     r2   
<listcomp>z*Polygram.round_corners.<locals>.<listcomp>  s+    &R&R&Rsc#*ooPQ>Q>Qs>Q>Q>Qr4   c                6    g | ]}|                                 S r5   )get_arc_lengthr`   s     r2   rb   z*Polygram.round_corners.<locals>.<listcomp>  s$    MMM#++--MMMr4   c                6    g | ]}t          |j                  S r5   r]   r`   s     r2   rb   z*Polygram.round_corners.<locals>.<listcomp>  s     LLLS__LLLr4   r\   g      ?NLine)rN   
isinstancerV   floatr^   r   rG   r   r   r   r.   signtancrossr   rI   summanim.mobject.geometry.linerh   r   extendr_   get_end	get_startinsert_n_curves
get_length
set_pointsr/   )r:   rQ   rS   rU   
new_pointsvertex_grouparcsradius_listcurrent_radiusv1v2v3vect1vect2
unit_vect1
unit_vect2rY   cut_off_lengthrk   ra   nonzero_length_arcstotal_arc_length
num_curvesaverage_arc_lengthrh   arc1arc2lines                               r2   round_cornerszPolygram.round_corners   s,   | Q;;K$&
 2244 ?	/ ?	/LD &3,// M%h\):)::$tC,=,=F,K'L'LL03.|Q??1 1 1 ! !,R RR&u--
&u--
-eU;;000 "0"&2C2C!C wrxu55a899&n44n44,#@	   C    ( -&R&Rd&R&R&R#*++a//'*MM9LMMM( ($ LL8KLLLMMPQQ  *:J)F&&),& H)tCRCy)D888888,T22 	/ 	/
d!!$+...tDLLNNDNN,<,<== - W((doo.?.?BT.T)U)UVVV!!$+....	/ 	,,---r4   )r)   r%   r(   r   r*   r   )r>   r#   )r>   rC   )rO   FrP   )rQ   rR   rS   rT   rU   rV   r>   r!   )
__name__
__module____qualname____doc__r   r7   rB   rN   r   __classcell__r=   s   @r2   r   r   0   s           J %)       &( ( ( (*( ( ( (X '**/-.	F F F F F F F F Fr4   r   )	metaclassc                  $     e Zd ZdZd	 fdZ xZS )
r   a  A shape consisting of one closed loop of vertices.

    Parameters
    ----------
    vertices
        The vertices of the :class:`Polygon`.
    kwargs
        Forwarded to the parent constructor.

    Examples
    --------
    .. manim:: PolygonExample
        :save_last_frame:

        class PolygonExample(Scene):
            def construct(self):
                isosceles = Polygon([-5, 1.5, 0], [-2, 1.5, 0], [-3.5, -2, 0])
                position_list = [
                    [4, 1, 0],  # middle right
                    [4, -2.5, 0],  # bottom right
                    [0, -2.5, 0],  # bottom left
                    [0, 3, 0],  # top left
                    [2, 1, 0],  # middle
                    [4, 3, 0],  # top right
                ]
                square_and_triangles = Polygon(*position_list, color=PURPLE_B)
                self.add(isosceles, square_and_triangles)
    r;   r$   r*   r   r>   Nonec                <     t                      j        |fi | d S r-   r6   r7   )r:   r;   r*   r=   s      r2   r7   zPolygon.__init__L  s(    ,,V,,,,,r4   )r;   r$   r*   r   r>   r   r   r   r   r   r7   r   r   s   @r2   r   r   .  sG         :- - - - - - - - - -r4   r   c                  .     e Zd ZdZddddd fdZ xZS )r   aR  A :class:`Polygram` with regularly spaced vertices.

    Parameters
    ----------
    num_vertices
        The number of vertices.
    density
        The density of the :class:`RegularPolygram`.

        Can be thought of as how many vertices to hop
        to draw a line between them. Every ``density``-th
        vertex is connected.
    radius
        The radius of the circle that the vertices are placed on.
    start_angle
        The angle the vertices start at; the rotation of
        the :class:`RegularPolygram`.
    kwargs
        Forwarded to the parent constructor.

    Examples
    --------
    .. manim:: RegularPolygramExample
        :save_last_frame:

        class RegularPolygramExample(Scene):
            def construct(self):
                pentagram = RegularPolygram(5, radius=2)
                self.add(pentagram)
    rP      N)densityrQ   start_anglenum_verticesrV   r   rQ   rj   r   float | Noner*   r   r>   r   c               V   t          j                  }|z  |z  dfd} ||          \  }| _        |g}	t          d|          D ]=}
| j        |
|z  t          z  z  z   } ||          \  }}|	                    |           > t                      j        |	i | d S )Nr   r   r>   tuple[list[Any], float]c                    t          |           \  }} g }d}	 |                    ||                    |z  }|z  }|dk    rn-|| fS )NrQ   r   r   )r    rI   )r   reg_verticesr;   ir   r   rQ   s       r2   gen_polygon_verticesz6RegularPolygram.__init__.<locals>.gen_polygon_vertices  s}    (8') ) )%L+ HAQ000W\!66 [((r4   r   )r   r   r>   r   )r.   gcdr   rangeTAUrI   r6   r7   )r:   r   r   rQ   r   r*   num_gonsr   first_groupr)   r   rK   _r=   s    ```         r2   r7   zRegularPolygram.__init__p  s    , 6,00!H	) 	) 	) 	) 	) 	) 	) 	)& )=(<[(I(I%T%$q(## 	( 	(A*a(lc-AL-PPK++K88HE1  ''''-2622222r4   )r   rV   r   rV   rQ   rj   r   r   r*   r   r>   r   r   r   s   @r2   r   r   P  s]         F $(83 83 83 83 83 83 83 83 83 83 83 83r4   r   c                  &     e Zd ZdZd
d fd	Z xZS )r   a  An n-sided regular :class:`Polygon`.

    Parameters
    ----------
    n
        The number of sides of the :class:`RegularPolygon`.
    kwargs
        Forwarded to the parent constructor.

    Examples
    --------
    .. manim:: RegularPolygonExample
        :save_last_frame:

        class RegularPolygonExample(Scene):
            def construct(self):
                poly_1 = RegularPolygon(n=6)
                poly_2 = RegularPolygon(n=6, start_angle=30*DEGREES, color=GREEN)
                poly_3 = RegularPolygon(n=10, color=RED)

                poly_group = Group(poly_1, poly_2, poly_3).scale(1.5).arrange(buff=1)
                self.add(poly_group)
       nrV   r*   r   r>   r   c                @     t                      j        |fddi| d S )Nr   r   r   )r:   r   r*   r=   s      r2   r7   zRegularPolygon.__init__  s-    00A000000r4   )r   )r   rV   r*   r   r>   r   r   r   s   @r2   r   r     sL         01 1 1 1 1 1 1 1 1 1 1r4   r   c                  :     e Zd ZdZ	 ddddedz  dd fdZ xZS )r   a  A regular polygram without the intersecting lines.

    Parameters
    ----------
    n
        How many points on the :class:`Star`.
    outer_radius
        The radius of the circle that the outer vertices are placed on.
    inner_radius
        The radius of the circle that the inner vertices are placed on.

        If unspecified, the inner radius will be
        calculated such that the edges of the :class:`Star`
        perfectly follow the edges of its :class:`RegularPolygram`
        counterpart.
    density
        The density of the :class:`Star`. Only used if
        ``inner_radius`` is unspecified.

        See :class:`RegularPolygram` for more information.
    start_angle
        The angle the vertices start at; the rotation of
        the :class:`Star`.
    kwargs
        Forwardeds to the parent constructor.

    Raises
    ------
    :exc:`ValueError`
        If ``inner_radius`` is unspecified and ``density``
        is not in the range ``[1, n/2)``.

    Examples
    --------
    .. manim:: StarExample

        class StarExample(Scene):
            def construct(self):
                pentagram = RegularPolygram(5, radius=2)
                star = Star(outer_radius=2, color=RED)

                self.add(pentagram)
                self.play(Create(star), run_time=3)
                self.play(FadeOut(star), run_time=2)

    .. manim:: DifferentDensitiesExample
        :save_last_frame:

        class DifferentDensitiesExample(Scene):
            def construct(self):
                density_2 = Star(7, outer_radius=2, density=2, color=RED)
                density_3 = Star(7, outer_radius=2, density=3, color=PURPLE)

                self.add(VGroup(density_2, density_3).arrange(RIGHT))

       r   NrP   r\   )outer_radiusinner_radiusr   r   r   rV   r   rj   r   r   r   r   r*   r   r>   r   c               <   t           d|z  z  }||dk    s	||dz  k    rt          d| d|           t           |z  |z  }dt          j        |          t          j        |          dz
  t          j        |          z  z  z
  }	|t          j        |          |	z  z  }t          |||          \  }
| _        t          ||| j        |z             \  }}g }t          |
|d          D ]}|	                    |            t                      j        |i | d S )	NrP   r   zIncompatible density z for number of points r   r   TrE   )r   
ValueErrorr.   rl   cossinr    r   rG   rp   r6   r7   )r:   r   r   r   r   r   r*   inner_angleouter_angle	inverse_xouter_verticesinner_verticesr   r;   pairr=   s                  r2   r7   zStar.__init__  sj    QUm
 !||w!a%// NGNN1NN   -!+KBF;//$$q(BF;,?,?? I (26++>+>+JKL+;#,
 ,
 ,
((
 -(;6
 
 
 ')tDDD 	" 	"DOOD!!!!(-f-----r4   )r   )r   rV   r   rj   r   r   r   rV   r   r   r*   r   r>   r   )r   r   r   r   r   r7   r   r   s   @r2   r   r     sn        7 7v ,.  %)$'!G,. ,. ,. ,. ,. ,. ,. ,. ,. ,. ,. ,.r4   r   c                  $     e Zd ZdZd fdZ xZS )r	   a  An equilateral triangle.

    Parameters
    ----------
    kwargs
        Additional arguments to be passed to :class:`RegularPolygon`

    Examples
    --------
    .. manim:: TriangleExample
        :save_last_frame:

        class TriangleExample(Scene):
            def construct(self):
                triangle_1 = Triangle()
                triangle_2 = Triangle().scale(2).rotate(60*DEGREES)
                tri_group = Group(triangle_1, triangle_2).arrange(buff=1)
                self.add(tri_group)
    r*   r   r>   r   c                >     t                      j        dddi| d S )Nr   rX   r5   r   )r:   r*   r=   s     r2   r7   zTriangle.__init__F  s+    ''1''''''r4   )r*   r   r>   r   r   r   s   @r2   r	   r	   1  sG         (( ( ( ( ( ( ( ( ( (r4   r	   c                  4     e Zd ZdZeddddddfd fdZ xZS )r
   a*  A quadrilateral with two sets of parallel sides.

    Parameters
    ----------
    color
        The color of the rectangle.
    height
        The vertical height of the rectangle.
    width
        The horizontal width of the rectangle.
    grid_xstep
        Space between vertical grid lines.
    grid_ystep
        Space between horizontal grid lines.
    mark_paths_closed
        No purpose.
    close_new_points
        No purpose.
    kwargs
        Additional arguments to be passed to :class:`Polygon`

    Examples
    ----------
    .. manim:: RectangleExample
        :save_last_frame:

        class RectangleExample(Scene):
            def construct(self):
                rect1 = Rectangle(width=4.0, height=2.0, grid_xstep=1.0, grid_ystep=0.5)
                rect2 = Rectangle(width=1.0, height=4.0)
                rect3 = Rectangle(width=2.0, height=2.0, grid_xstep=1.0, grid_ystep=1.0)
                rect3.grid_lines.set_stroke(width=1)

                rects = Group(rect1, rect2, rect3).arrange(buff=1)
                self.add(rects)
           @g      @NTr(   r   heightrj   width
grid_xstepr   
grid_ystepmark_paths_closedrT   close_new_pointsr*   r   c                0    t                      j        t          t          t          t
          fdi| |                                |                                |                                 t                      | _
        srddlm |                                 rbt                    t          z            }	t          fdt          d|	          D              }
| j
                            |
           rbt                    t          z            }	t          fdt          d|	          D              }
| j
                            |
           | j
        r|                     | j
                   d S d S )Nr(   r   rg   c              3     K   | ]E} d          |z  t           z  z   d          |z  t           z  z   t          z  z             V  FdS r   r'   N)RIGHTDOWN)r0   r   rh   r(   r   r   vs     r2   r3   z%Rectangle.__init__.<locals>.<genexpr>  s          D!q:~55!q:~55E#       r4   r   c              3     K   | ]E} d          |z  t           z  z   d          |z  t           z  z   t          z  z             V  FdS r   )r   r   )r0   r   rh   r(   r   r   r   s     r2   r3   z%Rectangle.__init__.<locals>.<genexpr>  s          D!q:~44!q:~44uu}D#       r4   )r6   r7   URULDLDRstretch_to_fit_widthstretch_to_fit_heightrB   r   
grid_linesro   rh   absrV   r   add)r:   r(   r   r   r   r   r   r   r*   countgridrh   r   r=   s    `````     @@r2   r7   zRectangle.__init__p  s    	RR??u????!!%(((""6*** (( 	$ 	$888888!!##A 	&ZJ
*++E        #1e__  	D O%%% 	&ZJ+,,E        #1e__  	D O%%%? 	&HHT_%%%%%	& 	&r4   )r(   r   r   rj   r   rj   r   r   r   r   r   rT   r   rT   r*   r   )r   r   r   r   r   r7   r   r   s   @r2   r
   r
   J  sd        # #N %*#'#'"&!%6& 6& 6& 6& 6& 6& 6& 6& 6& 6& 6&r4   r
   c                  `     e Zd ZdZdd fd	Zedd
            Zej        dd            Z xZS )r   a  A rectangle with equal side lengths.

    Parameters
    ----------
    side_length
        The length of the sides of the square.
    kwargs
        Additional arguments to be passed to :class:`Rectangle`.

    Examples
    --------
    .. manim:: SquareExample
        :save_last_frame:

        class SquareExample(Scene):
            def construct(self):
                square_1 = Square(side_length=2.0).shift(DOWN)
                square_2 = Square(side_length=1.0).next_to(square_1, direction=UP)
                square_3 = Square(side_length=0.5).next_to(square_2, direction=UP)
                self.add(square_1, square_2, square_3)
    r   side_lengthrj   r*   r   r>   r   c                @     t                      j        d||d| d S )N)r   r   r5   r   )r:   r   r*   r=   s      r2   r7   zSquare.__init__  s-    I;II&IIIIIr4   c                    t          t          j                            |                                 d         |                                 d         z
                      S )Nr   r   )rj   r.   linalgnormrB   rA   s    r2   r   zSquare.side_length  sF    RY^^D$5$5$7$7$:T=N=N=P=PQR=S$STTUUUr4   valuec                @    |                      || j        z             d S r-   )scaler   )r:   r   s     r2   r   zSquare.side_length  s"    

54++,,,,,r4   )r   )r   rj   r*   r   r>   r   )r>   rj   )r   rj   r>   r   )	r   r   r   r   r7   propertyr   setterr   r   s   @r2   r   r     s         ,J J J J J J J V V V XV - - - - - - - -r4   r   c                  &     e Zd ZdZdd	 fdZ xZS )
r   a  A rectangle with rounded corners.

    Parameters
    ----------
    corner_radius
        The curvature of the corners of the rectangle.
    kwargs
        Additional arguments to be passed to :class:`Rectangle`

    Examples
    --------
    .. manim:: RoundedRectangleExample
        :save_last_frame:

        class RoundedRectangleExample(Scene):
            def construct(self):
                rect_1 = RoundedRectangle(corner_radius=0.5)
                rect_2 = RoundedRectangle(corner_radius=1.5, height=4.0, width=4.0)

                rect_group = Group(rect_1, rect_2).arrange(buff=1)
                self.add(rect_group)
    rO   corner_radiusrR   r*   r   c                |     t                      j        di | || _        |                     | j                   d S )Nr5   )r6   r7   r   r   )r:   r   r*   r=   s      r2   r7   zRoundedRectangle.__init__  sE    ""6"""*4-.....r4   )rO   )r   rR   r*   r   r   r   s   @r2   r   r     sL         ./ / / / / / / / / / /r4   r   c                  $     e Zd ZdZd
 fd	Z xZS )r   a  A shape with smaller cutouts.

    Parameters
    ----------
    main_shape
        The primary shape from which cutouts are made.
    mobjects
        The smaller shapes which are to be cut out of the ``main_shape``.
    kwargs
        Further keyword arguments that are passed to the constructor of
        :class:`~.VMobject`.


    .. warning::
        Technically, this class behaves similar to a symmetric difference: if
        parts of the ``mobjects`` are not located within the ``main_shape``,
        these parts will be added to the resulting :class:`~.VMobject`.

    Examples
    --------
    .. manim:: CutoutExample

        class CutoutExample(Scene):
            def construct(self):
                s1 = Square().scale(2.5)
                s2 = Triangle().shift(DOWN + RIGHT).scale(0.5)
                s3 = Square().shift(UP + RIGHT).scale(0.5)
                s4 = RegularPolygon(5).shift(DOWN + LEFT).scale(0.5)
                s5 = RegularPolygon(6).shift(UP + LEFT).scale(0.5)
                c = Cutout(s1, s2, s3, s4, s5, fill_opacity=1, color=BLUE, stroke_color=RED)
                self.play(Write(c), run_time=4)
                self.wait()
    
main_shaper   mobjectsr*   r   r>   r   c                
    t                      j        di | |                     |j                   |                                dk    rdnd}|D ]/}|                     |                    |          j                   0d S )NCWCCWr5   )r6   r7   append_pointsr_   get_directionforce_direction)r:   r   r   r*   sub_directionmobjectr=   s         r2   r7   zCutout.__init__  s     	""6""":,-----//477EET 	   	N 	NGw66}EELMMMM	N 	Nr4   )r   r   r   r   r*   r   r>   r   r   r   s   @r2   r   r     sR           D	N 	N 	N 	N 	N 	N 	N 	N 	N 	Nr4   r   c                  *     e Zd ZdZddd fdZ xZS )r   a  Constructs a convex hull for a set of points in no particular order.

    Parameters
    ----------
    points
        The points to consider.
    tolerance
        The tolerance used by quickhull.
    kwargs
        Forwarded to the parent constructor.

    Examples
    --------
    .. manim:: ConvexHullExample
        :save_last_frame:
        :quality: high

        class ConvexHullExample(Scene):
            def construct(self):
                points = [
                    [-2.35, -2.25, 0],
                    [1.65, -2.25, 0],
                    [2.65, -0.25, 0],
                    [1.65, 1.75, 0],
                    [-0.35, 2.75, 0],
                    [-2.35, 0.75, 0],
                    [-0.35, -1.25, 0],
                    [0.65, -0.25, 0],
                    [-1.35, 0.25, 0],
                    [0.15, 0.75, 0]
                ]
                hull = ConvexHull(*points, color=BLUE)
                dots = VGroup(*[Dot(point) for point in points])
                self.add(hull)
                self.add(dots)
    gh㈵>)	tolerancer_   r$   r   rj   r*   r   r>   r   c                  t          j        |          d d d df         }t          |          }|                    |           t	          |j                  |j        z
  }|                                }t          |j	                  }t          |          t          |          k    r]|d         }	|j        |	         |hz
  \  }|j	        |	hz
  \  }	|                    |	           t          |          t          |          k    ]t          j        d |D                       }
t          j        |
t          j        t          |
          df          f          } t!                      j        |fi | d S )NrP   rf   c                    g | ]	}|j         
S r5   )coordinates)r0   sfs     r2   rb   z'ConvexHull.__init__.<locals>.<listcomp>R  s     D D DB D D Dr4   r   )r.   r/   r   buildsetfacetsremovedpoplist	subfacetsr^   	neighborsrI   vstackhstackzerosr6   r7   )r:   r   r_   r*   r/   hullr   facetr   r   r   r;   r=   s               r2   r7   zConvexHull.__init__?  s\      BQB'##

5 T[!!DL0

))	)nnF++2B~b)UG3HUOrd*ERR   	 )nnF++ i D D) D D DEE9k28S5E5Eq4I+J+JKLL 	,,V,,,,,r4   )r_   r$   r   rj   r*   r   r>   r   r   r   s   @r2   r   r     sW        # #L 8<- - - - - - - - - - - -r4   r   )4r   
__future__r   __all__mathr   typingr   r   r   numpyr.   manim.constantsmanim.mobject.geometry.arcr   )manim.mobject.opengl.opengl_compatibilityr   &manim.mobject.types.vectorized_mobjectr   r   manim.utils.colorr   r   r   manim.utils.iterablesr   r   manim.utils.qhullr   manim.utils.space_opsr   r   r    r!   numpy.typingnptmanim.typingr"   r#   r$   r%   r   r   r   r   r   r	   r
   r   r   r   r   r5   r4   r2   <module>r     s   1 1 " " " " " "         . . . . . . . . . .         7 7 7 7 7 7 E E E E E E C C C C C C C C = = = = = = = = = = C C C C C C C C ' ' ' ' ' ' T T T T T T T T T T 5            544444{ { { { {x? { { { {|- - - - -h - - -DX3 X3 X3 X3 X3h X3 X3 X3v1 1 1 1 1_ 1 1 1:f. f. f. f. f.7 f. f. f.R( ( ( ( (~ ( ( (2\& \& \& \& \& \& \& \&~ -  -  -  -  -Y  -  -  -F/ / / / /y / / /<,N ,N ,N ,N ,NX ,N ,N ,N ,N^=- =- =- =- =- =- =- =- =- =-r4   