0001"""
0002**points of the complex plane** which change position at each update cycle
0003"""
0004
0005__Def__ = ['zAniPoint']
0006
0007__Classes__ = [ 'zSlidingPoint', 'zCirclingPoint', 'zRotatingPoint']
0008
0009__all__ = __Classes__ + __Def__
0010
0011__doc_hints__={'m_type':'factory'}
0012
0013
0014import pygeo.base.abstracts._complex as Complex
0015from pygeo.base.abstracts._element import Element
0016
0017from pygeo.base.analytics.pygeomath import math_E, tan, sqrt, array, matrixmultiply, PI, mod2
0019
0020
0021class zSlidingPoint(Complex._zPoint):
0022 """
0023*complex point* which moves along the given **complex line**, at a rate
0024determined by the 'rate' keyword
0025
0026 inherits
0027
0028 `_zPoint`__
0029
0030__ class-base.abstracts._complex._zPoint.html
0031
0032 """
0033
0034 __doc_hints__= {'factory':'zAniPoint',
0035 'args':['zline,<,ratio=float>']}
0036
0037 __opts__= Complex._zPoint.__opts__[:] + ["rate"]
0038
0039 def __init__(self,zline,**kws):
0040 self.zLine=zline
0041 Complex._zPoint.__init__(self,*[zline], **kws)
0042 self.rate=kws.get("rate",36)
0043 self.xdelta=1./self.rate
0044 self.delta=0
0045 self.init()
0046
0047 def findSelf(self):
0048 self.delta+=self.xdelta
0049 self.set(self.zLine.p1*(1.0-self.delta)+self.zLine.p2*self.delta)
0050 return True
0051
0052 def init(self):
0053 self.set(self.zLine.p1)
0054 Element.init(self)
0055
0056class zCirclingPoint(Complex._zPoint):
0057 """
0058*complex point* which moves along the given **complex circle**, at a rate
0059determined by the 'rate' keyword, and initial position determined by
0060the 'angle' keyword.
0061
0062 inherits
0063
0064 `_zPoint`__
0065
0066__ class-base.abstracts._complex._zPoint.html
0067
0068 """
0069
0070 __doc_hints__= {'factory':'zAniPoint',
0071 'args':['zcircel,<,angle=float>']}
0072
0073 __opts__= Complex._zPoint.__opts__[:] + ["rate","angle"]
0074
0075 def __init__(self,zcircle,**kws):
0076 self.zcircle=zcircle
0077 Complex._zPoint.__init__(self,*[zcircle], **kws)
0078 self.rate=kws.get("rate",36)
0079 self.rad=2.*PI/self.rate
0080 self.angle=kws.get("angle",0)
0081 self.delta=0
0082 self.init()
0083
0084 def findSelf(self):
0085 circle=self.zcircle
0086 self.set(circle._radius*(math_E**complex(0,self.delta))+circle._center)
0087 self.delta+=self.rad
0088 return True
0089
0090 def init(self):
0091 self.set(self.zcircle._s*self.zcircle._radius+self.zcircle._center)
0092 Element.init(self)
0093
0094class zRotatingPoint(Complex._zPoint):
0095 """
0096*complex point* which moves the 2nd given **complex point** along the path induced by the
0097rotation of the unit sphere, with the stereographic projection of the first **complex point**
0098argmuent as axis of rotation, and initial position determined by the 'angle' keyword.
0099
0100 inherits
0101
0102 `_zPoint`__
0103
0104__ class-base.abstracts._complex._zPoint.html
0105
0106 """
0107
0108 __doc_hints__= {'factory':'zAniPoint',
0109 'args':['zpoint1,zpoint2 <,angle=float>']}
0110
0111 __opts__= Complex._zPoint.__opts__[:] + ["rate","angle"]
0112
0113 def __init__(self,zcenter,cpoint,**kws):
0114 self.angle=kws.get("angle",0)
0115 self.c_point=cpoint
0116 self.z_center=zcenter
0117 Complex._zPoint.__init__(self,*[zcenter,cpoint], **kws)
0118 self.rate=kws.get("rate",35)
0119 self.rad=2.*PI/self.rate
0120 self.delta=0
0121 self.init()
0122
0123 def findSelf(self):
0124 self.set(self.c_point)
0125 center=self.z_center.uVector()
0126 self.uRotate(center,self.delta)
0127 self.delta+=self.rad
0128 return True
0129
0130def zAniPoint(*args,**kws):
0131 """
0132'class factory' function returns instance of object derived from the
0133_zPoint abstract class representing a point of the complex plane which moves
0134along a given object or defined path at each update cycle
0135
0136 """
0137
0138 from pygeo.base.abstracts._element import method_get
0139 from pygeo.base.support.pygeoexceptions import Argument_Len_Error,Argument_Type_Error
0140 from pygeo.base.support.pygeoconstants import FIXED, POLE, INVERSEPOLE
0141
0142 __sigs__ = [[Complex._zCircle],[Complex._zLine],
0143 [Complex._zPoint,Complex._zPoint]]
0144 t,i = method_get(__sigs__,args)
0145
0146 if t is None:
0147 raise Argument_Type_Error(__sigs__,args)
0148 else:
0149 if i == 0:
0150 return zCirclingPoint(t[0],**kws)
0151 elif i == 1:
0152 return zSlidingPoint(t[0],**kws)
0153 elif i == 2:
0154 return zRotatingPoint(t[0],t[1],**kws)
0155 else:
0156 raise Argument_Type_Error(__sigs__,args)