0001"""
0002**points** fixed or determined on the Riemann sphere
0003"""
0004
0005__Def__ = ['uPoint']
0006
0007__Classes__ = ['uPolarPoint', 'z_to_uPoint', 'uAntiPodal', 'uInversePoint',
0008 'uCircumPoint']
0009__all__ = __Classes__ + __Def__
0010
0011__doc_hints__={'m_type':'factory'}
0012
0013import pygeo.base.abstracts._usphere as USphere
0014
0015from pygeo.base.analytics._position3 import Position3
0016from pygeo.base.abstracts._element import Element
0017from pygeo.base.support.pygeoconstants import RED
0018from pygeo.base.analytics.pygeomath import sin, cos, vector, matrixmultiply, PI
0019
0020
0021class uPolarPoint(USphere._uPoint):
0022 """
0023*point* of the Riemann sphere at the given spherical
0024coordinates, in radians
0025
0026
0027 inherits
0028
0029 `_uPoint`__
0030
0031__ class-base.abstracts._usphere._uPoint.html
0032
0033 """
0034
0035 __doc_hints__= {'factory':'uPoint',
0036 'args':['float,<float>', '<theta = float> <,phi= float>']}
0037
0038 __opts__= USphere._uPoint.__opts__[:] + ["theta","phi"]
0039
0040 def __init__(self,theta=0,phi=0,**kws):
0041 self.theta=theta
0042 self.phi=phi
0043 USphere._uPoint.__init__(self,**kws)
0044 self.init()
0045
0046 def init(self):
0047 x=cos(self.theta)*sin(self.phi)
0048 y=sin(self.theta)*sin(self.phi)
0049 z=cos(self.phi)
0050 self.set(vector(x,y,z))
0051 self.initvector=Position3()
0052 self.initvector.set(self)
0053 Element.init(self)
0054
0055 def findSelf(self):
0056 return True
0057
0058
0059class z_to_uPoint(USphere._uPoint):
0060 """
0061*point* of the Riemann sphere stereographically projected
0062from the given **point of the complex plane**
0063
0064
0065 inherits
0066
0067 `_uPoint`__
0068
0069__ class-base.abstracts._usphere._uPoint.html
0070
0071 """
0072
0073 __doc_hints__= {'factory':'uPoint',
0074 'args':['zpoint']}
0075
0076 def __init__(self,zpoint,**kws):
0077 self.color = kws.get("color",RED)
0078 USphere._uPoint.__init__(self,*[zpoint],**kws)
0079 self.zpoint=zpoint
0080 self.init()
0081
0082 def findSelf(self):
0083 return self.zpoint.to_uSphere(self)
0084
0085
0086class uAntiPodal(USphere._uPoint):
0087 """
0088*point* of the Riemann sphere antipodal to the given **point** of the sphere
0089
0090
0091 inherits
0092
0093 `_uPoint`__
0094
0095__ class-base.abstracts._usphere._uPoint.html
0096
0097 """
0098
0099 __doc_hints__= {'factory':'uPoint',
0100 'args':['upoint']}
0101
0102 def __init__(self,upoint,**kws):
0103 USphere._uPoint.__init__(self,*[upoint],**kws)
0104 self.upoint=upoint
0105 self.init()
0106
0107 def findSelf(self):
0108 self.set(self.upoint * -1)
0109 return True
0110
0111class uCircumPoint(USphere._uPoint):
0112 """
0113*point* of a spheric section of the Riemann sphere
0114
0115
0116 inherits
0117
0118 `_uPoint`__
0119
0120__ class-base.abstracts._usphere._uPoint.html
0121
0122 """
0123
0124 __doc_hints__= {'factory':'uPoint',
0125 'args':['ucircle']}
0126
0127 def __init__(self,ucircle,angle=0,**kws):
0128 USphere._uPoint.__init__(self,*[ucircle],**kws)
0129 self.ucircle=ucircle
0130 self.angle=angle
0131 self.init()
0132
0133 def findSelf(self):
0134 self.set(self.ucircle._cpoint)
0135 return self.toCircumPoint(self.ucircle,self.angle)
0136
0137class uInversePoint(USphere._uPoint):
0138 """
0139*point* of the Riemann sphere inverse to the given **point** of the sphere with
0140respect to the given **spheric section** of the sphere
0141
0142
0143 inherits
0144
0145 `_uPoint`__
0146
0147__ class-base.abstracts._usphere._uPoint.html
0148
0149 """
0150
0151 __doc_hints__= {'factory':'uPoint',
0152 'args':['ucricle,upoint']}
0153
0154
0155 def __init__(self,ucircle,upoint,**kws):
0156 USphere._uPoint.__init__(self,*[ucircle,upoint],**kws)
0157 self.ucircle=ucircle
0158 self.upoint=upoint
0159 self.init()
0160
0161 def findSelf(self):
0162 equat=self.ucircle.equat()
0163 m = self.upoint.dot(self.ucircle._u)
0164 d=self.ucircle._d*-1.
0165 factor=2*d*(m+d)/(matrixmultiply(equat,equat)+2*d*m)
0166 try:
0167 c=vector(self.ucircle._u/self.ucircle._d)
0168 self.set((1-factor)*self.upoint+factor*c)
0169 except:
0170 self.set(vector(COMPLEX_MAX,COMPLEX_MAX,COMPLEX_MAX))
0171 return True
0172
0173
0174def uPoint(*args,**kws):
0175 """
0176'class factory' function returns instance of object derived from the
0177_uPoint abstract class representing fixed or determmined points of the Riemann sphere
0178 """
0179
0180 from pygeo.base.abstracts._element import method_get
0181 from pygeo.base.support.pygeoexceptions import Argument_Type_Error
0182 import pygeo.base.abstracts._complex as Complex
0183
0184 __sigs__=[[],[float],[float,float],
0185 [USphere._uPoint],
0186 [Complex._zPoint],
0187 [USphere._uCircle,USphere._uPoint]]
0188
0189 t,i = method_get(__sigs__,args)
0190
0191 if t is None:
0192 raise Argument_Type_Error(__sigs__,args)
0193 else:
0194 if i==0:
0195 return uPolarPoint(**kws)
0196 elif i==1:
0197 return uPolarPoint(t[0],**kws)
0198 elif i==2:
0199 return uPolarPoint(t[0],t[1],**kws)
0200 elif i==3:
0201 return uAntiPodal(t[0],**kws)
0202 elif i==4:
0203 return z_to_uPoint(t[0],**kws)
0204 elif i==5:
0205 return uInversePoint(t[0],t[1],**kws)
0206 else:
0207 raise Argument_Type_Error(__sigs__,args)