Ñò
‡FuPc           @   s�   d  d k  Z  d  d k l Z d  d k l Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z d S(   iÿÿÿÿN(   t   pi(   t#   DEFAULT_GUN_PITCH_LIMITS_TRANSITIONc         C   sÖ   | d } | i  d ƒ } | i  d ƒ } | d  j o | d  j o | S| d  j o | d | d d f } n | d  j o | d | d d f } n | i  d ƒ } | d  j o
 t } n t i |  | | | | ƒ S(   Nt   basict   frontt   backi    i   g        t
   transition(   t   gett   NoneR   t   BigWorldt   wg_calcGunPitchLimits(   t	   turretYawt   pitchLimitsDesct   basicLimitst   frontLimitst
   backLimitsR   (    (    s%   scripts/common/gun_rotation_shared.pyt   calcPitchLimitsFromDesc   s$    

c         C   s)   t  |  h | d 6| d 6| d 6| d 6ƒ S(   NR   R   R   R   (   R   (   R
   R   R   R   R   (    (    s%   scripts/common/gun_rotation_shared.pyt   calcPitchLimits$   s    c         C   s6   d | >d } t  t | d |  t t d ƒ ƒ | @S(   Ni   g       @(   t   intt   roundR    (   t   anglet   bitst   mask(    (    s%   scripts/common/gun_rotation_shared.pyt   encodeAngleToUint*   s    c         C   s   t  d |  d | >t  S(   Ng       @i   (   R    (   t   codeR   (    (    s%   scripts/common/gun_rotation_shared.pyt   decodeAngleFromUint0   s    c         C   sJ   |  | | | } t  d | d ƒ } d | >d } t t | | ƒ ƒ | @S(   Ng        g      ð?i   (   t   _clampR   R   (   R   R   t   minBoundt   maxBoundt   tR   (    (    s%   scripts/common/gun_rotation_shared.pyt   encodeRestrictedAngleToUint5   s    c         C   s(   t  |  ƒ d | >d } | | | | S(   Ni   (   t   float(   R   R   R   R   R   (    (    s%   scripts/common/gun_rotation_shared.pyt   decodeRestrictedAngleFromUint=   s    c         C   s!   t  |  d ƒ d >t | d | Œ BS(   Ni
   i   (   R   R   (   t   yawt   pitcht   pitchLimits(    (    s%   scripts/common/gun_rotation_shared.pyt   encodeGunAnglesG   s    c         C   s+   t  |  d ?d @d ƒ t |  d @d | Œ f S(   Ni   iÿ  i
   i?   (   R   R   (   R   R"   (    (    s%   scripts/common/gun_rotation_shared.pyt   decodeGunAnglesO   s    c         C   s(   | |  j  o |  S| | j o | S| S(   N(    (   R   t   valueR   (    (    s%   scripts/common/gun_rotation_shared.pyR   U   s    (   R   t   mathR    t	   constantsR   R   R   R   R   R   R   R#   R$   R   (    (    (    s%   scripts/common/gun_rotation_shared.pyt   <module>   s   						
		