
    lj,,                        d Z ddlmZ g d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 erdd
lmZmZmZmZ dZddZe	fddZe	fddZddZddZe	fddZdS )zBFunctions determining transformation paths between sets of points.    )annotations)straight_pathpath_along_arcclockwise_pathcounterclockwise_path)TYPE_CHECKINGN   )OUTinterpolate)	normalizerotation_matrix)PathFuncTypePoint3D_ArrayPoint3DLike_ArrayVector3DLikeg{Gz?returnr   c                     t           S )a  Simplest path function. Each point in a set goes in a straight path toward its destination.

    Examples
    --------

    .. manim :: StraightPathExample

        class StraightPathExample(Scene):
            def construct(self):
                colors = [RED, GREEN, BLUE]

                starting_points = VGroup(
                    *[
                        Dot(LEFT + pos, color=color)
                        for pos, color in zip([UP, DOWN, LEFT], colors)
                    ]
                )

                finish_points = VGroup(
                    *[
                        Dot(RIGHT + pos, color=color)
                        for pos, color in zip([ORIGIN, UP, DOWN], colors)
                    ]
                )

                self.add(starting_points)
                self.add(finish_points)
                for dot in starting_points:
                    self.add(TracedPath(dot.get_center, stroke_color=dot.get_color()))

                self.wait()
                self.play(
                    Transform(
                        starting_points,
                        finish_points,
                        path_func=utils.paths.straight_path(),
                        run_time=2,
                    )
                )
                self.wait()

    r        L/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/utils/paths.pyr   r   !   s    V r   	arc_anglefloatcircles_centersr   axisr   c                H     t          |t                    d	 fd}|S )
a5  This function transforms each point by moving it roughly along a circle, each with its own specified center.

    The path may be seen as each point smoothly changing its orbit from its starting position to its destination.

    Parameters
    ----------
    arc_angle
        The angle each point traverses around the quasicircle.
    circles_centers
        The centers of each point's quasicircle to rotate around.
    axis
        The axis of rotation.

    Examples
    --------

    .. manim :: PathAlongCirclesExample

        class PathAlongCirclesExample(Scene):
            def construct(self):
                colors = [RED, GREEN, BLUE]

                starting_points = VGroup(
                    *[
                        Dot(LEFT + pos, color=color)
                        for pos, color in zip([UP, DOWN, LEFT], colors)
                    ]
                )

                finish_points = VGroup(
                    *[
                        Dot(RIGHT + pos, color=color)
                        for pos, color in zip([ORIGIN, UP, DOWN], colors)
                    ]
                )

                self.add(starting_points)
                self.add(finish_points)
                for dot in starting_points:
                    self.add(TracedPath(dot.get_center, stroke_color=dot.get_color()))

                circle_center = Dot(3 * LEFT)
                self.add(circle_center)

                self.wait()
                self.play(
                    Transform(
                        starting_points,
                        finish_points,
                        path_func=utils.paths.path_along_circles(
                            2 * PI, circle_center.get_center()
                        ),
                        run_time=3,
                    )
                )
                self.wait()

    	fall_backstart_pointsr   
end_pointsalphar   r   c                    t          j        |z
  t                     j                  z   }t          |z            }t          j        t	          | ||          z
  |j                  z   S )N)npdotr   Tr   )r   r    r!   detransformed_end_points
rot_matrixr   r   	unit_axiss        r   pathz path_along_circles.<locals>.path   s     $3RV(/9*i*P*P*R6
 6
 $
  %UY%6	BB
&>FFL"
 "
 
 	
r   r   r   r    r   r!   r   r   r   )r   r
   )r   r   r   r)   r(   s   ``  @r   path_along_circlesr+   O   sI    z $#...I
 
 
 
 
 
 
 
 Kr   c                     t                     t          k     rt                      S t          |t                    d	 fd}|S )
a  This function transforms each point by moving it along a circular arc.

    Parameters
    ----------
    arc_angle
        The angle each point traverses around a circular arc.
    axis
        The axis of rotation.

    Examples
    --------

    .. manim :: PathAlongArcExample

        class PathAlongArcExample(Scene):
            def construct(self):
                colors = [RED, GREEN, BLUE]

                starting_points = VGroup(
                    *[
                        Dot(LEFT + pos, color=color)
                        for pos, color in zip([UP, DOWN, LEFT], colors)
                    ]
                )

                finish_points = VGroup(
                    *[
                        Dot(RIGHT + pos, color=color)
                        for pos, color in zip([ORIGIN, UP, DOWN], colors)
                    ]
                )

                self.add(starting_points)
                self.add(finish_points)
                for dot in starting_points:
                    self.add(TracedPath(dot.get_center, stroke_color=dot.get_color()))

                self.wait()
                self.play(
                    Transform(
                        starting_points,
                        finish_points,
                        path_func=utils.paths.path_along_arc(TAU * 2 / 3),
                        run_time=3,
                    )
                )
                self.wait()

    r   r   r   r    r!   r   r   c                
   || z
  }| d|z  z   }t           j        k    r3|t          j        |dz            t          j        dz            z  z  }t	          |z            }|t          j        | |z
  |j                  z   S )Ng      ?g       @r	   )r#   picrosstanr   r$   r%   )r   r    r!   vectscentersr'   r   r(   s         r   r)   zpath_along_arc.<locals>.path   s     \)u,rx	53;77"&Q:O:OOOG$UY%6	BB
