
    ljD]                    $   d Z ddlmZ ddlZddlmZmZ ddlm	Z	 ddl
ZddlmZ ddlmZ ddlmZmZmZmZmZmZ dd	lmZ e	r$ddlmZ dd
lmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) g dZ*ddZ+ddZ,ddZ-	 ddd Z.dd"Z/dd#Z0efdd%Z1ddd+Z2dd.Z3dd/Z4dd0Z5	 ddd2Z6dd3Z7dd4Z8dd6Z9dd7Z:	 ddd<Z;dd>Z<dddAZ=dBefddEZ>dFddGddLZ?ddOZ@ddQZAddUZBddYZCdd]ZDddaZE	 dddkZFddlZGddoZHddqZIddvZJddzZKdd|ZLdd~ZMefddZNdS )z9Utility functions for two- and three-dimensional vectors.    )annotationsN)CallableSequence)TYPE_CHECKING)triangulate_float32)Rotation)DOWNOUTPIRIGHTTAUUP)adjacent_pairs)
ManimFloatMatrixMNPoint2D_ArrayPoint3DPoint3DLikePoint3DLike_ArrayPointNDPointNDLike_ArrayVector2DVector2D_ArrayVector3DVector3DLikeVector3DLike_Array)quaternion_multquaternion_from_angle_axisangle_axis_from_quaternionquaternion_conjugaterotate_vectorthick_diagonalrotation_matrixrotation_about_zz_to_vectorangle_of_vectorangle_between_vectors	normalizeget_unit_normalcompass_directionsregular_verticescomplex_to_R3R3_to_complexcomplex_func_to_R3_funccenter_of_massmidpointfind_intersectionline_intersectionget_winding_numbershoelaceshoelace_directioncross2dearclip_triangulationcartesian_to_sphericalspherical_to_cartesianperpendicular_bisectorvfloatreturnc                0    t          j        | |           }|S N)npdot)r;   vals     P/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/utils/space_ops.pynorm_squaredrD   E   s    1CJ    v1r   v2r   c                    t          j        | d         |d         z  | d         |d         z  z
  | d         |d         z  | d         |d         z  z
  | d         |d         z  | d         |d         z  z
  g          S )N      r   r@   array)rF   rG   s     rC   crossrM   J   s{    8qEBqEMBqEBqEM)qEBqEMBqEBqEM)qEBqEMBqEBqEM)	
  rE   quatsSequence[float]%np.ndarray | list[float | np.ndarray]c                 .   t          |           dk    rg dS | d         }| dd         D ]j}|\  }}}}|\  }}}	}
||z  ||z  z
  ||	z  z
  ||
z  z
  ||z  ||z  z   ||
z  z   ||	z  z
  ||	z  ||z  z   ||z  z   ||
z  z
  ||
z  ||z  z   ||	z  z   ||z  z
  g}k|S )a(  Gets the Hamilton product of the quaternions provided.
    For more information, check `this Wikipedia page
    <https://en.wikipedia.org/wiki/Quaternion>`__.

    Returns
    -------
    Union[np.ndarray, List[Union[float, np.ndarray]]]
        Returns a list of product of two quaternions.
    r   )rI   r   r   r   rI   N)len)rN   result	next_quatw1x1y1z1w2x2y2z2s              rC   r   r   X   s     5zzQ||1XF122Y 
 
	BB"BBGb2gR'"r'1Gb2gR'"r'1Gb2gR'"r'1Gb2gR'"r'1	
 MrE   Fangleaxis
