
    Mi)                      0    S r SSKrSSKJr   " S S5      rg)z2Trackball class for 3D manipulation of viewpoints.    N   )transformationsc                   j    \ rS rSrSrSrSrSrSrSS jr	\
S	 5       rS
 rS rS rS rS rSS jrSrg)	Trackball!   zFA trackball class for creating camera transforms from mouse movements.r      r      Nc                 0   [         R                  " U5      U l        [        U5      U l        Xl        Xl        Uc;  [         R                  " / SQ5      U l        [         R                  " / SQ5      U l        OX@l        X@l        [        R                  U l        g)a  Initialize a trackball with an initial camera-to-world pose
and the given parameters.

Parameters
----------
pose : [4,4]
    An initial camera-to-world pose for the trackball.

size : (float, float)
    The width and height of the camera image in pixels.

scale : float
    The diagonal of the scene's bounding box --
    used for ensuring translation motions are sufficiently
    fast for differently-sized scenes.

target : (3,) float
    The center of the scene in world coordinates.
    The trackball will revolve around this point.
N)        r   r   )nparray_sizefloat_scale_pose_n_pose_target	_n_targetr   STATE_ROTATE_state)selfposesizescaletargets        r/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/trimesh/viewer/trackball.py__init__Trackball.__init__)   sd    * XXd^
El
>88O4DLXXo6DN!L#N,,    c                     U R                   $ )z?autolab_core.RigidTransform : The current camera-to-world pose.)r   )r   s    r   r   Trackball.poseM   s     ||r   c                     Xl         g)zSet the state of the trackball in order to change the effect of
dragging motions.

Parameters
----------
state : int
    One of Trackball.STATE_ROTATE, Trackball.STATE_PAN,
    Trackball.STATE_ROLL, and Trackball.STATE_ZOOM.
N)r   )r   states     r   	set_stateTrackball.set_stateR   s	     r   c                 :    [         R                  " U5      U l        g)z|Resize the window.

Parameters
----------
size : (float, float)
    The new width and height of the camera image in pixels.
N)r   r   r   )r   r   s     r   resizeTrackball.resize^   s     XXd^
r   c                     [         R                  " U[         R                  S9U l        U R                  U l        U R                  U l        g)zRecord an initial mouse press at a given point.

Parameters
----------
point : (2,) int
    The x and y pixel coordinates of the mouse press.
dtypeN)r   r   float32_pdownr   r   r   r   )r   points     r   downTrackball.downh   s0     hhuBJJ7\\
~~r   c                 <   [         R                  " U[         R                  S9nU[        U SU5      -
  u  p#S[         R                  " U R
                  5      -  nU R                  nU R                  SS2S4   R                  5       nU R                  SS2S4   R                  5       nU R                  SS2S4   R                  5       nU R                  SS2S4   R                  5       n	U R                  [        R                  :X  ah  U* U-  n
[        R                  " XU5      nX4-  n[        R                  " XU5      nUR                  UR                  U R                  5      5      U l        gU R                  [        R                   :X  a  U R
                  S	-  nU R"                  U-
  nX-
  nU[         R$                  R'                  U5      -  nU[         R$                  R'                  U5      -  n[         R(                  " US   US   5      * [         R(                  " US   US   5      -   n[        R                  " UX5      nUR                  U R                  5      U l        gU R                  [        R*                  :X  a  U* S
U-  -  U R,                  -  nU* S
U-  -  U R,                  -  nX&-  X7-  -   nU R                  U-   U l        [         R0                  " S5      nUUSS2S4'   UR                  U R                  5      U l        gU R                  [        R2                  :X  a  [         R$                  R'                  X-
  5      nSnUS:  a6  [         R4                  " [7        U5      SU R
                  S   -  -  5      S-
  nO2US:  a,  S[         R4                  " USU R
                  S   -  -  5      -
  n[         R8                  " U5      * U-  U-  U-  n[         R0                  " S5      nUUSS2S4'   UR                  U R                  5      U l        gg)a  Update the tracball during a drag.

Parameters
----------
point : (2,) int
    The current x and y pixel coordinates of the mouse during a drag.
    This will compute a movement for the trackball with the relative
    motion between this point and the one marked by down().
r*   r-   g333333?Nr	   r   r   r   g       @g      @   r   g      ?      ?)r   r   r,   getattrminr   r   r   flattenr   r   r   r   rotation_matrixdotr   
STATE_ROLLr-   linalgnormarctan2	STATE_PANr   r   eye
STATE_ZOOMexpabssign)r   r.   dxdymindimr   x_axisy_axisz_axisr>   x_angle	x_rot_maty_angle	y_rot_matcenterv_initv_currthetarot_mattranslationt_tfradiusratios                          r   dragTrackball.dragt   se    bjj1 x77rvvdjj))BQBE"**,BQBE"**,BQBE"**,jj!Q'') ;;)000cFlG'77PIkG'77PI$==tzz)BCDL [[I000ZZ#%F[[6)F^FbiinnV44FbiinnV44FZZq	6!955

6!9fUVi8XXE%55eVLG";;tzz2DL [[I///f%3Bf%3B+3K!\\K7DN66!9D%D!QK88DJJ/DL [[I000YY^^CL1FEAvs2w#

1*=>?#EabffR3$**Q-+@%ABB772;,.7&@K66!9D%D!QK88DJJ/DL 1r   c                    U R                   nSnSnUS:  a  X1-  nOUS:  a  SU-  [        U5      -  nU R                  SS2S4   R                  5       nU R                  SS2S4   R                  5       n[        R
                  R                  Xb-
  5      nXG-  U-
  U-  n[        R                  " S5      n	XSS2S4'   U	R                  U R                  5      U l        U R                  SS2S4   R                  5       nU R                  SS2S4   R                  5       n[        R
                  R                  Xb-
  5      nXG-  U-
  U-  n[        R                  " S5      n	XSS2S4'   U	R                  U R                  5      U l	        g)zZoom using a mouse scroll wheel motion.

Parameters
----------
clicks : int
    The number of clicks. Positive numbers indicate forward wheel
    movement.
g?r3   r   Nr	   r   r2   )
r   rA   r   r6   r   r:   r;   r>   r8   r   )
r   clicksr   rU   multrH   r>   rT   rR   rS   s
             r   scrollTrackball.scroll   sd    A:=DaZ%KCK/Dbqb!e$,,.ll2A2q5!))+-}v-7vvay!RaRUxx-BQBE"**,jj!Q'')-}v-7vvay!RaRUXXdjj)
r   c                    U R                   nU R                  SS2S4   R                  5       nUb  Un[        R                  " XU5      nUR                  U R                  5      U l        U R                  SS2S4   R                  5       nUb  Un[        R                  " XU5      nUR                  U R                  5      U l        g)zRotate the trackball about the "Up" axis by azimuth radians.

Parameters
----------
azimuth : float
    The number of radians to rotate.
Nr	   r   )r   r   r6   r   r7   r8   r   )r   azimuthaxisr   rG   rJ   s         r   rotateTrackball.rotate   s     bqb!e$,,.F#33GVL	 }}T\\2BQBE"**,F#33GVL	]]4::.
r   )r   r   r-   r   r   r   r   r   )N)__name__
__module____qualname____firstlineno____doc__r   r=   r9   r?   r   propertyr   r$   r'   r/   rV   r[   r`   __static_attributes__ r   r   r   r   !   sT    PLIJJ"-H  
$
&D0L *D/r   r   )rf   numpyr    r   r   ri   r   r   <module>rl      s   4 9  O/ O/r   