0001"""
0002**points** which move on the Riemann sphere or an object on the sphere
0003at each update cycle
0004"""
0005
0006__Def__ = ['uAniPoint']
0007
0008__Classes__ = ['uCirclingPoint', 'uSpiral']
0009
0010__all__ = __Classes__ + __Def__
0011
0012__doc_hints__={'m_type':'factory'}
0013
0014
0015import pygeo.base.abstracts._usphere as USphere
0016
0017from pygeo.base.analytics.pygeomath import sin, cos, PI, vector
0018from pygeo.base.abstracts._element import Element
0019
0020class uCirclingPoint(USphere._uPoint):
0021 """
0022*point* of the given **spheric section** of the Riemann sphere that moves
0023along the spheric section at each update, with its initial position
0024determined by optinal **float** argument, in radians
0025
0026 inherits
0027
0028 `_uPoint`__
0029
0030__ class-base.abstracts._usphere._uPoint.html
0031
0032 """
0033
0034 __doc_hints__= {'factory':'uAniPoint',
0035 'args':['zcircle <,float>']}
0036
0037 __opts__= USphere._uFreePosition.__opts__[:] + ["rate","angle"]
0038
0039 def __init__(self,ucircle,angle=0,**kws):
0040 self.ucircle=ucircle
0041 self.rate=kws.get("rate",36)
0042 self.rad=2.*PI/self.rate
0043 self.angle=angle
0044 self.delta=0
0045 USphere._rPoint.__init__(self,*[ucircle],**kws)
0046 self.init()
0047
0048 def findSelf(self):
0049 self-=self.ucircle._center
0050 self.set(self.rotate(self.rad, self.ucircle._u))
0051 self+=self.ucircle._center
0052 return True
0053
0054
0055 def init(self):
0056 self.set(self.ucircle._cpoint)
0057 self.toCircumPoint(self.ucircle,self.angle-self.rad)
0058 Element.init(self)
0059
0060class uSpiral(USphere._uPoint):
0061 """
0062*point* of the Riemann sphere that moves as a spiral on the sphere from
0063its initial point to its antipodal point, with the initial point determined
0064by given polar coordinates, in radians
0065
0066 inherits
0067
0068 `_uPoint`__
0069
0070__ class-base.abstracts._usphere._uPoint.html
0071
0072 """
0073
0074 __doc_hints__= {'factory':'uAniPoint',
0075 'args':['float,<float>', '<theta = float> <,phi= float>']}
0076
0077 __opts__= USphere._uFreePosition.__opts__[:] + ["theta","phi", "t_factor","p_factor","rate"]
0078
0079 def __init__(self,theta=0,phi=0,**kws):
0080 self.rate=kws.get('rate',36)
0081 self.rad=PI/self.rate
0082 self.t_factor=1
0083 self.p_factor=5
0084 self.t_delta=0
0085 self.p_delta=0
0086 self.phi=phi
0087 self.axis=vector(sin(theta)*sin(phi),-cos(theta)*sin(phi),0)
0088 USphere._uPoint.__init__(self,**kws)
0089 self.init()
0090
0091 def findSelf(self):
0092 phi =self.p_delta
0093 theta = self.t_delta
0094 x=cos(theta)*sin(phi)
0095 y=sin(theta)*sin(phi)
0096 z=cos(phi)
0097 self.set(vector(x,y,z).rotate(self.phi,self.axis))
0098
0099 self.p_delta+=self.rad*self.t_factor
0100 self.t_delta+=self.rad*2*self.p_factor
0101 return True
0102
0103def uAniPoint(*args,**kws):
0104 """
0105'class factory' function returns instance of object derived from the _uPoint
0106abstract class which moves in relation to a given geometric object of the Riemann sphere
0107at each update cyle
0108 """
0109
0110 __sigs__=[[],[float],[float,float]
0111 [USphere._uCircle],[USphere._uCircle,float]]
0112
0113 from pygeo.base.abstracts._element import method_get
0114 from pygeo.base.support.pygeoexceptions import Argument_Type_Error
0115
0116 t,i = method_get(__sigs__,args)
0117
0118 if t is None:
0119 raise Argument_Type_Error(__sigs__,args)
0120 else:
0121 if i==0:
0122 return uSpiral(**kws)
0123 elif i==1:
0124 return uSpiral(t[0],**kws)
0125 elif i==2:
0126 return uSpiral(t[0],t[1],**kws)
0127 elif i==3:
0128 return uCirclingPoint(t[0],**kws)
0129 elif i==4:
0130 return uCirclingPoint(t[0],t[1],**kws)
0131 else:
0132 raise Argument_Type_Error(__sigs__,args)