np.ndarrayaxis_normalizedboollist[float]c                    |st          |          }t          j        | dz            gt          j        | dz            |z  S )a  Gets a quaternion from an angle and an axis.
    For more information, check `this Wikipedia page
    <https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles>`__.

    Parameters
    ----------
    angle
        The angle for the quaternion.
    axis
        The axis for the quaternion
    axis_normalized
        Checks whether the axis is normalized, by default False

    Returns
    -------
    list[float]
        Gives back a quaternion from the angle and axis
    rJ   )r(   r@   cossin)r]   r^   r`   s      rC   r   r   s   sF    .  F519;	!2!2T!9;;rE   
quaternionc                    t          | dd         t          j        g d                    }dt          j        | d                   z  }|t          dz  k    r
t          |z
  }||fS )zGets angle and axis from a quaternion.

    Parameters
    ----------
    quaternion
        The quaternion from which we get the angle and axis.

    Returns
    -------
    Sequence[float]
        Gives the angle and axis
    rI   NrI   r   r   )	fall_backrJ   r   )r(   r@   rL   arccosr   )rf   r^   r]   s      rC   r   r      sd     Z^rx			/B/BCCCD	*Q-(((EsQwe$;rE   c                R    t          j        |           }|ddxx         dz  cc<   |S )zUsed for finding the conjugate of the quaternion

    Parameters
    ----------
    quaternion
        The quaternion for which you want to find the conjugate for.

    Returns
    -------
    np.ndarray
        The conjugate of the quaternion.
    rI   NrK   )rf   rS   s     rC   r    r       s2     Xj!!F
122JJJ"JJJMrE   vectorc                    t          |           dk    rt          d          t          |           dk    rt          j        | d          } t	          ||          | z  S )a  Function for rotating a vector.

    Parameters
    ----------
    vector
        The vector to be rotated.
    angle
        The angle to be rotated by.
    axis
        The axis to be rotated, by default OUT

    Returns
    -------
    np.ndarray
        The rotated vector with provided angle and axis.

    Raises
    ------
    ValueError
        If vector is not of dimension 2 or 3.
       z(Vector must have the correct dimensions.rJ   r   )rR   
ValueErrorr@   appendr#   )rm   r]   r^   s      rC   r!   r!      sY    0 6{{QCDDD
6{{a61%%5$''&00rE   rJ   dimint	thicknessr   c                    t          j        |                               |                               | | f          }t          j        |          }t          j        ||z
            |k                         d          S )Nuint8)r@   arangerepeatreshape	transposeabsastype)rr   rt   row_indicescol_indicess       rC   r"   r"      sf    )C..'',,44c3Z@@K,{++KF;,--	9AA'JJJrE   quatlist[np.ndarray]c                T     t                      fdg dg dg dfD             S )a  Converts the quaternion, quat, to an equivalent rotation matrix representation.
    For more information, check `this page
    <https://in.mathworks.com/help/driving/ref/quaternion.rotmat.html>`_.

    Parameters
    ----------
    quat
        The quaternion which is to be converted.

    Returns
    -------
    List[np.ndarray]
        Gives back the Rotation matrix representation, returned as a 3-by-3
        matrix or 3-by-3-by-N multidimensional array.
    c                H    g | ]}t          d g|          dd         S )r   rI   N)r   ).0basisr   quat_invs     rC   
