0001"""
0002**point** determined as a reflection in a given geometric object
0003"""
0004
0005__Def__ =       ['Reflection']
0006
0007__Classes__ =   ['PlaneReflection', 'LineReflection']
0008
0009__all__= __Classes__ + __Def__
0010
0011__doc_hints__=  {'m_type':'factory'}
0012
0013import pygeo.base.abstracts._real as Real
0014
0015from pygeo.base.analytics.pygeomath import PI
0016
0017
0018class PlaneReflection(Real._Point):
0019    """
0020*point* of reflection of the given **point** in the given **plane**
0021
0022    inherits
0023    
0024        `_Point`__
0025
0026__ base.abstracts._real._Point.html        
0027
0028    """
0029
0030    __doc_hints__=  {'factory':'Reflection',
0031                    'args':['point,plane']}
0032
0033    def __init__(self,point,plane,**kws):
0034        self.plane=plane
0035        self.point=point
0036        Real._Point.__init__(self,*[point,plane],**kws)
0037        self.init()
0038
0039    def findSelf(self):
0040        self.set(self.point)
0041        return self.toPlaneReflection(self.plane._u,self.plane._d)
0042
0043
0044class LineReflection(Real._Point):
0045    """
0046*point* of reflection of given **point** in the given **line**, 
0047on the plane of the line and point
0048    
0049    inherits
0050    
0051        `_Point`__
0052
0053__ base.abstracts._real._Point.html        
0054    
0055    """
0056
0057    __doc_hints__=  {'factory':'Reflection',
0058                    'args':['point,line']}
0059
0060    def __init__(self,point,line,**kws):
0061        self.line=line
0062        self.point=point
0063        Real._Point.__init__(self,*[point,line],**kws)
0064        self.init()
0065
0066    def findSelf(self):
0067        line=self.line
0068        axis=line.p1-line.p2
0069        self.set(self.point-line.p1)
0070        self.set(self.rotate(PI,axis)+line.p1)
0071        return True
0072
0073
0074def Reflection(*args,**kws):
0075    """
0076'class factory' function returns instance of object derived from the 
0077_Point abstract class determined as a reflection in a given geometric 
0078object
0079    
0080    """
0081
0082    from pygeo.base.abstracts._element import method_get
0083    from pygeo.base.support.pygeoexceptions import Argument_Type_Error
0084    from pygeo.base.analytics.pygeomath import vector
0085
0086    __sigs__=[[vector, Real._Plane],[vector,Real._Line]]
0087
0088    t,i=method_get(__sigs__,args)
0089
0090    if t is  None:
0091        raise Argument_Type_Error(__sigs__,args)
0092    else:
0093        if i==0:
0094            return PlaneReflection(t[0],t[1],**kws)
0095        elif i==1:
0096            return LineReflection(t[0],t[1],**kws)
0097        else:
0098            raise Argument_Type_Error(__sigs__,args)