68 |
self.__point0=numarray.array(point0,type=_TYPE) |
self.__point0=numarray.array(point0,type=_TYPE) |
69 |
self.__point1=numarray.array(point1,type=_TYPE) |
self.__point1=numarray.array(point1,type=_TYPE) |
70 |
self.__axis=self.__point1-self.__point0 |
self.__axis=self.__point1-self.__point0 |
71 |
lax=dot(self.__axis,self.__axis) |
lax=numarray.dot(self.__axis,self.__axis) |
72 |
if not lax>0: |
if not lax>0: |
73 |
raise ValueError("points must be distinct.") |
raise ValueError("points must be distinct.") |
74 |
self.__axis/=math.sqrt(lax) |
self.__axis/=math.sqrt(lax) |
81 |
z=x-self.__point0 |
z=x-self.__point0 |
82 |
z0=numarray.dot(z,self.__axis) |
z0=numarray.dot(z,self.__axis) |
83 |
z_per=z-z0*self.__axis |
z_per=z-z0*self.__axis |
84 |
z1=numarray.dot(z_per,z_per) |
lz_per=numarray.dot(z_per,z_per) |
85 |
if z1>0: |
if lz_per>0: |
86 |
axis1=z_per/math.sqrt(z1) |
axis1=z_per/math.sqrt(lz_per) |
87 |
axis2=__cross(self.__axis,axis1) |
axis2=_cross(self.__axis,axis1) |
88 |
axis2/=math.sqrt(axis2) |
lax2=numarray.dot(axis2,axis2) |
89 |
return z0*self.__axis+z1*(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.__point0 |
91 |
else: |
else: |
92 |
return x |
return x |
93 |
def __cross(x, y): |
def _cross(x, y): |
94 |
""" |
""" |
95 |
Returns the cross product of x and y |
Returns the cross product of x and y |
96 |
""" |
""" |
97 |
return numarray.array([x[1] * y[2] - x[2] * y[1], x[2] * y[0] - y[0] * x[2], x[0] * y[1] - y[1] * x[0]], _TYPE) |
return numarray.array([x[1] * y[2] - x[2] * y[1], x[2] * y[0] - x[0] * y[2], x[0] * y[1] - x[1] * y[0]], _TYPE) |
98 |
|
|
99 |
class Dilation(Transformation): |
class Dilation(Transformation): |
100 |
""" |
""" |