ó
ßÈ[c           @` s   d  d l  m Z m Z m Z d  d l Z d  d l m Z d d l m	 Z
 d d l m Z d d l m Z m Z d g Z d	   Z d e f d
     YZ d S(   i    (   t   print_functiont   divisiont   absolute_importN(   t   Polygoni   (   t   units(   t   UnitSphericalRepresentation(   t   rotation_matrixt   matrix_productt   SphericalCirclec         C` s   t  d |  d |  } t d t j t j | d d } t | d d } t | |  } | j   } | j |  } t  j	 |  } | j
 | j f S(   s&  
    Given a polygon with vertices defined by (lon, lat), rotate the polygon
    such that the North pole of the spherical coordinates is now at (lon0,
    lat0). Therefore, to end up with a polygon centered on (lon0, lat0), the
    polygon should initially be drawn around the North pole.
    t   lont   latg      à?t   axist   yt   z(   R   R   t   npt   pit   ut   radianR   t   to_cartesiant	   transformt   from_cartesianR	   R
   (   R	   R
   t   lon0t   lat0t   polygont   m1t   m2t   transform_matrix(    (    sD   lib/python2.7/site-packages/astropy/visualization/wcsaxes/patches.pyt   _rotate_polygon   s    	%c           B` s    e  Z d  Z d e j d  Z RS(   sï  
    Create a patch representing a spherical circle - that is, a circle that is
    formed of all the points that are within a certain angle of the central
    coordinates on a sphere. Here we assume that latitude goes from -90 to +90

    This class is needed in cases where the user wants to add a circular patch
    to a celestial image, since otherwise the circle will be distorted, because
    a fixed interval in longitude corresponds to a different angle on the sky
    depending on the latitude.

    Parameters
    ----------
    center : tuple or `~astropy.units.Quantity`
        This can be either a tuple of two `~astropy.units.Quantity` objects, or
        a single `~astropy.units.Quantity` array with two elements.
    radius : `~astropy.units.Quantity`
        The radius of the circle
    resolution : int, optional
        The number of points that make up the circle - increase this to get a
        smoother circle.
    vertex_unit : `~astropy.units.Unit`
        The units in which the resulting polygon should be defined - this
        should match the unit that the transformation (e.g. the WCS
        transformation) expects as input.

    Notes
    -----
    Additional keyword arguments are passed to `~matplotlib.patches.Polygon`
    id   c         K` sØ   | \ } } t  j d d t  j | d  d  t j } t  j d t  j | j t j  |  t j }	 t | |	 | |  \ } }	 | j |  } |	 j |  }	 t  j | |	 g  j	   }
 t
 t |   j |
 |  d  S(   Ng        i   i   iÿÿÿÿg      à?(   R   t   linspaceR   R   R   t   repeatt   to_valueR   t   arrayt	   transposet   superR   t   __init__(   t   selft   centert   radiust
   resolutiont   vertex_unitt   kwargst	   longitudet   latitudeR	   R
   t   vertices(    (    sD   lib/python2.7/site-packages/astropy/visualization/wcsaxes/patches.pyR"   H   s    +0(   t   __name__t
   __module__t   __doc__R   t   degreeR"   (    (    (    sD   lib/python2.7/site-packages/astropy/visualization/wcsaxes/patches.pyR   )   s   (   t
   __future__R    R   R   t   numpyR   t   matplotlib.patchesR   t    R   R   t   coordinates.representationR   t   coordinates.matrix_utilitiesR   R   t   __all__R   R   (    (    (    sD   lib/python2.7/site-packages/astropy/visualization/wcsaxes/patches.pyt   <module>   s   		