³ò
àŸÔPc           @   s   d  d k  Z  d „  Z d „  Z d e f d „  ƒ  YZ d „  Z d d „ Z d	 „  Z d
 „  Z d „  Z	 d „  Z
 e d „ Z e d „ Z e Z d S(   iÿÿÿÿNc         c   sQ   t  d „  |  Dƒ ƒ } x4 |  D], } | t | ƒ } t | ƒ d g | Vq Wd S(   s   
Converts a list of iterables such that they become lists with as many
items as is in the longest list by appending extra 0 items to them.
    c         s   s   x |  ] } t  | ƒ Vq Wd  S(   N(   t   len(   t   .0t   x(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>   s    i    N(   t   maxR    t   list(   t	   sequencest   maxlenR   t   l(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   nullseq   s
     c          G   s   t  t |  ƒ Œ  S(   sž   
The same as built-in zip function except instead of truncating
to the shortest sequence, zeroes are added to respect the length of the longest
sequence.
    (   t   zipR   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   nullzip   s    t   Vectorc           B   s”  e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z d „  Z e Z d „  Z d „  Z e Z d „  Z e Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d „  Z# d  „  Z$ d! „  Z% e& d" „  d# „  d+ d$ ƒ Z( e& d% „  d& „  d+ d' ƒ Z) e& d( „  d) „  d+ d* ƒ Z* RS(,   s–  
Spatial Vector in Cartesian space.

Creating a new vector can be done in one of the following ways:
    - passing a sequence of numbers:
        myvec = vecmath.Vector( [1, 2, 3] )
    - passing numbers as separate arguments:
        myvec = vecmath.Vector(1, 2, 3)
    - passing so called "vectorstring":
        myvec = vecmath.Vector("1.000000,2.000000,3.000000")
    - passing Source entity Keyvalues vector value:
        myvec = vecmath.Vector("1.000000 2.000000 3.000000")

The first three values can be overridden with keyword arguments x, y and z:
    myvec = vecmath.Vector(sequence, x=500)
    myvec = vecmath.Vector(sequence, y=-2.7, z=0, x=42)
    c   
      O   sá  t  | ƒ d j o. g  } | D] } | t | ƒ q ~ |  _ nt  | ƒ d j oë | d } t | ƒ i d j o t | ƒ } n y. g  } | D] } | t | ƒ q’ ~ |  _ WqQt j
 oF g  } | i d d ƒ i d ƒ D] } | t | ƒ qã ~ |  _ qQt	 j
 o) t	 d t | ƒ i t
 | ƒ f ‚ qQXn d d d g |  _ | o… yM d } x@ d D]8 }	 |	 | j o t | |	 ƒ |  i | <n | d 7} qhWWqÝt	 d
 t | |	 ƒ i t
 | |	 ƒ f ‚ qÝXn d S(   sN   
Initializes a new Vector instance, see class documentation for info.
        i   i    t	   generatort    t   ,s%   Invalid data type %s (%s) for vector.R   t   yt   zs1   Invalid data type %s (%s) in override for vector.N(   R   R   R   (   R    t   floatt   vlt   typet   __name__t   tuplet
   ValueErrort   replacet   splitt	   TypeErrort   str(
   t   selft   argst   kwt   _[1]R   R   t   _[2]t   _[3]t   compvalt   comp(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __init__3   s2    .
.C% c         C   s   d t  |  i ƒ S(   s,    Returns a string representation of itself. s
   Vector(%s)(   R   R   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __repr__Q   s    c         C   s   t  |  i ƒ S(   s"    Converts the vector into a list. (   R   R   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __list__U   s    c         C   s   t  t d |  i ƒ ƒ S(   s  
Converts the vector into a dictionary with at most three components.

By convention these components are named "x", "y" and "z",
if the vector has more components, the rest are discarded,
if the vector has less components, then items from the dictionary are omitted.
        t   xyz(   t   dictR	   R   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   getdictY   s    c         C   s
   |  i  ƒ  S(   sm   
Returns the vector info as a vectorstring.

An example return value is "0.000000,0.000000,0.000000"
        (   t   getstr(   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __str__c   s    R   c         C   s   | i  d „  |  i Dƒ ƒ S(   sÏ   
Returns a string representation of the vector with specified separator.

By default the separator is "," to produce a vectorstring
"0.000000,0.000000,0.000000", but can be changed to be any string.
        c         s   s   x |  ] } d  | Vq Wd S(   s   %0.6fN(    (   R   t   v(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>r   s    (   t   joinR   (   R   t   sep(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyR)   k   s    c         C   s   t  |  i ƒ S(   sF    Returns the dimension of the vector (i.e. the number of components). (   R    R   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __len__t   s    c         C   s   t  d „  t |  | ƒ Dƒ ƒ S(   s3  
Adds two vectors mathematically.

If the vectors are not of the same dimension, the lesser dimensioned vector
is assumed to have values of zero for the missing dimensions.

The simplified formula of vector addition is:
vector1 + vector2 == (x1, y1, z1) + (x2, y2, z2) = (x1 + x2, y1 + y2, z1 + z2)
        c         s   s#   x |  ] \ } } | | Vq Wd  S(   N(    (   R   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>‚   s    (   R   R
   (   R   t   vl2(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __add__x   s    
c         C   s;   g  } t  |  | ƒ D] \ } } | | | q ~ |  _ |  S(   sB  
Adds another vector to this one mathematically.

If the vectors are not of the same dimension, the lesser dimensioned vector
is assumed to have values of zero for the missing dimensions.

The simplified formula of vector addition is:
vector1 + vector2 == (x1, y1, z1) + (x2, y2, z2) = (x1 + x2, y1 + y2, z1 + z2)
        (   R
   R   (   R   R/   R   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __iadd__„   s    
7c         C   s   t  d „  t |  | ƒ Dƒ ƒ S(   s;  
Subtracts two vectors mathematically.

If the vectors are not of the same dimension, the lesser dimensioned vector
is assumed to have values of zero for the missing dimensions.

The simplified formula of vector subtraction is:
vector1 - vector2 == (x1, y1, z1) - (x2, y2, z2) = (x1 - x2, y1 - y2, z1 - z2)
        c         s   s#   x |  ] \ } } | | Vq Wd  S(   N(    (   R   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>›   s    (   R   R
   (   R   R/   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __sub__‘   s    
c         C   s;   g  } t  |  | ƒ D] \ } } | | | q ~ |  _ |  S(   sM  
Subtracts another vectors from this one mathematically.

If the vectors are not of the same dimension, the lesser dimensioned vector
is assumed to have values of zero for the missing dimensions.

The simplified formula of vector subtraction is:
vector1 - vector2 == (x1, y1, z1) - (x2, y2, z2) = (x1 - x2, y1 - y2, z1 - z2)
        (   R
   R   (   R   R/   R   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __isub__   s    
7c            sW   y t  |  ˆ  ƒ } Wn- t j
 o! t ‡  f d †  |  Dƒ ƒ Sn Xt d „  | Dƒ ƒ S(   s®  
Multiplies the vector by a scalar or by each component of another vector and
returns the resulting vector.

When used with a scalar, the length of the vector is multiplied with the scalar
while retaining the direction (unless the value is negative).
The simplified formula of scalar multiplication is:
vector * scalar == (x, y, z) * a = (x * a, y * a, z * a)

When used with another vector (any sequence with numerical items is OK),
the result is an uncommon vector resulted in multiplying the vectors by each
component separately.
The simplified formula for by-component vector multiplication is:
vector1 * vector2 == (x1, y1, z1) * (x2, y2, z2) = (x1 * x2, y1 * y2, z1 * z2)
        c         3   s   x |  ] } ˆ  | Vq Wd  S(   N(    (   R   R   (   t   value(    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>½   s    c         s   s#   x |  ] \ } } | | Vq Wd  S(   N(    (   R   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>¾   s    (   R
   R   R   (   R   R4   t   testzip(    (   R4   sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __mul__ª   s
    c         C   s†   yA t  |  | ƒ } g  } | D] \ } } | | | q ~ |  _ Wn> t j
 o2 x- t |  ƒ D] \ } } | | |  | <q_ Wn X|  S(   sŽ  
Multiplies this vector by a scalar or by each component of another vector.

When used with a scalar, the length of the vector is multiplied with the scalar
while retaining the direction (unless the value is negative).
The simplified formula of scalar multiplication is:
vector * scalar == (x, y, z) * a = (x * a, y * a, z * a)

When used with another vector (any sequence with numerical items is OK),
the result is an uncommon vector resulted in multiplying the vectors by each
component separately.
The simplified formula for by-component vector multiplication is:
vector1 * vector2 == (x1, y1, z1) * (x2, y2, z2) = (x1 * x2, y1 * y2, z1 * z2)
        (   R
   R   R   t	   enumerate(   R   R4   R5   R   R   R   t   indext   current_value(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __imul__Á   s    2 c            sW   y t  |  ˆ  ƒ } Wn- t j
 o! t ‡  f d †  |  Dƒ ƒ Sn Xt d „  | Dƒ ƒ S(   sx  
Divides the vector by a scalar or by each component of another vector.

When used with a scalar, the length of the vector is divided with the scalar
while retaining the direction (unless the value is negative).
The simplified formula of scalar division is:
vector / scalar == (x, y, z) / a = (x / a, y / a, z / a)

When used with another vector (any sequence with numerical items is OK),
the result is an uncommon vector resulted in dividing the vectors by each
component separately.
The simplified formula for by-component vector division is:
vector1 / vector2 == (x1, y1, z1) / (x2, y2, z2) = (x1 / x2, y1 / y2, z1 / z2)
        c         3   s   x |  ] } | ˆ  Vq Wd  S(   N(    (   R   R   (   R4   (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>ê   s    c         s   s#   x |  ] \ } } | | Vq Wd  S(   N(    (   R   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>ë   s    (   R
   R   R   (   R   R4   R5   (    (   R4   sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __div__Ø   s
    c            sW   y t  |  ˆ  ƒ } Wn- t j
 o! t ‡  f d †  |  Dƒ ƒ Sn Xt d „  | Dƒ ƒ S(   sx  
Divides the vector by a scalar or by each component of another vector.

When used with a scalar, the length of the vector is divided with the scalar
while retaining the direction (unless the value is negative).
The simplified formula of scalar division is:
vector / scalar == (x, y, z) / a = (x / a, y / a, z / a)

When used with another vector (any sequence with numerical items is OK),
the result is an uncommon vector resulted in dividing the vectors by each
component separately.
The simplified formula for by-component vector division is:
vector1 / vector2 == (x1, y1, z1) / (x2, y2, z2) = (x1 / x2, y1 / y2, z1 / z2)
        c         3   s   x |  ] } | ˆ  Vq Wd  S(   N(    (   R   R   (   R4   (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>   s    c         s   s#   x |  ] \ } } | | Vq Wd  S(   N(    (   R   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>  s    (   R
   R   R   (   R   R4   R5   (    (   R4   sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __idiv__î   s
    c         C   se   t  | t ƒ o t |  i | ƒ Sn= d i t | ƒ ƒ } | d j o |  i | Sn |  i | Sd S(   sÓ   
Returns the value of the specified vector component.

Valid indexes are integer indexes < dimension of the vector and
special keywords "x", "y" and "z" which resolve to indexes 0, 1 and 2
respectively.
        R&   i    N(   t
   isinstancet   sliceR   R   t   findR   (   R   R8   t   sindex(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __getitem__  s    c         C   s’   t  | t ƒ o2 g  } | D] } | t | ƒ q ~ |  i | <nM d i t | ƒ ƒ } | d j o t | ƒ |  i | <n t | ƒ |  i | <d S(   sÔ   
Replaces the value of the specified vector component.

Valid indexes are integer indexes < dimension of the vector and
special keywords "x", "y" and "z" which resolve to indexes 0, 1 and 2
respectively.
        R&   i    N(   R=   R>   R   R   R?   R   (   R   R8   R4   R   R   R@   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __setitem__  s    2c         C   s   |  i  | =d S(   s‚   
Deletes a component off the vector.

This reduces the dimension of the vector by 1 and reorders the adjacent
components.
        N(   R   (   R   R8   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __delitem__&  s    c         C   s   | |  i  j S(   sC   
Tests if the given value is one of the vector components.
        (   R   (   R   R4   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __contains__/  s    c         C   s   |  i  | i  j S(   s½   
Test the equality of two vectors.

The vectors are considered to be equal when they have the same number of
components and all the respective components of both vectors are equal.
        (   R   (   R   t   vec2(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __eq__5  s    c         C   s   |  i  | i  j S(   sâ   
Test the inequality of two vectors.

The vectors are considered to be equal when they have the same number of
components and all the respective components of both vectors are equal.
The vectors are inequal otherwise.
        (   R   (   R   RE   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __ne__>  s    c         C   s   t  d „  |  i Dƒ ƒ S(   s³   
Negates the vector.

The negation happens by negating all of the components separately.
The simplified formula of negating a vector:
-vector == -(x, y, z) = (-x, -y, -z)
        c         s   s   x |  ] } | Vq Wd  S(   N(    (   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>P  s    (   R   R   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __neg__H  s    c         C   s   t  |  i ƒ S(   sL   
Returns an iterator to loop through every component of the vector.
        (   t   iterR   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __iter__R  s    c         C   s   t  |  i ƒ S(   sP   
Returns an iterator to loop through every component in reversed order.
        (   t   reversedR   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   __reversed__X  s    c         C   s   t  |  i ƒ S(   s0   
Returns a new identical vector object.
        (   R   R   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   copy^  s    c         C   s   t  d „  t |  | ƒ Dƒ ƒ S(   s-  
Calculates the dot product (inner product with Cartesian space Spatial vectors).

Also known as Scalar product, the definition of inner product is:
a . b = |a|*|b|*cos(a,b)

The simplified formula for dot product is:
vector1.ip(vector2) == (x1, y1, z1) . (x2, y2, z2) = x1*x2 + y1*y2 + z1*z2
        c         s   s#   x |  ] \ } } | | Vq Wd  S(   N(    (   R   t   at   b(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>n  s    (   t   sumR	   (   R   RE   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   ipd  s    
c         C   s—   t  |  ƒ d j p t  | ƒ d j o t d ‚ n t |  d | d |  d | d |  d | d |  d | d |  d | d |  d | d ƒ S(   s}  
Calculates the cross product of two three-dimensional vectors.

The cross product is defined as:
a x b = |a|*|b|*sin(a,b)*u
where u is a unit vector pointing to a direction perpendicular to both vectors.
In other words, the result is a vector that points to a direction perpendicular
to both of the original vectors, creating a normal for the plane defined by the
two vectors. The length of the resulting vector is equal to the area of a
parallelogram created using those two vectors.

The formula used here for cross product is:
vector1.cp(vector 2) == (x1, y1, z1) x (x2, y2, z2)
    = (y1*z2-z1*y2, z1*x2-x1*z2, x1*y2-y1*x2)
        i   sE   Cross product can only be calculated for vectors of three dimensions.i   i   i    (   R    R   R   (   R   RE   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   cpp  s    &c         C   sW   y1 t  i |  i | ƒ |  i ƒ  t i | ƒ ƒ SWn t j
 o t d ƒ ‚ n Xd S(   s:    Calculates the angle between the two vectors in radians. s&   Cannot calculate angle for zero vectorN(   t   matht   acosRQ   t   lengthR   t   ZeroDivisionError(   R   RE   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   angleˆ  s    1c         C   sÖ   t  |  ƒ d j p t  | ƒ d j o t d ‚ n t i |  d |  d ƒ t i | d | d ƒ } t i |  d |  d ƒ t i | d | d ƒ } t i |  d |  d ƒ t i | d | d ƒ } | | | f S(   s  
Creates projections of the two vectors to the three planes (xy, yz, xz) and
calculates the angles between the projected vectors for each.

The returned value is a three-tuple containing the values in following order:
(yz, xz, xy). The returned angles are measured in radians.
        i   sG   Multiple angles can only be calculated for vectors of three dimensions.i   i   i    (   R    R   RS   t   atan2(   R   RE   t   axt   ayt   az(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   angles  s    &222c         C   s   t  d „  |  Dƒ ƒ d S(   s©   
Returns the length/magnitude of the vector.

The simplified formula of calculating a vector length is:
length(vector) == |(x, y, z)| = sqrt(x**2 + y**2 + z**2)
        c         s   s   x |  ] } | | Vq Wd  S(   N(    (   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>¥  s    g      à?(   RP   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyRU   ž  s    c         C   s   |  | |  i  ƒ  S(   sT   
Returns a new vector that has the same direction but the specified length.
        (   RU   (   R   t	   newlength(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt	   setlength§  s    c         C   s   |  i  d ƒ S(   sU   
x.normalize()

    Returns a new vector that is the vector x with length 1.
        i   (   R^   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt	   normalize­  s    c         C   s   |  i  d  ƒ S(   i    (   RA   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   <lambda>·  s    c         C   s   |  i  d  | ƒ S(   i    (   RB   (   R   R4   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyR`   ¸  s    s!   X coordinate value of the vector.c         C   s   |  i  d  ƒ S(   i   (   RA   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyR`   ¼  s    c         C   s   |  i  d  | ƒ S(   i   (   RB   (   R   R4   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyR`   ½  s    s!   Y coordinate value of the vector.c         C   s   |  i  d  ƒ S(   i   (   RA   (   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyR`   Á  s    c         C   s   |  i  d  | ƒ S(   i   (   RB   (   R   R4   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyR`   Â  s    s!   Z coordinate value of the vector.N(+   R   t
   __module__t   __doc__R#   R$   R%   R(   R*   R)   R.   R0   R1   R2   R3   R6   t   __rmul__R:   R;   t   __truediv__R<   t   __itruediv__RA   RB   RC   RD   RF   RG   RH   RJ   RL   RM   RQ   RR   RW   R\   RU   R^   R_   t   propertyt   NoneR   R   R   (    (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyR       sf   				
																			
	
														c         C   s   t  |  ƒ t  | ƒ i ƒ  S(   s*    Returns the distance between two points. (   R   RU   (   t   coord1t   coord2(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   distanceÈ  s    g        c   	      C   s­   | d |  d } | d |  d } | d |  d } t  i | | ƒ } t  i t  i | | ƒ ƒ } t  i t  i | | ƒ ƒ } | d j  o | d 7} n | | t | ƒ f S(   sÓ   
Returns tuple (pitch, yaw, roll) showing in which direction coord2 is from coord1.

The roll value cannot be determined by the vectors, so you will need to pass
it as an optional parameter (defaults to 0).
    i   i    i   ih  (   RS   t   hypott   degreesRX   R   (	   t   v1t   v2t   rollt   heightt   xlt   ylt   xylent   pitcht   yaw(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt
   viewanglesÌ  s    c         C   s“   t  |  ƒ } t i t i | d ƒ ƒ } t i d | d ƒ } | t i t i | d ƒ ƒ } | t i t i | d ƒ ƒ } t  | | | f ƒ S(   sl   
Creates a vector of undefined length pointing to the direction specified as (pitch, yaw, roll) object.
    i    i   i   (   R   RS   t   sint   radianst   sqrtt   cos(   t   vat   vanglesR   RN   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt
   viewvectorÝ  s      c         C   su   d „  t  | | ƒ Dƒ } d „  t  | | ƒ Dƒ } x< |  D]4 } | | i ƒ  j  p | | i ƒ  j o t Sq9 q9 Wt S(   sX   
Checks if a point is between a rectangular area specified by two opposite corners.
    c         s   s   x |  ] } t  | ƒ Vq Wd  S(   N(   t   min(   R   t   comps(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>ì  s    c         s   s   x |  ] } t  | ƒ Vq Wd  S(   N(   R   (   R   R   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys	   <genexpr>í  s    (   R	   t   nextt   Falset   True(   t   whatt   corner1t   corner2t   min_itert   max_itert   i(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   isbetweenRectè  s     &c         C   s'  t  |  ƒ } t  | ƒ } t  | ƒ } | | j p | | j o t Sn | | j o t Sn | d | d | d | d | d | d | d | d j o‡ | d | d | d | d | d | d | d | d j oB | d | d | d | d | d | d | d | d j S(   sE    Checks if a point is truly between a segment created by two points. i    i   i   (   R   R‚   R   (   Rƒ   R„   R…   R+   t   c1t   c2(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   isbetweenVectó  s    EEc   
      C   s“   t  |  ƒ } t  | ƒ } t  | ƒ } | | j o t d | i d ƒ ‚ n | | } | | } | t | | ƒ t | | ƒ } | | }	 |	 i ƒ  S(   sI    Returns the distance of point from a line specified by two coordinates. s.   Identical points (%s) cannot form unique line.s   , (   R   R   R)   RQ   RU   (
   t   pointt   line_coord1t   line_coord2t   cRN   RO   t   pt   st   tt   d(    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   distance_from_line   s    

 
c         C   sJ  t  |  ƒ } t  | ƒ } t  | ƒ } | | j o t d | i d ƒ ‚ n | | } | | } t | | ƒ }	 |	 d j oJ | p5 t d | i d ƒ | i d ƒ | i d ƒ f ‚ n | i ƒ  Sn t | | ƒ }
 |
 |	 j oM | p5 t d | i d ƒ | i d ƒ | i d ƒ f ‚ n t | | ƒ Sn | | |	 |
 } | i ƒ  S(   s«   
Returns the distance of point from a segment between start and end points.

If allow_outside is False, then ValueError is raised if the point is outside the segment.
    s.   Identical points (%s) cannot form unique line.s   , i    s6   Point (%s) is behind the starting point of (%s) - (%s)s4   Point (%s) is behind the ending point of (%s) - (%s)(   R   R   R)   RQ   RU   Rj   (   R   t   startt   endt   allow_outsideR   RN   RO   R‘   R’   t   spt   lpR”   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   distance_from_segment  s,    

//c         C   sð   t  |  ƒ } t  | ƒ } t  | ƒ } | | j o t d | i d ƒ ‚ n | | } | | } t | | ƒ }	 |	 d j oJ | p5 t d | i d ƒ | i d ƒ | i d ƒ f ‚ n | i ƒ  Sn t | | ƒ }
 | | |	 |
 } | i ƒ  S(   sà   
Returns the distance of "point" from a ray starting from "start" point and then
continuing indefinitely passing "line_coord".

If allow_outside is False, then ValueError is raised if the point is behind starting point.
    s.   Identical points (%s) cannot form unique line.s   , i    sD   Point (%s) is behind the starting point of the ray from (%s) by (%s)(   R   R   R)   RQ   RU   (   R   R–   t
   line_coordR˜   R   RN   RO   R‘   R’   R™   Rš   R”   (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pyt   distance_from_ray.  s"    

/(   RS   R   R
   t   objectR   Rj   Rv   R}   R‰   RŒ   R•   R‚   R›   R   t   vector(    (    (    sN   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/vecmath.pys   <module>   s   	
	ÿ ©					 