0001"""
0002**array of points** of the complex plane
0003"""
0004__Def__ = ['zPointArray']
0005
0006__Classes__ = ['zCirclePoints','zLinePoints']
0007
0008__all__ = __Classes__ + __Def__
0009
0010__doc_hints__={'m_type':'factory'}
0011
0012import pygeo.base.abstracts._complex as Complex
0013from pygeo.base.analytics.pygeomath import math_E, PI
0014from pygeo.base.support.pygeoopts import COMPLEX_MAX
0015
0016
0017class zCirclePoints(Complex._zPointArray):
0018    """
0019array of complex points equidistant on thecircumference of the given complex circle    
0020    """
0021
0022    __doc_hints__=  {'factory':'zPointArray',
0023                    'args':['zcircle']}
0024
0025    def __init__(self,circle,**kws):
0026        Complex._zPointArray.__init__(self,*[circle],**kws)
0027        self.circle=circle
0028        self.adelta=2*PI/self.density
0029        self.init()
0030
0031    def findSelf(self):
0032        circle=self.circle
0033        for i, zpoint in enumerate(self):
0034            angle=i*self.adelta
0035            zpoint.set(complex(0,1)*circle._radius*(math_E**complex(0,angle))+circle._center)
0036        return True
0037
0038
0039class zLinePoints(Complex._zPointArray):
0040    """
0041*array of complex points* equidistant on a given **line of the complex plane** 
0042    """
0043
0044    __doc_hints__=  {'factory':'zPointArray',
0045                    'args':['zline']}
0046
0047    def __init__(self,zline,**kws):
0048        self.zline=zline
0049        self.seg=kws.get('seg',False)
0050        Complex._zPointArray.__init__(self,*[zline],**kws)
0051        self.init()
0052
0053    def findSelf(self):
0054        zline =self.zline
0055        p= zline.getDirection()
0056        length=COMPLEX_MAX*2
0057        start = (p*-COMPLEX_MAX)+(zline.p1+zline.p2)/2
0058        steps=[length/float(self.density-1)*i for i in range(self.density)]
0059        for zpoint,step in zip(self,steps):
0060            zpoint.set(p*step+start)
0061        return True
0062
0063def zPointArray(*args,**kws):
0064    """
0065'class factory' function returns instance of object derived from the 
0066_zPointArray abstract class representing an array of points  
0067of the complex plane
0068    """
0069
0070    from pygeo.base.abstracts._element import method_get
0071    from pygeo.base.support.pygeoexceptions import Argument_Type_Error
0072
0073
0074    __sigs__=[[Complex._zCircle]]
0075
0076    t,i = method_get(__sigs__,args)
0077
0078    if t is None:
0079        raise Argument_Type_Error(__sigs__,args)
0080    else:
0081        if i==0:
0082            return zCirclePoints(t[0],**kws)
0083        else:
0084            raise Argument_Type_Error(__sigs__,args)