o
    iX                     @   sB   d dl mZ d dlmZ d dlmZmZmZm	Z	 G dd dZ
dS )    N)get_spherical_rotatation)get_model_matrixmodel_to_screenscreen_to_modelvec_subsc                   @   s   e Zd ZdZdZdZdZdZdZddd	d
dZ	d'ddZ
dd Zdd Zdd Zdd Zdd Zdd Zdd Zd(ddZd d! Zd"d# Zd$d% Zd&S ))
PlotCamerag?g     @@g      Y@g     @g      @g     @)r   r   r   )ir   r   )r   Z   r   )r   r	   )ZxyxzZyzZperspectiveFc                 C   s$   || _ | j jj| _|| _|   d S N)windowZplotZaxesorthoreset)selfr   r    r   t/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/sympy/plotting/pygletplot/plot_camera.py__init__   s   zPlotCamera.__init__c                 C   s$   t   t   t | _t   d S r   )pglglPushMatrixglLoadIdentityr   _rotglPopMatrixr   r   r   r   init_rot_matrix   s   zPlotCamera.init_rot_matrixc                 C   sh   |    || jvrtd| | j| }| |d ddd | |d ddd | |d ddd d S )Nz"%s is not a valid rotation preset.r         )r   rot_presets
ValueErroreuler_rotate)r   Zpreset_namerr   r   r   set_rot_preset%   s   

zPlotCamera.set_rot_presetc                 C   s<   d| _ d\| _| _d | _| jr| j| _ n| j| _ |   d S )N        )r!   r!   )_dist_x_yr   r   _default_ortho_dist_default_distr   r   r   r   r   r   /   s   
zPlotCamera.resetc                 C   s2   t   t | t | j t | _t   d S r   )r   r   glLoadMatrixfglMultMatrixfr   r   r   )r   Zrotr   r   r   mult_rot_matrix9   s
   
zPlotCamera.mult_rot_matrixc                 C   s   t t j t   | jr&t dt| jjt| jj	 | j
d | jd  nt dt| jjt| jj	 | jd | jd  t t j d S )Ng333333?g{Gz?g      >@)r   ZglMatrixModeZGL_PROJECTIONr   r   ZgluPerspectivefloatr   widthheightmin_ortho_distmax_ortho_distmin_distmax_distZGL_MODELVIEWr   r   r   r   setup_projection@   s   zPlotCamera.setup_projectionc                 C   s   dS )N)      ?r2   r2   r   r   r   r   r   
_get_scaleN   s   zPlotCamera._get_scalec                 C   sF   t   t | j| j| j  | jd urt | j t j| 	   d S r   )
r   r   glTranslatefr#   r$   r"   r   r(   ZglScalefr3   r   r   r   r   apply_transformationQ   s
   
zPlotCamera.apply_transformationr2   c                 C   s2   t ||| jj| jj|}|d ur| | d S d S r   )r   r   r+   r,   r)   )r   p1p2sensitivitymatr   r   r   spherical_rotateX   s   zPlotCamera.spherical_rotatec                 C   s8   t   t | j t |||| t | _t   d S r   )r   r   r'   r   Z	glRotatefr   r   )r   Zanglexyzr   r   r   r   ^   s
   zPlotCamera.euler_rotatec                 C   sd   | j r|| d }| j}| j}n
|| }| j}| j}| j| }|dk r'||k s+||kr0|| _d S d S )Ng      I@r   )r   r-   r.   r/   r0   r"   )r   Zclicksr8   Zdist_dr/   r0   Znew_distr   r   r   zoom_relativee   s   

zPlotCamera.zoom_relativec                 C   s   t   t   t dd| j  tdddd }tt|||t|| || |}t   |  j	|d 7  _	|  j
|d 7  _
d S )Nr   r   r   )r   r   r   r4   r"   r   r   r   r   r#   r$   )r   r;   r<   ZdxZdyr=   dr   r   r   mouse_translatet   s   "zPlotCamera.mouse_translateN)F)r2   )__name__
__module____qualname__r/   r0   r-   r.   r&   r%   r   r   r   r    r   r)   r1   r3   r5   r:   r   r>   r@   r   r   r   r   r      s0    



r   )Z	pyglet.glglr   Z'sympy.plotting.pygletplot.plot_rotationr   Zsympy.plotting.pygletplot.utilr   r   r   r   r   r   r   r   r   <module>   s    