w 6
EEEEr   r*   absSTRAIGHT_PATH_THRESHOLDr   r   r
   )r   r   r)   r(   s   `  @r   r   r      sf    d 9~~///$#...IF F F F F F F Kr   c                 6    t          t          j                   S )a  This function transforms each point by moving clockwise around a half circle.

    Examples
    --------

    .. manim :: ClockwisePathExample

        class ClockwisePathExample(Scene):
            def construct(self):
                colors = [RED, GREEN, BLUE]

                starting_points = VGroup(
                    *[
                        Dot(LEFT + pos, color=color)
                        for pos, color in zip([UP, DOWN, LEFT], colors)
                    ]
                )

                finish_points = VGroup(
                    *[
                        Dot(RIGHT + pos, color=color)
                        for pos, color in zip([ORIGIN, UP, DOWN], colors)
                    ]
                )

                self.add(starting_points)
                self.add(finish_points)
                for dot in starting_points:
                    self.add(TracedPath(dot.get_center, stroke_color=dot.get_color()))

                self.wait()
                self.play(
                    Transform(
                        starting_points,
                        finish_points,
                        path_func=utils.paths.clockwise_path(),
                        run_time=2,
                    )
                )
                self.wait()

    r   r#   r.   r   r   r   r   r      s    V 25&!!!r   c                 4    t          t          j                  S )a  This function transforms each point by moving counterclockwise around a half circle.

    Examples
    --------

    .. manim :: CounterclockwisePathExample

        class CounterclockwisePathExample(Scene):
            def construct(self):
                colors = [RED, GREEN, BLUE]

                starting_points = VGroup(
                    *[
                        Dot(LEFT + pos, color=color)
                        for pos, color in zip([UP, DOWN, LEFT], colors)
                    ]
                )

                finish_points = VGroup(
                    *[
                        Dot(RIGHT + pos, color=color)
                        for pos, color in zip([ORIGIN, UP, DOWN], colors)
                    ]
                )

                self.add(starting_points)
                self.add(finish_points)
                for dot in starting_points:
                    self.add(TracedPath(dot.get_center, stroke_color=dot.get_color()))

                self.wait()
                self.play(
                    Transform(
                        starting_points,
                        finish_points,
                        path_func=utils.paths.counterclockwise_path(),
                        run_time=2,
                    )
                )
                self.wait()

    r7   r   r   r   r   r     s    V "%   r   anglec                     t                     t          k     rt                      S t          |t                    d	 fd}|S )
a  This function transforms each point by moving along a spiral to its destination.

    Parameters
    ----------
    angle
        The angle each point traverses around a spiral.
    axis
        The axis of rotation.

    Examples
    --------

    .. manim :: SpiralPathExample

        class SpiralPathExample(Scene):
            def construct(self):
                colors = [RED, GREEN, BLUE]

                starting_points = VGroup(
                    *[
                        Dot(LEFT + pos, color=color)
                        for pos, color in zip([UP, DOWN, LEFT], colors)
                    ]
                )

                finish_points = VGroup(
                    *[
                        Dot(RIGHT + pos, color=color)
                        for pos, color in zip([ORIGIN, UP, DOWN], colors)
                    ]
                )

                self.add(starting_points)
                self.add(finish_points)
                for dot in starting_points:
                    self.add(TracedPath(dot.get_center, stroke_color=dot.get_color()))

                self.wait()
                self.play(
                    Transform(
                        starting_points,
                        finish_points,
                        path_func=utils.paths.spiral_path(2 * TAU),
                        run_time=5,
                    )
                )
                self.wait()

    r   r   r   r    r!   r   r   c                v    t          |dz
  z            }| |t          j        || z
  |j                  z  z   S )N   )r   r#   r$   r%   )r   r    r!   r'   r9   r(   s       r   r)   zspiral_path.<locals>.paths  s@     %eai5%8)DD
ebfZ,-F
&U&UUUUr   r*   r3   )r9   r   r)   r(   s   `  @r   spiral_pathr=   =  sf    d 5zz+++$#...IV V V V V V V Kr   )r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   )r9   r   r   r   r   r   )__doc__
__future__r   __all__typingr   numpyr#   	constantsr
   utils.bezierr   utils.space_opsr   r   manim.typingr   r   r   r   r5   r   r+   r   r   r   r=   r   r   r   <module>rG      s   H H " " " " " "   !                     & & & & & & 8 8 8 8 8 8 8 8              + + + +^ PSL L L L L^ ;> @ @ @ @ @F+" +" +" +"\+! +! +! +!\ 47 < < < < < < <r   