<listcomp>z=rotation_matrix_transpose_from_quaternion.<locals>.<listcomp>   sD        	qk5k844QRR8  rE   rh   )r   rI   r   r   r   rI   )r    )r   r   s   `@rC   )rotation_matrix_transpose_from_quaternionr      s\      $D))H     IIIIII
   rE   c                D    t          j        t          |                     S r?   )r@   rz   r   )r   s    rC   rotation_matrix_from_quaternionr      s    <A$GGHHHrE   c                   t          t          j        |          d d         t          j        d          k              r/t	          | t          j        |d                   z            j        S t          | |          j        S NrJ   )allr@   rL   zerosr$   signTr#   )r]   r^   s     rC   rotation_matrix_transposer      sg    
28D>>"1"!,-- <Q(8(8 899;;5$''))rE   homogeneousc                    t          j        | t          |          z                                            }|s|S t	          j        d          }||ddddf<   |S )z3Rotation in R^3 about a specified axis of rotation.   Nro   )r   from_rotvecr(   	as_matrixr@   eye)r]   r^   r   inhomogeneous_rotation_matrixr#   s        rC   r#   r#      si     %-$8	$% %ikk "  ,,&))"?BQBrE   c                    t          j        |           t          j        |           }}t          j        || dg||dgg dg          S )zReturns a rotation matrix for a given angle.

    Parameters
    ----------
    angle
        Angle for the rotation matrix.

    Returns
    -------
    np.ndarray
        Gives back the rotated matrix.
    r   r   )r@   rd   re   rL   )r]   css      rC   r$   r$     sQ     6%=="&--qA8AJ1III	
  rE   c                h   t          |           }t          t          |t                              }t          ||          }t          j                            |          dk    r3t          t          t          |                    }t          ||           }t          j        |||g          j        S )zt
    Returns some matrix in SO(3) which takes the z-axis to the
    (normalized) vector provided as an argument
    r   )	r(   rM   r   r@   linalgnormr   rL   r   )rm   axis_zaxis_yaxis_xs       rC   r%   r%   '  s    
 vFuVU++,,F66""F	y~~f""5V,,--'''8VVV,--//rE   Sequence[float] | np.ndarrayc                   t          | t          j                  rt          | j                  dk    r{| j        d         dk     rt          d          t          j        | j        d         t          j                  }| d         |_        | d         |_	        t          j
        |          }|S t          j
        t          | dd                    }|S )zReturns polar coordinate theta when vector is projected on xy plane.

    Parameters
    ----------
    vector
        The vector to find the angle for.

    Returns
    -------
    float
        The angle of the vector projected.
    rI   r   rJ   z/Vector must have the correct dimensions. (2, n)dtypeN)
isinstancer@   ndarrayrR   shaperp   empty
complex128realimagr]   complex)rm   c_vecval1rB   s       rC   r&   r&   7  s     &"*%% #fl*;*;a*?*?<?QNOOOa>>>AY
AY
huoo'6"1":.//CJrE   c           
        dt          j        t           j                            t	          |           t	          |          z
            t           j                            t	          |           t	          |          z                       z  }|S )a  Returns the angle between two vectors.
    This angle will always be between 0 and pi

    Parameters
    ----------
    v1
        The first vector.
    v2
        The second vector.

    Returns
    -------
    float
        The angle between the vectors.
    rJ   )r@   arctan2r   r   r(   )rF   rG   rB   s      rC   r'   r'   P  sg      RZ
	y}}y}}455
	y}}y}}455  C
 JrE   vectnp.ndarray | tuple[float]ri   np.ndarray | Nonec                    t           j                            |           }|dk    rt          j        |           |z  S |p t          j        t          |                     S Nr   )r@   r   r   rL   r   rR   )r   ri   r   s      rC   r(   r(   h  sN     9>>$Daxxx~~$$/BHSYY///rE   rL   c                    t          j        | | z                      |                    }d||dk    <   t          j        || j        |                                       | j                  }| |z  } | S )a  Normalizes an array with the provided axis.

    Parameters
    ----------
    array
        The array which has to be normalized.
    axis
        The axis to be normalized to.

    Returns
    -------
    np.ndarray
        Array which has been normalized according to the axis.
    rI   r   )r@   sqrtsumrx   r   ry   )rL   r^   normsbuffed_normss       rC   normalize_along_axisr   r  sj     GUU]''--..EE%1*9UEK$566>>u{KKL	\ELrE   ư>tolc                   t          j        |           }t          j        |          }t          t          j        |                    t          t          j        |                    }}|dk    r|dk    rt          S ||z  }nT|dk    r||z  }nH||z  ||z  }	}t          ||	          }
t          j        t          |
                    }||k    r|
|z  S |}t          |d                   |k     r t          |d                   |k     rt          S t          j        |d          |d         z  |d          |d         z  |d         |d         z  |d         |d         z  z   g          }
t          j        t          |
                    }|
|z  S )a  Gets the unit normal of the vectors.

    Parameters
    ----------
    v1
        The first vector.
    v2
        The second vector
    tol
        [description], by default 1e-6

    Returns
    -------
    np.ndarray
        The normal of the two vectors.
    g        r   rI   rJ   )	r@   asarraymaxr{   r	   rM   r   rD   rL   )rF   rG   r   np_v1np_v2div1div2uu1u2cpcp_norms               rC   r)   r)     sn   " JrNNEJrNNE RVE]]##S%7%7$Ds{{3;;KDL	DL ut|B2r]]',r**++S==< 1Q4yy33qt99s?? 
AaD51Q4<!A$1qtad{QqTAaD[/HI	J	JBgl2&&''G <rE   r   n
start_vectc                v    t           | z  t          j        fdt          |           D                       S )a&  Finds the cardinal directions using tau.

    Parameters
    ----------
    n
        The amount to be rotated, by default 4
    start_vect
        The direction for the angle to start with, by default RIGHT

    Returns
    -------
    np.ndarray
        The angle which has been rotated.
    c                6    g | ]}t          |z            S  )r!   )r   kr]   r   s     rC   r   z&compass_directions.<locals>.<listcomp>  s'    LLLa]:q5y99LLLrE   )r   r@   rL   range)r   r   r]   s    `@rC   r*   r*     s=     !GE8LLLLL588LLLMMMrE   rI   )radiusstart_angler   r   float | Nonetuple[np.ndarray, float]c                   || dz  dk    rdn	t           dz  }t          t          |z  |          }t          | |          }||fS )a@  Generates regularly spaced vertices around a circle centered at the origin.

    Parameters
    ----------
    n
        The number of vertices
    radius
        The radius of the circle that the vertices are placed on.
    start_angle
        The angle the vertices start at.

        If unspecified, for even ``n`` values, ``0`` will be used.
        For odd ``n`` values, 90 degrees is used.

    Returns
    -------
    vertices : :class:`numpy.ndarray`
        The regularly spaced vertices.
    start_angle : :class:`float`
        The angle the vertices start at.
    NrJ   r   r   )r   r!   r   r*   )r   r   r   start_vectorverticess        rC   r+   r+     sP    0 q5A::aa37 ==L!!\22H[  rE   complex_numr   c                D    t          j        | j        | j        df          S r   )r@   rL   r   r   )r   s    rC   r,   r,     s    8[%{'7;<<<rE   pointc                $    t          | d d          S r   )r   )r   s    rC   r-   r-     s    E"1"IrE   complex_funcCallable[[complex], complex] Callable[[Point3DLike], Point3D]c                      fdS )Nc                N    t           t          |                               S r?   )r,   r-   )pr   s    rC   <lambda>z)complex_func_to_R3_func.<locals>.<lambda>  s!    ]<<a0@0@#A#ABB rE   r   )r   s   `rC   r.   r.     s     CBBBBrE   pointsr   r   c           	     l    t          j        | dt          j        t          |                               S )zGets the center of mass of the points in space.

    Parameters
    ----------
    points
        The points to find the center of mass from.

    Returns
    -------
    np.ndarray
        The center of mass of the points.
    r   )r@   averageonesrR   )r   s    rC   r/   r/     s(     :faV!5!5666rE   point1point2float | np.ndarrayc                $    t          | |g          S )zGets the midpoint of two points.

    Parameters
    ----------
    point1
        The first point.
    point2
        The second point.

    Returns
    -------
    Union[float, np.ndarray]
        The midpoint of the points
    )r/   )r   r   s     rC   r0   r0     s    $ 66*+++rE   line1Sequence[np.ndarray]line2c                l   t          t          j        | |g          dddddf                             d                    rt	          d          d | |fD             }d |D             \  } }t          | |          \  }}}|dk    rt	          d          t          j        ||z  ||z  dg          S )	a9  Returns the intersection point of two lines, each defined by
    a pair of distinct points lying on the line.

    Parameters
    ----------
    line1
        A list of two points that determine the first line.
    line2
        A list of two points that determine the second line.

    Returns
    -------
    np.ndarray
        The intersection points of the two lines which are intersecting.

    Raises
    ------
    ValueError
        Error is produced if the two lines don't intersect with each other
        or if the coordinates don't lie on the xy-plane.
    NrJ   rl   zCoords must be in the xy-plane.c              3     K   | ]9}t          j        t          j        |          d d d df         dd          V  :d S )NrJ   ))r   r   )r   rI   rI   )constant_values)r@   padrL   r   is     rC   	<genexpr>z$line_intersection.<locals>.<genexpr>D  sa         	rx{{111bqb5!#3QGGG     rE   c              3  (   K   | ]}t          | V  d S r?   )rM   r   s     rC   r   z$line_intersection.<locals>.<genexpr>H  s&      ..!E1I......rE   r   z>The lines are parallel, there is no unique intersection point.)anyr@   rL   ry   rp   rM   )r   r   paddedxyzs         rC   r2   r2   '  s    0 28UEN##AAAqqq!G,44R8899 <:;;;   F /.v...LE5E5!!GAq!AvvL
 
 	
 8QUAE1%&&&rE   h㈵>p0sr   v0sr   p1sv1s	thresholdlist[Point3D]c                   g }t          | |||d          D ]m\  }}}}	t          |	t          ||	                    }
