0001"""
0002**lines of the complex plane** (i.e. circles of infinite radius)
0003"""
0004
0005__Def__ = ['zLine']
0006
0007__Classes__ = [ 'zLineFromPoints','zBiChord']
0008
0009__all__ = __Classes__ + __Def__
0010
0011__doc_hints__={'m_type':'factory'}
0012
0013
0014import pygeo.base.abstracts._complex as Complex
0015
0016from pygeo.base.analytics.pygeomath import absolute
0017
0018class zLineFromPoints(Complex._zLine):
0019    """
0020*line* of the complex plane through the given **2 complex point** arguments
0021    
0022    inherits
0023    
0024        `_zLine`__
0025
0026__ class-base.abstracts._complex._zLine.html        
0027    
0028    """
0029
0030    __doc_hints__=  {'factory':'zLine',
0031                    'args':['zpoint1,zpoint2']}
0032
0033    def __init__(self,p1,p2,**kws):
0034        Complex._zLine.__init__(self,*[p1,p2],**kws)
0035        self.p1=p1
0036        self.p2=p2
0037        self.init()
0038
0039class zBiChord(Complex._zLine):
0040    """
0041line of the complex plane determined as the  radical axis 
0042of the given **2 the complex circles** arguments
0043    
0044    inherits
0045    
0046        `_zLine`__
0047
0048__ class-base.abstracts._complex._zLine.html        
0049    
0050    """
0051
0052    __doc_hints__=  {'factory':'zLine',
0053                    'args':['zcircle1,zcircle2']}
0054
0055    def __init__(self,circle1,circle2,**kw):
0056        Complex._zLine.__init__(self,*[circle1,circle2],**kw)
0057        self.zCircle1=circle1
0058        self.zCircle2=circle2
0059        self.deps=[self.p1,self.p2]
0060        self.init()
0061
0062    def findSelf(self):
0063        v=self.zCircle2._center-self.zCircle1._center
0064        d=v.mod()
0065        a = (self.zCircle1._radiusSquared - self.zCircle2._radiusSquared + d**2 ) / (2*d)
0066        P2 = self.zCircle1._center + a * ( v) / d
0067        h = absolute(self.zCircle1._radius - a**2)
0068        m1=v/d*h
0069        m2=v/d*-h
0070        self.p1.set(complex(-m1.imag+P2.real,m1.real+P2.imag))
0071        self.p2.set(complex(-m2.imag+P2.real,m2.real+P2.imag))
0072        self.set_hermitian_from_points()
0073        return True
0074
0075def zLine(*args,**kws):
0076    """
0077'class factory' function returns instance of object derived from the 
0078_zLine abstract class representing a line (circle of infinite radius) 
0079of the complex plane 
0080    """
0081
0082    from pygeo.base.abstracts._element import method_get
0083    from pygeo.base.support.pygeoexceptions import Argument_Type_Error
0084
0085    __sigs__=[[Complex._zPoint,Complex._zPoint],
0086             [Complex._zCircle,Complex._zCircle]]
0087
0088    t,i = method_get(__sigs__,args)
0089
0090    if t is None:
0091        raise Argument_Type_Error(__sigs__,args)
0092    else:
0093        if i==0:
0094            return zLineFromPoints(t[0],t[1],**kws)
0095        elif i==1:
0096            return zBiChord(t[0],t[1],**kws)
0097        else:
0098         raise Argument_Type_Error(__sigs__,args)