§
    gv»jT  ã                  óF   — d Z ddlmZ ddlZdd
„Zdd„Zdd„Zdd„Zdd„ZdS )z°
FreeExile Common Mathematical Utilities.
Pure, stateless mathematical and spatial calculation functions.
High performance, zero-allocation, suitable for real-time game loops.
é    )ÚannotationsNÚx1ÚfloatÚy1Úx2Úy2Úreturnc                ó8   — t          j        | |z
  ||z
  ¦  «        S )z4Calculates 2D Euclidean distance between two points.)ÚmathÚhypot)r   r   r   r   s       ú1C:\Projects\FreeExile\server\common\math_utils.pyÚeuclidean_distance_2dr      s   € åŒ:�b˜2‘g˜r B™wÑ'Ô'Ð'ó    c                ó,   — | |z
  }||z
  }||z  ||z  z   S )zRCalculates squared 2D Euclidean distance (avoids costly sqrt in proximity checks).© )r   r   r   r   ÚdxÚdys         r   Úeuclidean_distance_squared_2dr      s'   € à	ˆb‰€BØ	ˆb‰€BØ�‰7�R˜"‘WÑÐr   ÚradiusÚboolc                ó4   — t          | |||¦  «        ||z  k    S )zRFast check whether two points are within a circular radius using squared distance.)r   )r   r   r   r   r   s        r   Úis_within_radius_2dr      s   € å(¨¨R°°RÑ8Ô8¸VÀf¹_ÒMÐMr   ÚvalÚmin_valÚmax_valc                ó&   — | |k     r|S | |k    r|S | S )z2Clamps a numeric value between [min_val, max_val].r   )r   r   r   s      r   Úclampr      s#   € à
ˆW‚}€}ØˆØ
ˆW‚}€}ØˆØ€Jr   ÚaÚbÚtc                ó:   — t          |dd¦  «        }| || z
  |z  z   S )zILinear interpolation between a and b by factor t (clamped to [0.0, 1.0]).g        g      ð?)r   )r   r   r    Ú	clamped_ts       r   Úlerpr#   %   s'   € å�a˜˜cÑ"Ô"€IØ��A‘˜Ñ"Ñ"Ð"r   )
r   r   r   r   r   r   r   r   r	   r   )r   r   r   r   r   r   r   r   r   r   r	   r   )r   r   r   r   r   r   r	   r   )r   r   r   r   r    r   r	   r   )	Ú__doc__Ú
__future__r   r   r   r   r   r   r#   r   r   r   ú<module>r&      sž   ððð ð #Ð "Ð "Ð "Ð "Ð "Ø €€€ð(ð (ð (ð (ð
ð ð ð ðNð Nð Nð Nð
ð ð ð ð#ð #ð #ð #ð #ð #r   