t          t          j        ||
          |          }||t          j        ||z
  |
          |z  |z  z   gz  }n|S )a'  
    Return the intersection of a line passing through p0 in direction v0
    with one passing through p1 in direction v1 (or array of intersections
    from arrays of such points/directions).
    For 3d values, it returns the point on the ray p0 + v0 * t closest to the
    ray p1 + v1 * t
    Tstrict)ziprM   r   r@   rA   )r   r   r   r   r  rS   p0v0p1rF   normaldenoms               rC   r1   r1   S  s     Fc3S>>> > >BBr5R==))BF2v&&	222rBw//%7"<<==MrE   c                    d}t          |           D ]C\  }}t          |          t          |          z
  }|t          z   t          z  t          z
  }||z  }D|t          z  }|S )a!  Determine the number of times a polygon winds around the origin.

    The orientation is measured mathematically positively, i.e.,
    counterclockwise.

    Parameters
    ----------
    points
        The vertices of the polygon being queried.

    Examples
    --------

    >>> from manim import Square, UP, get_winding_number
    >>> polygon = Square()
    >>> get_winding_number(polygon.get_vertices())
    np.float64(1.0)
    >>> polygon.shift(2 * UP)
    Square
    >>> get_winding_number(polygon.get_vertices())
    np.float64(0.0)
    r   )r   r&   r   r   )r   total_angler	  p2d_anglerB   s         rC   r3   r3   k  sl    . K ((  B!"%%(;(;;bLC'2-ws"CJrE   x_yr   c                `    | dddf         }| dddf         }t          j        ||          }|S )zx2D implementation of the shoelace formula.

    Returns
    -------
    :class:`float`
        Returns signed area.
    Nr   rI   )r@   	trapezoid)r  r   r   rB   s       rC   r4   r4     s<     	AAAqD	AAAAqD	Aa##CJrE   strc                4    t          |           }|dk    rdndS )z
    Uses the area determined by the shoelace method to determine whether
    the input set of points is directed clockwise or counterclockwise.

    Returns
    -------
    :class:`str`
        Either ``"CW"`` or ``"CCW"``.
    r   CWCCW)r4   )r  areas     rC   r5   r5     s!     C==D!8844&rE   aVector2D | Vector2D_Arrayb$ManimFloat | npt.NDArray[ManimFloat]c                    t          | j                  dk    r3| dddf         |dddf         z  | dddf         |dddf         z  z
  S | d         |d         z  |d         | d         z  z
  S )a  Compute the determinant(s) of the passed
    vector (sequences).

    Parameters
    ----------
    a
        A vector or a sequence of vectors.
    b
        A vector or a sequence of vectors.

    Returns
    -------
    Sequence[float] | float
        The determinant or sequence of determinants
        of the first two components of the specified
        vectors.

    Examples
    --------
    .. code-block:: pycon

        >>> cross2d(np.array([1, 2]), np.array([3, 4]))
        np.int64(-2)
        >>> cross2d(
        ...     np.array([[1, 2, 0], [1, 0, 0]]),
        ...     np.array([[3, 4, 0], [0, 1, 0]]),
        ... )
        array([-2,  1])
    rJ   Nr   rI   )rR   r   )r  r  s     rC   r6   r6     s    B 17||qAw111a4 1QQQT7Qqqq!tW#444tad{QqTAaD[((rE   verts	ring_endslistc                    d t          dg||d          D             }|dd         }|dd         }i |rfd||fD             \  }}t           |d                   |t          |          dz                              t          | fd	
          t          | fd
          t          | fd
          <   <   t	          fd|D             d          }|+|                    |           |                    |           nt          d          |g }d}	|D ]?}
|                    t          |	dz   |
                     |                    |	           |
}	@g dt          t                     t          |          z   dz
            D ]S}v r(                             g           |         n                               |         dk    r nTt           ddf         t          j        t                    gt          j                            }fd|D             S )a|  Returns a list of indices giving a triangulation
    of a polygon, potentially with holes.

    Parameters
    ----------
    verts
        verts is a numpy array of points.
    ring_ends
        ring_ends is a list of indices indicating where
        the ends of new paths are.

    Returns
    -------
    list
        A list of indices giving a triangulation of a polygon.
    c                N    g | ]"\  }}t          t          ||                    #S r   )r  r   )r   e0e1s      rC   r   z)earclip_triangulation.<locals>.<listcomp>  s9        &BU2r]]  rE   r   Fr  NrI   c           	   3  p   K   | ]0}t          t          fd t          j        |                     V  1dS )c                    | vS r?   r   )r   loop_connectionss    rC   r   z1earclip_triangulation.<locals>.<genexpr>.<lambda>  s    a'77 rE   N)r  filteritchain)r   
ring_groupr&  s     rC   r   z(earclip_triangulation.<locals>.<genexpr>  sh       

 

   8777Hj)	  

 

 

 

 

 

rE   rJ   c                4    t          |          z
            S r?   rD   )r   
tmp_j_vertr  s    rC   r   z'earclip_triangulation.<locals>.<lambda>  s    |E!Hz4I'J'J rE   )keyc                @    t                   |          z
            S r?   r,  )jr   r  s    rC   r   z'earclip_triangulation.<locals>.<lambda>      |E!HuQx4G'H'H rE   c                @    t          |                   z
            S r?   r,  )r   r0  r  s    rC   r   z'earclip_triangulation.<locals>.<lambda>  r1  rE   c              3  T   K   | ]"}|d          cxk    r|d         k     n n|V  #dS )r   rl   Nr   )r   ringr0  s     rC   r   z(earclip_triangulation.<locals>.<genexpr>  sL      HHdQ10G0G0G0GtBx0G0G0G0G0GT0G0G0G0GHHrE   zCould not find a ring to attachr   c                     g | ]
}|         S r   r   )r   miindicess     rC   r   z)earclip_triangulation.<locals>.<listcomp>(  s    ///BGBK///rE   )r  r0   rR   minnextremoverq   	Exceptionextendr   earcutr@   rL   uint32)r  r  ringsattached_ringsdetached_ringsi_rangej_rangenew_ringafterend0end1_meta_indicesr   r7  r0  r&  r-  s   `            @@@@@rC   r7   r7     s   * *-qo9oyQV*W*W*W  E 2A2YN122YN
 $?

 

 

 

  .~>

 

 

 eGAJ/ws7||q?P7Q1RSS
JJJJJKKK HHHHHIIIHHHHHIII   HHHHnHHH$
 
 !!(+++!!(++++=>>>I  $?N ED  U4!8T**+++T G	A3u::I.233 
 
    #ANNAq6"""aAANN1aA66E  %!,bhG~RY.W.W.WXXL////,////rE   vecc                "   t           j                            |           }|dk    rt          j        d          S |}t          j        | d         |z            }t          j        | d         | d                   }t          j        |||g          S )zReturns an array of numbers corresponding to each
    polar coordinate value (distance, phi, theta).

    Parameters
    ----------
    vec
        A numpy array or a sequence of floats ``[x, y, z]``.
    r   ro   rJ   rI   )r@   r   r   r   rj   r   rL   )rJ  r   rphithetas        rC   r8   r8   +  sy     9>>#Dqyyx{{A
)CFQJ

CJs1vs1v&&E8QsO$$$rE   	sphericalc                   | \  }}}t          j        |t          j        |          z  t          j        |          z  |t          j        |          z  t          j        |          z  |t          j        |          z  g          S )a  Returns a numpy array ``[x, y, z]`` based on the spherical
    coordinates given.

    Parameters
    ----------
    spherical
        A list of three floats that correspond to the following:

        r - The distance between the point and the origin.

        theta - The azimuthal angle of the point to the positive x-axis.

        phi - The vertical angle of the point to the positive z-axis.
    )r@   rL   rd   re   )rO  rL  rN  rM  s       rC   r9   r9   =  sq     MAuc8us+us+sO	
  rE   linenorm_vectorc                |    | d         }| d         }t          ||z
  |          }t          ||          }||z   ||z
  gS )a  Returns a list of two points that correspond
    to the ends of the perpendicular bisector of the
    two points given.

    Parameters
    ----------
    line
        a list of two numpy array points (corresponding
        to the ends of a line).
    norm_vector
        the vector perpendicular to both the line given
        and the perpendicular bisector.

    Returns
    -------
    list
        A list of two numpy array points that correspond
        to the ends of the perpendicular bisector
    r   rI   )rM   r0   )rQ  rR  r	  r  	directionms         rC   r:   r:   V  sK    . 
