0001"""
0002**points of the complex plane** with position determined in connection with
0003a defined Moebius transformation 
0004"""
0005
0006__Def__ = ['mobPoint']
0007
0008__Classes__ = ['mobPole','mobInversePole','mobFixed']
0009
0010
0011__all__ =__Classes__ + __Def__
0012
0013__doc_hints__={'m_type':'factory'}
0014
0015import pygeo.base.abstracts._complex as Complex
0016from pygeo.base.analytics.pygeomath import Mobius, matrixmultiply, inverse
0017
0018
0019
0020class mobPole(Complex._zPoint):
0021    """
0022*complex point* which is transformed to the point at infinity under the given 
0023**Mobius transformation** 
0024    
0025    inherits
0026    
0027        `_zPoint`__
0028
0029__ class-base.abstracts._complex._zPoint.html        
0030    
0031    """
0032
0033    __doc_hints__=  {'factory':'mobPoint',
0034                    'args':['mobtransform'],
0035                    'qualifier':'POLE'}
0036
0037    def __init__(self,transform,**kws):
0038        Complex._zPoint.__init__(self,*[transform],**kws)
0039        self.mobius=transform
0040        self.init()
0041
0042    def findSelf(self):
0043        self.set(self.mobius._mobius.getPole())
0044        return True
0045
0046class mobInversePole(Complex._zPoint):
0047    """
0048*complex point* to which the point at infinity is transformed under the given 
0049**Mobius transformation** 
0050    
0051    inherits
0052    
0053        `_zPoint`__
0054
0055__ class-base.abstracts._complex._zPoint.html        
0056    
0057    """
0058    __doc_hints__=  {'factory':'mobPoint',
0059                    'args':['mobtransform'],
0060                    'qualifier':'INVERSEPOLE'}
0061
0062    def __init__(self,transform,**kws):
0063        Complex._zPoint.__init__(self,*[transform],**kws)
0064        self.mobius=transform
0065        self.init()
0066
0067    def findSelf(self):
0068        self.set(self.mobius._mobius.getInversePole())
0069        return True
0070
0071
0072class mobFixed(Complex._zPoint):
0073    """
0074*complex point* representing one of the points fixed of the given 
0075**Mobius transformation** 
0076    
0077    inherits
0078    
0079        `_zPoint`__
0080
0081__ class-base.abstracts._complex._zPoint.html        
0082    
0083    """
0084
0085    __opts__= Complex._zPoint.__opts__[:] + ["fixed"]
0086
0087    __doc_hints__=  {'factory':'mobPoint',
0088                    'args':['mobtransform <,fixed=(0 or 1)>'],
0089                    'qualifier':'FIXED'}
0090
0091    def __init__(self,transform,**kws):
0092        Complex._zPoint.__init__(self,*[transform],**kws)
0093        self.mobius=transform
0094        self.fixed=kws.get('fixed',0)
0095        self.init()
0096
0097    def findSelf(self):
0098        evectors=self.mobius._mobius.getFixed()
0099        if self.fixed:
0100            try:
0101                self.set(evectors[1][0]/evectors[1][1])
0102            except ZeroDivisionError:
0103                print self.__class__.__name__
0104                print "fixed point at infinity, returning False"
0105                return False
0106        else:
0107            try:
0108                self.set(evectors[0][0]/evectors[0][1])
0109            except ZeroDivisionError:
0110                print self.__class__.__name__
0111                print "fixed point at infinity, returning False"
0112                return False
0113        return True
0114
0115def mobPoint(*args,**kws):
0116    """
0117'class factory' function returns instance of object derived from the 
0118_zPoint abstract class representing a point defined by a given Mobius 
0119transformation
0120    """
0121
0122    from pygeo.base.abstracts._element import method_get
0123    from pygeo.base.support.pygeoexceptions import Argument_Len_Error,Argument_Type_Error
0124    from pygeo.base.support.pygeoconstants import FIXED, POLE, INVERSEPOLE
0125
0126    __sigs__=[[Complex._zTransformation],[Complex._zTransformation,float],
0127              [list,list,Complex._zPoint]]
0128
0129    t,i = method_get(__sigs__,args)
0130    if t is None:
0131       raise Argument_Type_Error(__sigs__,args)
0132    else:
0133        if i==0:
0134            return mobFixed(t[0],**kws)
0135        elif i==1:
0136            if t[1]==FIXED:
0137                return mobFixed(t[0],**kws)
0138            elif t[1]==POLE:
0139                return mobPole(t[0],**kws)
0140            elif t[1]==INVERSEPOLE:
0141                return mobInversePole(t[0],**kws)
0142            else:
0143                raise Argument_Type_Error(__sigs__,args)
0144        elif i==2:
0145            return mobCrossPoint(t[0],t[1],t[2],**kws)
0146        else:
0147            raise Argument_Type_Error(__sigs__,args)