revision 907 by gross, Wed Nov 22 09:54:19 2006 UTC revision 916 by gross, Fri Dec 15 08:25:57 2006 UTC
# Line 61  class Rotatation(Transformation): Line 61  class Rotatation(Transformation):
61      """      """
62      defines a rotation      defines a rotation
63      """      """
65         """         """
66         creates a rotation using to points to define the axis and a rotation angle         creates a rotation using an axis and a point on the axis
67         """         """
68         self.__point0=numarray.array(point0,type=_TYPE)         self.__axis=numarray.array(axis,type=_TYPE)
69         self.__point1=numarray.array(point1,type=_TYPE)         self.__point=numarray.array(point,type=_TYPE)
self.__axis=self.__point1-self.__point0
70         lax=numarray.dot(self.__axis,self.__axis)         lax=numarray.dot(self.__axis,self.__axis)
71         if not lax>0:         if not lax>0:
72            raise ValueError("points must be distinct.")            raise ValueError("points must be distinct.")
# Line 78  class Rotatation(Transformation): Line 77  class Rotatation(Transformation):
77         applies rotatation to x         applies rotatation to x
78         """         """
79         x=numarray.array(x,_TYPE)         x=numarray.array(x,_TYPE)
80         z=x-self.__point0         z=x-self.__point
81         z0=numarray.dot(z,self.__axis)         z0=numarray.dot(z,self.__axis)
82         z_per=z-z0*self.__axis         z_per=z-z0*self.__axis
83         lz_per=numarray.dot(z_per,z_per)         lz_per=numarray.dot(z_per,z_per)
84         if lz_per>0:         if lz_per>0:
85           axis1=z_per/math.sqrt(lz_per)           axis1=z_per/math.sqrt(lz_per)
86           axis2=_cross(self.__axis,axis1)           axis2=_cross(axis1,self.__axis)
87           lax2=numarray.dot(axis2,axis2)           lax2=numarray.dot(axis2,axis2)
88           axis2/=math.sqrt(lax2)           if lax2>0:
89           return z0*self.__axis+math.sqrt(lz_per)*(math.cos(self.__angle)*axis1-math.sin(self.__angle)*axis2)+self.__point0              axis2/=math.sqrt(lax2)
90                return z0*self.__axis+math.sqrt(lz_per)*(math.cos(self.__angle)*axis1-math.sin(self.__angle)*axis2)+self.__point
91             else:
92                return x
93         else:         else:
94           return x           return x
95  def _cross(x, y):  def _cross(x, y):
# Line 104  class Dilation(Transformation): Line 106  class Dilation(Transformation):
106         """         """
107         creates a dilation with a center an a given expansion/contraction factor         creates a dilation with a center an a given expansion/contraction factor
108         """         """
109         if not factor>0:         if not abs(factor)>0:
110            raise ValueError("factor must be positive.")            raise ValueError("factor must be non-zero.")
111         self.__factor=factor         self.__factor=factor
112         self.__center=numarray.array(center,type=_TYPE)         self.__center=numarray.array(center,type=_TYPE)
113      def __call__(self,x=numarray.zeros((3,))):      def __call__(self,x=numarray.zeros((3,))):

Legend:
 Removed from v.907 changed lines Added in v.916