0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022"""
0023abstract classes for geometric objects of the Riemann sphere
0024"""
0025
0026from pygeo.base.analytics._position3 import Position3
0027from pygeo.base.support.pygeoconstants import RED, WHITE
0028from pygeo.base.analytics.pygeomath import *
0029import pygeo.base.drawing.vdraw as Draw
0030import pygeo.base.abstracts._real as Real
0031from pygeo.base.abstracts._element import Element,freepoints
0032from pygeo.base.abstracts._complex import _zPoint,_zLine,_zCircle
0033
0034
0035
0036"""
0037Abstract classes for geometric objects of the Riemann sphere
0038"""
0039
0040
0041class _rPoint(Real._Point):
0042 """a O dimensional object with a defined position in space.
0043
0044inherits
0045
0046 `_Point`__
0047
0048defining instance attributes
0049
0050 - x: x coord
0051 - y: y coord
0052 - z: z coord
0053
0054__ class-base.abstracts._real._Point.html
0055
0056 """
0057
0058 def __init__(self,*args,**kws):
0059 Real._Point.__init__(self,*args,**kws)
0060 self.pointsize=kws.get("pointsize",.08)
0061 self.color=kws.get("color",RED)
0062 if self.trace:
0063 self.tmparray=Position3()
0064 self.tmparray.set(self)
0065 self.mintrace=kws.get("mintrace",.01)
0066 self.maxtrace=kws.get("maxtrace",500.)
0067 self.tracewidth=kws.get("tracewidth",self.pointsize/2.0)
0068 self.tracecolor=kws.get("tracecolor",self.color)
0069 self.fontXoffset=kws.get("fontXoffset",0)
0070 self.fontYoffset=kws.get("fontYoffset",0)
0071
0072class _uPoint(_rPoint):
0073 """a O dimensional object on the unit sphere.
0074
0075inherits
0076
0077 `_rPoint`__
0078
0079defining instance attributes
0080
0081 - x: x coord
0082 - y: y coord
0083 - z: z coord
0084
0085__ class-base.abstracts._usphere._rPoint.html
0086
0087 """
0088 def __init__(self,*args,**kws):
0089 _rPoint.__init__(self,*args,**kws)
0090
0091
0092class _uFreePosition(_uPoint):
0093 """a O dimensional object that can be picked and moved either
0094freely on the unit sphere or on an object of the unit sphere
0095
0096inherits:
0097
0098 `_uPoint`__
0099
0100defining instance attributes
0101
0102 - x: x coord
0103 - y: y coord
0104 - z: z coord
0105
0106__ class-base.abstracts._usphere._uPoint.html
0107
0108 """
0109
0110 def __init__(self,*args,**kws):
0111 _uPoint.__init__(self,*args,**kws)
0112 self.pointsize=kws.get("pointsize",.1)
0113 self.color=kws.get("color",RED)
0114 self.initcolor =self.color
0115 self.initpointsize=self.pointsize
0116 self.initvector=Position3()
0117 self.initvector.set(self)
0118 freepoints.append(self)
0119 self.dependants=[self]
0120
0121 def _add_dependant(self,e):
0122 self.dependants.append(e)
0123
0124 def reset(self):
0125 """Reset to position of start-up input"""
0126 self.pointsize=self.initpointsize
0127 self.color = self.initcolor
0128 self.set(self.initvector)
0129 _uPoint.update(self)
0130
0131
0132class _uCircle(Real._Circle):
0133 """a spheric section of the unit sphere
0134
0135inherits:
0136
0137 `_Circle`__
0138
0139defining attributes:
0140
0141 - _u : the unit normal of the circle's plane
0142 - _d : the distance from origin of the circle's plane
0143 - _s : unit vector perp to normal of the circle's plane
0144 - _center: the circle's center point
0145 - _cpoint: a point of the circle's circumference
0146 - _radius: the circle's radius
0147 - _radiusSquared: the square of circle's radius
0148
0149__ class-base.abstracts._real._Circle.html
0150
0151 """
0152
0153 def __init__(self,*args,**kws):
0154 Real._Circle.__init__(self,*args,**kws)
0155 self.linewidth=kws.get("linewidth",.02)
0156
0157
0158class _uSphere(Real._Sphere):
0159 """the orign centered Riemann (unit) sphere representing the extended complex plane
0160
0161inherits:
0162
0163 `_Sphere`__
0164
0165defining attributes:
0166
0167 - _center the sphere's center point
0168 - _cpoint a point on the sphere's circumference
0169 - _radius: the sphere's radius
0170 - _radiusSquared: the square of the sphere's radius
0171
0172__ class-base.abstracts._real._Sphere.html
0173
0174 """
0175
0176 def __init__(self,*args,**kws):
0177 Real._Sphere.__init__(self,*args,**kws)
0178 self.precision=kws.get("precision",20)
0179 self.color=kws.get("color",WHITE)
0180 self.linewidth=kws.get("linewidth",.01)
0181 self._center=_rPoint(append=False)
0182 self._radius=1
0183 self._radiusSquared=1
0184 self.N=_rPoint(0,0,1,append=False)
0185
0186 def rmatrix(self):
0187 mat=Element.rmatrix(self)
0188 mat[3:]=array([[0.0,0.0,0.0,1.0]])
0189 return mat
0190
0191
0192class _uCirclePencil(Real._CirclePencil):
0193 """an array of circles on the Riemann sphere
0194
0195inherits:
0196
0197 `_CirclePencil`__
0198
0199defining attributes:
0200
0201 - circles: the positioned circles of the array
0202
0203__ class-base.abstracts._real._CirclePencil.html
0204
0205 """
0206
0207 def __init__(self,*args,**kws):
0208 Real._CirclePencil.__init__(self,*args,**kws)
0209 self.linewidth=kws.get("linewidth",.02)
0210
0211
0212class _uTransformation(Element,Draw.drawArray):
0213 """the stereographic mapping of geometric objects of the complex plane to the unit sphere
0214
0215inherits:
0216
0217 Element__ , drawArray__
0218
0219defining attributes:
0220
0221 - transforms: the transformed positions of the given objects
0222
0223__ class-base.abstracts._element.Element.html
0224__ class-base.drawing.vdraw.drawArray.html
0225
0226 """
0227
0228 def __init__(self,*args,**kws):
0229 Element.__init__(self,*args,**kws)
0230 self.color = kws.get("color",None)
0231 self.level = kws.get("level",None)
0232 self.deps=[]
0233
0234 def findSelf(self):
0235 for e,t in zip(self.elements,self.transforms):
0236 e.to_uSphere(t)
0237 return True
0238
0239 def __iter__(self):
0240 for transform in self.transforms:
0241 yield transform
0242
0243 def init(self):
0244 self.transforms=[]
0245 for e in self.elements:
0246 if self.color:
0247 color=self.color
0248 else:
0249 color=e.color
0250 if self.level:
0251 level=self.level
0252 else:
0253 level=e.level
0254 if isinstance(e,_zPoint):
0255 self.transforms.append(_uPoint(
0256 color=color,level=level,pointsize=.03))
0257 elif isinstance(e,_zCircle):
0258 self.transforms.append(_uCircle(
0259 color=color,level=level,linewidth=.01))
0260 elif isinstance(e,_zLine):
0261 self.transforms.append(_uCircle(
0262 color=color,level=level,linewidth=.01))
0263 elif isinstance(e,_zCirclePencil):
0264 for circle in e:
0265 self.transforms.append(_uCircle(
0266 color=color,level=level,linewidth=.01))
0267 for t in self.transforms:
0268 t.init()
0269 Element.init(self)
0270
0271
0272class _rLine(Real._Line):
0273 """a 1 dimensional object representing "breathless length"
0274
0275inherits:
0276
0277 `_Line`__
0278
0279defining attributes:
0280
0281 - p1: point on line
0282 - p2: point on line
0283
0284__ class-base.abstracts._real._Line.html
0285
0286 """
0287
0288 def __init__(self,*args,**kws):
0289 Real._Line.__init__(self,*args,**kws)
0290 self.linewidth=kws.get("linewidth",.02)
0291
0292 def findSelf(self):
0293 return True
0294
0295__author__ = "Arthur Siegel <ajsiegel@optonline.com>"
0296__date__ = "Date: 2006-02-02 "
0297__revision__ = "Revision: a1"
0298__url__ = "URL: http://source.net/projects/pygeo"
0299__copyright__ ="GPL <http://www.opensource.org/licenses/gpl-license.php>"