aB	aBb2g{++IRA	M1y=))rE   )r;   r<   r=   r<   )rF   r   rG   r   r=   r   )rN   rO   r=   rP   )F)r]   r<   r^   r_   r`   ra   r=   rb   )rf   rO   r=   rO   )rf   rO   r=   r_   )rm   r   r]   r<   r^   r   r=   r   )rJ   )rr   rs   rt   rs   r=   r   )r   r_   r=   r   )r   r_   r=   r_   )r]   r<   r^   r   r=   r_   )r]   r<   r^   r   r   ra   r=   r_   )r]   r<   r=   r_   )rm   r_   r=   r_   )rm   r   r=   r<   )rF   r_   rG   r_   r=   r<   r?   )r   r   ri   r   r=   r_   )rL   r_   r^   r_   r=   r_   )r   )rF   r   rG   r   r   r<   r=   r   )r   rs   r   r_   r=   r_   )r   rs   r   r<   r   r   r=   r   )r   r   r=   r_   )r   rO   r=   r_   )r   r   r=   r   )r   r   r=   r   )r   rO   r   rO   r=   r   )r   r   r   r   r=   r_   )r   )r   r   r   r   r   r   r   r   r  r<   r=   r  )r   r   r=   r<   )r  r   r=   r<   )r  r   r=   r  )r  r  r  r  r=   r  )r  r_   r  r  r=   r  )rJ  r   r=   r_   )rO  rO   r=   r_   )rQ  r   rR  r   r=   r   )O__doc__
__future__r   	itertoolsr(  collections.abcr   r   typingr   numpyr@   mapbox_earcutr   r=  scipy.spatial.transformr   manim.constantsr	   r
   r   r   r   r   manim.utils.iterablesr   numpy.typingnptmanim.typingr   r   r   r   r   r   r   r   r   r   r   r   r   __all__rD   rM   r   r   r   r    r!   r"   r   r   r   r#   r$   r%   r&   r'   r(   r   r)   r*   r+   r,   r-   r.   r/   r0   r2   r1   r3   r4   r5   r6   r7   r8   r9   r:   r   rE   rC   <module>rd     s   ? ? " " " " " "     . . . . . . . .                 7 7 7 7 7 7 , , , , , , 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 0 0 0 0 0 0                                 D   
      < "< < < < <8   (   & >A1 1 1 1 1>K K K K K   6I I I I* * * *     "   .0 0 0 0    2   2 EI0 0 0 0 0   ,2 2 2 2 2p !"E N N N N N(  !d! ! ! ! ! !B= = = =   C C C C7 7 7 7 , , , ,*)' )' )' )'b     0   @   ' ' ' '$) $) $) $)NZ0 Z0 Z0 Z0z% % % %$   6  * * * * * * *rE   