0001"""
0002**array of circles** of the complex plane
0003"""
0004__Def__ = ['zCirclePencil']
0005
0006__Classes__ = ['zCircles','u_to_zCirclePencil']
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 vector,Hermitian
0014
0015class zCircles(Complex._zCirclePencil):
0016    """
0017array of complex circles generated by the given **2 complex circles**
0018    
0019    inherits
0020    
0021        `_zCirclePencil`__
0022
0023__ class-base.abstracts._complex._zCirclePencil.html        
0024    
0025    """
0026
0027    __doc_hints__=  {'factory':'zCirclePencil',
0028                    'args':['zcircle1,zcircle2']}
0029
0030    def __init__(self,circle1,circle2,**kws):
0031        Complex._zCirclePencil.__init__(self,*[circle1,circle2],**kws)
0032        self.circle1=circle1
0033        self.circle2=circle2
0034        self.init()
0035
0036    def findSelf(self):
0037        for i,zcircle  in enumerate(self.zcircles):
0038           zcircle._hermitian=self.circle1._hermitian*i+self.circle2._hermitian*(self.density-i)
0039           zcircle.set_radius_from_hermitian()
0040        return True
0041
0042
0043class u_to_zCirclePencil(Complex._zCirclePencil):
0044    """
0045*array of complex circles* generated by the stereographic projection
0046of a **pencil of spheric sections of the Riemann sphere**
0047    
0048    inherits
0049    
0050        `_zCirclePencil`__
0051
0052__ class-base.abstracts._complex._zCirclePencil.html        
0053    
0054    """
0055
0056    __doc_hints__=  {'factory':'zCirclePencil',
0057                    'args':['ucirclepencil']}
0058
0059    def __init__(self,r_pencil,**kw):
0060        Complex._zCirclePencil.__init__(self,*[r_pencil],**kw)
0061        self.density=r_pencil.density
0062        self.r_pencil=r_pencil
0063        self.init()
0064
0065    def findSelf(self):
0066        for i,zcircle in enumerate(self.zcircles):
0067            c_center=self.r_pencil.circles[i]._center
0068            d=c_center.mag
0069            try:
0070                u=c_center.norm()
0071            except ZeroDivisionError:
0072                u=vector(0,0,0)
0073            a=u.x
0074            b=u.y
0075            c=u.z
0076            A=(d-c)*.5
0077            B=(a-b*complex(0,1))*.5
0078            C=B.conjugate()
0079            D=(d+c)*.5
0080            zcircle._hermitian=Hermitian([[A,B],[C,D]])
0081            zcircle.set_radius_from_hermitian()
0082        return True
0083
0084
0085def zCirclePencil(*args,**kws):
0086    """
0087'class factory' function returns instance of object derived from the 
0088_zCirclePencil abstract class representing an array of circles  
0089on the complex plane
0090    """
0091
0092    from pygeo.base.abstracts._element import method_get
0093    from pygeo.base.support.pygeoexceptions import Argument_Type_Error
0094    import pygeo.base.abstracts._usphere as USphere
0095
0096    __sigs__=[[Complex._zCircle,Complex._zCircle],
0097               [USphere._uCirclePencil]]
0098
0099    t,i = method_get(__sigs__,args)
0100
0101    if t is None:
0102        raise Argument_Type_Error(__sigs__,args)
0103    else:
0104        if i==0:
0105            return zCircles(t[0],t[1],**kws)
0106        elif i==1:
0107            return u_to_zCirclePencil(t[0],**kws)
0108        else:
0109            raise Argument_Type_Error(__sigs__,args)