
    h                     ,    S r SSKrSSKr " S S5      rg)z7geomath.py: transcription of GeographicLib::Math class.    Nc                       \ rS rSrSr\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       r\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rSrg)Math   z-
Additional math routines for GeographicLib.
c                 
    X -  $ )zSquare a number xs    hC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geographiclib/geomath.pysqMath.sq   s     5L    c                 l    [         R                  " [         R                  " [        U 5      S5      U 5      $ )zReal cube root of a numbergUUUUUU?)mathcopysignpowabsr   s    r
   cbrt	Math.cbrt   s$     ==#a&%0!44r   c                     S[         R                  s=::  a  S:  aB  O  O?[        R                  " [        R                  U 5      [        R                  U5      -   5      O[        R                  " X5      nX-  X-  4$ )z Private: Normalize a two-vector.)      )r   
   )sysversion_infor   sqrtr   r   hypot)r	   yrs      r
   norm	Math.norm"   s\     c&&00 
4771:
*	+ jj  38Or   c                 N    X-   nX!-
  nX#-
  nX0-  nXA-  nUS:X  a  UOSX4-   -
  nX%4$ )z#Error free transformation of a sum.r           r   )uvsupvppts         r
   sumMath.sum/   sD     	
A	
B
&CGBHC!V)A 4Kr   c                 p    [        U S:  a  SOX   5      nU S:  a  U S-  oS-  nXC-  X   -   nU S:  a  M  U$ )zEvaluate a polynomial.r      )float)Npr%   r	   r   s        r
   polyvalMath.polyval?   sK     	1q5aad#A
a%1fa1fa
%!$,a a% Hr   c                 `    Sn[        U 5      nX!:  a  XU-
  -
  n[        R                  " X 5      $ )z?Private: Round an angle so that small values underflow to zero.g      ?)r   r   r   )r	   zr   s      r
   AngRoundMath.AngRoundI   s0     	AAAu!1u+a==r   c                     [         R                  " U 5      (       a  [         R                  " X5      $ [         R                  $ )z*remainder of x/y in the range [-y/2, y/2].)r   isfinite	remaindernanr	   r   s     r
   r8   Math.remainderX   s*     $(==#3#34>>!AAr   c                 ~    [         R                  U S5      n[        U5      S:X  a  [        R                  " SU 5      $ U$ )zreduce angle to [-180,180]h     g     f@)r   r8   r   r   r   r:   s     r
   AngNormalizeMath.AngNormalize^   s4     	q#A&)!fm4=="::r   c                 D    [        U 5      S:  a  [        R                  $ U $ )z&replace angles outside [-90,90] by NaNZ   )r   r   r9   r   s    r
   LatFixMath.LatFixe   s     1v{488))r   c                 N   [         R                  [         R                  U * S5      [         R                  US5      5      u  p#[         R                  [         R                  US5      U5      u  p#US:X  d  [        U5      S:X  a!  [        R
                  " X#S:X  a  X-
  OU* 5      nX#4$ )z1compute y - x and reduce to [-180,180] accuratelyr=   r   r>   )r   r)   r8   r   r   r   )r	   r   dr(   s       r
   AngDiffMath.AngDiffk   s}     88DNNA2s+T^^As-CDDA88DNN1c*A.DAAvQ3
--F15
3a4Kr   c                    [         R                  " U 5      (       a  [         R                  " U S5      O[         R                  n[         R                  " U5      (       a  SO[        [        US-  5      5      nUSU-  -  n[         R                  " U5      n[         R                  " U5      n[         R                  " U5      nUS-  nUS:X  a  XC* pCOUS:X  a  U* U* pCO
US:X  a  U* UpCUS-   nUS:X  a  [         R                  " X05      nX44$ )	z(Compute sine and cosine of x in degrees.r=   r   rB      r,      r   r"   )r   r7   fmodr9   isnanintroundradianssincosr   )r	   r   qr%   cs        r
   sincosdMath.sincosdu   s     "]]1--		!S488AZZ]]E!b&M 2AaKAT\\!_A!Q	AA	
aBA	
aQBA	
aQA	CAAv4==&q4Kr   c                    [         R                  " U 5      (       a  [        [        U S-  5      5      OSnU SU-  -
  n[         R                  " [
        R                  X1-   5      5      n[         R                  " U5      n[         R                  " U5      nUS-  nUS:X  a  XT* pTOUS:X  a  U* U* pTO
US:X  a  U* UpTUS-   nUS:X  a  [         R                  " X@5      nXE4$ )zCCompute sine and cosine of (x + t) in degrees with x in [-180, 180]rB   r   rJ   r,   rK   r   r"   )
r   r7   rN   rO   rP   r   r4   rQ   rR   r   )r	   r(   rS   r   r%   rT   s         r
   sincosdeMath.sincosde   s     #mmA..E!b&MAA	BF
AT]]15%9:AA!Q	AA	
aBA	
aQBA	
aQA	CAAv4==&q4Kr   c                 &   [        U 5      [        U5      :  a  So UpOSnUS:  a  US-  o!* n[        R                  " [        R                  " X5      5      nUS:X  a  [        R                  " SU 5      U-
  nU$ US:X  a  SU-
  nU$ US:X  a  SU-   nU$ )z.compute atan2(y, x) with the result in degreesrK   r   r,   r>   rB   r   i)r   r   degreesatan2r   )r   r	   rS   angs       r
   atan2dMath.atan2d   s     1vA
aq
a1u1fa"a
,,tzz!'
(C	
at}}S!,s2 J 
abmJ 
aSs]Jr   r   N)__name__
__module____qualname____firstlineno____doc__staticmethodr   r   r   r)   r0   r4   r8   r?   rC   rG   rU   rX   r^   __static_attributes__r   r   r
   r   r      s     
 5 5
 
 
       B B
 ; ; * *
        r   r   )rd   r   r   r   r   r   r
   <module>rg      s    =  Q Qr   