
    lj)                        d Z ddlmZ ddgZddlmZ ddlmZmZ ddl	m
Z
 dd	lmZ dd
lmZmZmZ ddlmZ erddlmZ ddlmZ ddlmZmZ  G d de
          Z G d de          ZdS )zAnimations related to rotation.    )annotationsRotatingRotate)Callable)TYPE_CHECKINGAny   )	Animation)	Transform)OUTPITAU)linear)Mobject)OpenGLMobject)Point3DLikeVector3DLikec                  :     e Zd ZdZeedddefd fdZddZ xZ	S )r   a	  Animation that rotates a Mobject.

    Parameters
    ----------
    mobject
        The mobject to be rotated.
    angle
        The rotation angle in radians. Predefined constants such as ``DEGREES``
        can also be used to specify the angle in degrees.
    axis
        The rotation axis as a numpy vector.
    about_point
        The rotation center.
    about_edge
        If ``about_point`` is ``None``, this argument specifies
        the direction of the bounding box point to be taken as
        the rotation center.
    run_time
        The duration of the animation in seconds.
    rate_func
        The function defining the animation progress based on the relative
        runtime (see :mod:`~.rate_functions`) .
    **kwargs
        Additional keyword arguments passed to :class:`~.Animation`.

    Examples
    --------
    .. manim:: RotatingDemo

        class RotatingDemo(Scene):
            def construct(self):
                circle = Circle(radius=1, color=BLUE)
                line = Line(start=ORIGIN, end=RIGHT)
                arrow = Arrow(start=ORIGIN, end=RIGHT, buff=0, color=GOLD)
                vg = VGroup(circle,line,arrow)
                self.add(vg)
                anim_kw = {"about_point": arrow.get_start(), "run_time": 1}
                self.play(Rotating(arrow, 180*DEGREES, **anim_kw))
                self.play(Rotating(arrow, PI, **anim_kw))
                self.play(Rotating(vg, PI, about_point=RIGHT))
                self.play(Rotating(vg, PI, axis=UP, about_point=ORIGIN))
                self.play(Rotating(vg, PI, axis=RIGHT, about_edge=UP))
                self.play(vg.animate.move_to(ORIGIN))

    .. manim:: RotatingDifferentAxis

        class RotatingDifferentAxis(ThreeDScene):
            def construct(self):
                axes = ThreeDAxes()
                cube = Cube()
                arrow2d = Arrow(start=[0, -1.2, 1], end=[0, 1.2, 1], color=YELLOW_E)
                cube_group = VGroup(cube,arrow2d)
                self.set_camera_orientation(gamma=0, phi=40*DEGREES, theta=40*DEGREES)
                self.add(axes, cube_group)
                play_kw = {"run_time": 1.5}
                self.play(Rotating(cube_group, PI), **play_kw)
                self.play(Rotating(cube_group, PI, axis=UP), **play_kw)
                self.play(Rotating(cube_group, 180*DEGREES, axis=RIGHT), **play_kw)
                self.wait(0.5)

    See also
    --------
    :class:`~.Rotate`, :meth:`~.Mobject.rotate`

    N   mobjectr   anglefloataxisr   about_pointPoint3DLike | None
about_edgeVector3DLike | Nonerun_time	rate_funcCallable[[float], float]kwargsr   returnNonec                z    || _         || _        || _        || _         t	                      j        |f||d| d S )N)r   r   )r   r   r   r   super__init__)
selfr   r   r   r   r   r   r   r!   	__class__s
            S/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/animation/rotation.pyr&   zRotating.__init__X   sN     
	&$S8ySSFSSSSS    alphac                    | j                             | j                   | j                             |                     |          | j        z  | j        | j        | j                   d S N)r   r   r   )	r   becomestarting_mobjectrotater   r   r   r   r   )r'   r+   s     r)   interpolate_mobjectzRotating.interpolate_mobjecti   sj    D1222NN5!!DJ.(	 	 	
 	
 	
 	
 	
r*   )r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r   r"   r#   )r+   r   r"   r#   )
__name__
__module____qualname____doc__r   r   r   r&   r1   __classcell__r(   s   @r)   r   r      s~        @ @J  *.*..4T T T T T T T"
 
 
 
 
 
 
 
r*   c                  6     e Zd ZdZeeddfd fdZddZ xZS )r   a  Animation that rotates a Mobject.

    Parameters
    ----------
    mobject
        The mobject to be rotated.
    angle
        The rotation angle.
    axis
        The rotation axis as a numpy vector.
    about_point
        The rotation center.
    about_edge
        If ``about_point`` is ``None``, this argument specifies
        the direction of the bounding box point to be taken as
        the rotation center.

    Examples
    --------
    .. manim:: UsingRotate

        class UsingRotate(Scene):
            def construct(self):
                self.play(
                    Rotate(
                        Square(side_length=0.5).shift(UP * 2),
                        angle=2*PI,
                        about_point=ORIGIN,
                        rate_func=linear,
                    ),
                    Rotate(Square(side_length=0.5), angle=2*PI, rate_func=linear),
                    )

    See also
    --------
    :class:`~.Rotating`, :meth:`~.Mobject.rotate`

    Nr   r   r   r   r   r   r   r   r   r   r!   r   r"   r#   c                    d|vr||d<   d|vr||d<   || _         || _        || _        || _        | j        |                                | _         t                      j        |fd| j        i| d S )Npath_arcpath_arc_axispath_arc_centers)r   r   r   r   
get_centerr%   r&   )r'   r   r   r   r   r   r!   r(   s          r)   r&   zRotate.__init__   s     V##!&F:&((&*F?#
	$&#&1133DNN43CNvNNNNNr*   Mobject | OpenGLMobjectc                    | j                                         }|                    | j        | j        | j        | j                   |S r-   )r   copyr0   r   r   r   r   )r'   targets     r)   create_targetzRotate.create_target   sL    ""$$J(	 	 	
 	
 	
 r*   )r   r   r   r   r   r   r   r   r   r   r!   r   r"   r#   )r"   r>   )	r2   r3   r4   r5   r   r   r&   rB   r6   r7   s   @r)   r   r   s   sv        % %T  *.*.O O O O O O O*       r*   N)r5   
__future__r   __all__collections.abcr   typingr   r   animation.animationr
   animation.transformr   	constantsr   r   r   utils.rate_functionsr   mobject.mobjectr   mobject.opengl.opengl_mobjectr   r   r   r   r    r*   r)   <module>rN      sZ   % % " " " " " "x
  $ $ $ $ $ $ % % % % % % % % + + + + + + + + + + + + $ $ $ $ $ $ $ $ $ $ ) ) ) ) ) ) 3))))))======22222222[
 [
 [
 [
 [
y [
 [
 [
|E E E E EY E E E E Er*   