revision 907 by gross, Wed Nov 22 09:54:19 2006 UTC revision 915 by gross, Thu Dec 14 06:12:53 2006 UTC
# Line 28  def _cross(x, y): Line 28  def _cross(x, y):
28      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]])      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]])
29
30
32     ABS_TOL=1.e-8     ABS_TOL=1.e-8
33     def __distance(self,x,y):     def __distance(self,x,y):
34         return math.sqrt(numarray.dot(x-y,x-y))         return math.sqrt(numarray.dot(x-y,x-y))
304          self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")          self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
305          s1=t([0,1,0])          s1=t([0,1,0])
306          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
307          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(self.__distance(s1,numarray.array([0.,0,1.]))<self.ABS_TOL,"s1 is wrong.")
self.failUnless(abs(s1[1]-math.cos(90*DEG))<self.ABS_TOL,"s1 angle is wrong.")
self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))>0.,"s1 has wrong orientation.")
308          s2=t([0,0,1])          s2=t([0,0,1])
309          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
310          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(self.__distance(s2,numarray.array([0.,-1.,0.]))<self.ABS_TOL,"s2 is wrong.")
self.failUnless(abs(s2[2]-math.cos(90*DEG))<self.ABS_TOL,"s2 angle is wrong.")
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.")
311     def test_Rotatation_x_30_0(self):     def test_Rotatation_x_30_0(self):
312          t=Rotatation(point1=[1.,0.,0.],angle=30*DEG)          t=Rotatation(point1=[1.,0.,0.],angle=30*DEG)
313          s0=t([1,0,0])          s0=t([1,0,0])
317          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
318          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
319          self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")          self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
320          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))>0.,"s1 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))<0.,"s1 has wrong orientation.")
321          s2=t([0,0,1])          s2=t([0,0,1])
322          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
323          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
324          self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")          self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
325          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))<0.,"s2 has wrong orientation.")
326     def test_Rotatation_x_330_0(self):     def test_Rotatation_x_330_0(self):
327          t=Rotatation(point1=[1.,0.,0.],angle=330*DEG)          t=Rotatation(point1=[1.,0.,0.],angle=330*DEG)
328          s0=t([1,0,0])          s0=t([1,0,0])
332          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
333          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
334          self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")          self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
335          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))<0.,"s1 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))>0.,"s1 has wrong orientation.")
336          s2=t([0,0,1])          s2=t([0,0,1])
337          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
338          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
339          self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")          self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
340          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))<0.,"s2 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.")
341     def test_Rotatation_x_90(self):     def test_Rotatation_x_90(self):
342          t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=90*DEG)          t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=90*DEG)
343          s0=t([1,0,0])          s0=t([1,0,0])
345          self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")          self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
346          s1=t([0,1,0])          s1=t([0,1,0])
347          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
348          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(self.__distance(s1,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s1 is wrong.")
self.failUnless(abs(s1[1]-math.cos(90*DEG))<self.ABS_TOL,"s1 angle is wrong.")
self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.")
349          s2=t([0,0,1])          s2=t([0,0,1])
350          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
351          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(self.__distance(s2,numarray.array([0.,1.,0.]))<self.ABS_TOL,"s2 is wrong.")
self.failUnless(abs(s2[2]-math.cos(90*DEG))<self.ABS_TOL,"s2 angle is wrong.")
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.")
352     def test_Rotatation_x_30(self):     def test_Rotatation_x_30(self):
353          t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=30*DEG)          t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=30*DEG)
354          s0=t([1,0,0])          s0=t([1,0,0])
358          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
359          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
360          self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")          self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
361          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.")
362          s2=t([0,0,1])          s2=t([0,0,1])
363          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
364          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
365          self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")          self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
366          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.")
367     def test_Rotatation_x_330(self):     def test_Rotatation_x_330(self):
368          t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=330*DEG)          t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=330*DEG)
369          s0=t([1,0,0])          s0=t([1,0,0])
373          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
374          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
375          self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")          self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
376          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.")
377          s2=t([0,0,1])          s2=t([0,0,1])
378          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
379          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
380          self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")          self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
381          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.")
382     def test_Rotatation_y_90_0(self):     def test_Rotatation_y_90_0(self):
383          t=Rotatation(point1=[0.,1.,0.],angle=90*DEG)          t=Rotatation(point1=[0.,1.,0.],angle=90*DEG)
384          s0=t([1,0,0])          s0=t([1,0,0])
385          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
386          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(self.__distance(s0,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s0 is wrong.")
self.failUnless(abs(s0[0]-math.cos(90*DEG))<self.ABS_TOL,"s0 angle is wrong.")
self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))>0.,"s0 has wrong orientation.")
387          s1=t([0,5,0])          s1=t([0,5,0])
388          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
389          self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")          self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
390          s2=t([0,0,1])          s2=t([0,0,1])
391          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
392          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(self.__distance(s2,numarray.array([1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
self.failUnless(abs(s2[2]-math.cos(90*DEG))<self.ABS_TOL,"s2 angle is wrong.")
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.")
393     def test_Rotatation_y_30_0(self):     def test_Rotatation_y_30_0(self):
394          t=Rotatation(point1=[0.,1.,0.],angle=30*DEG)          t=Rotatation(point1=[0.,1.,0.],angle=30*DEG)
395          s0=t([1,0,0])          s0=t([1,0,0])
396          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
397          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
398          self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")          self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
399          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))>0.,"s0 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))<0.,"s0 has wrong orientation.")
400          s1=t([0,5,0])          s1=t([0,5,0])
401          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
402          self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")          self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
404          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
405          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
406          self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")          self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
407          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))<0.,"s2 has wrong orientation.")
408     def test_Rotatation_y_330_0(self):     def test_Rotatation_y_330_0(self):
409          t=Rotatation(point1=[0.,1.,0.],angle=330*DEG)          t=Rotatation(point1=[0.,1.,0.],angle=330*DEG)
410          s0=t([1,0,0])          s0=t([1,0,0])
411          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
412          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
413          self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")          self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
414          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))<0.,"s0 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))>0.,"s0 has wrong orientation.")
415          s1=t([0,1,0])          s1=t([0,1,0])
416          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
417          self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")          self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
419          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
420          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
421          self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")          self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
422          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))<0.,"s2 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.")
423     def test_Rotatation_y_90(self):     def test_Rotatation_y_90(self):
424          t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=90*DEG)          t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=90*DEG)
425          s0=t([1,0,0])          s0=t([1,0,0])
426          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
427          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(self.__distance(s0,numarray.array([0.,0,1.]))<self.ABS_TOL,"s0 is wrong.")
428          self.failUnless(abs(s0[0]-math.cos(90*DEG))<self.ABS_TOL,"s0 angle is wrong.")          s1=t([0,5,0])
self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.")
s1=t([0,1,0])
429          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
430          self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")          self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
431          s2=t([0,0,1])          s2=t([0,0,1])
432          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
433          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(self.__distance(s2,numarray.array([-1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
self.failUnless(abs(s2[2]-math.cos(90*DEG))<self.ABS_TOL,"s2 angle is wrong.")
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.")
434     def test_Rotatation_y_30(self):     def test_Rotatation_y_30(self):
435          t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=30*DEG)          t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=30*DEG)
436          s0=t([1,0,0])          s0=t([1,0,0])
437          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
438          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
439          self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")          self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
440          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.")
441          s1=t([0,1,0])          s1=t([0,1,0])
442          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
443          self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")          self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
445          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
446          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
447          self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")          self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
448          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.")
449     def test_Rotatation_y_330(self):     def test_Rotatation_y_330(self):
450          t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=330*DEG)          t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=330*DEG)
451          s0=t([1,0,0])          s0=t([1,0,0])
452          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
453          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
454          self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")          self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
455          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.")
456          s1=t([0,1,0])          s1=t([0,1,0])
457          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
458          self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")          self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
460          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
461          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")          self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
462          self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")          self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
463          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.")
464     def test_Rotatation_z_90_0(self):     def test_Rotatation_z_90_0(self):
465          t=Rotatation(point1=[0.,0.,1.],angle=90*DEG)          t=Rotatation(point1=[0.,0.,1.],angle=90*DEG)
466          s0=t([1,0,0])          s0=t([1,0,0])
467          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
468          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(self.__distance(s0,numarray.array([0.,1,0.]))<self.ABS_TOL,"s0 is wrong.")
self.failUnless(abs(s0[0]-math.cos(90*DEG))<self.ABS_TOL,"s0 angle is wrong.")
self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))>0.,"s0 has wrong orientation.")
469          s1=t([0,5,0])          s1=t([0,5,0])
470          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
471          self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(self.__distance(s1,numarray.array([-5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
self.failUnless(abs(s1[1]/5.-math.cos(90*DEG))<self.ABS_TOL,"s1 angle is wrong.")
self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.")
472          s2=t([0,0,1])          s2=t([0,0,1])
473          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
474          self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")          self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
478          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
479          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
480          self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")          self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
481          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))>0.,"s0 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))<0.,"s0 has wrong orientation.")
482          s1=t([0,5,0])          s1=t([0,5,0])
483          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
484          self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
485          self.failUnless(abs(s1[1]/5.-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")          self.failUnless(abs(s1[1]/5.-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
486          self.failUnless(numarray.dot(_cross(s1,[0,5,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s1,[0,5,0]),numarray.array([0.,0.,1.]))<0.,"s1 has wrong orientation.")
487          s2=t([0,0,1])          s2=t([0,0,1])
488          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
489          self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")          self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
493          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
494          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
495          self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")          self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
496          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))<0.,"s0 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))>0.,"s0 has wrong orientation.")
497          s1=t([0,5,0])          s1=t([0,5,0])
498          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
499          self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
500          self.failUnless(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")          self.failUnless(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
501          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))<0.,"s1 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.")
502     def test_Rotatation_z_90(self):     def test_Rotatation_z_90(self):
503          t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=90*DEG)          t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=90*DEG)
504          s0=t([1,0,0])          s0=t([1,0,0])
505          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
506          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(self.__distance(s0,numarray.array([0.,-1,0.]))<self.ABS_TOL,"s0 is wrong.")
507          self.failUnless(abs(s0[0]-math.cos(90*DEG))<self.ABS_TOL,"s0 angle is wrong.")          s1=t([0,5,0])
self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.")
s1=t([0,1,0])
508          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
509          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(self.__distance(s1,numarray.array([5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
self.failUnless(abs(s1[1]-math.cos(90*DEG))<self.ABS_TOL,"s1 angle is wrong.")
self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.")
510          s2=t([0,0,1])          s2=t([0,0,1])
511          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
512          self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")          self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
516          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
517          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
518          self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")          self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
519          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.")
520          s1=t([0,1,0])          s1=t([0,1,0])
521          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
522          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
523          self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")          self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
524          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.")
525          s2=t([0,0,1])          s2=t([0,0,1])
526          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
527          self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")          self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
531          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")          self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
532          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")          self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
533          self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")          self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
534          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.")
535          s1=t([0,1,0])          s1=t([0,1,0])
536          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")          self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
537          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")          self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
538          self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")          self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
539          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.")          self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.")
540          s2=t([0,0,1])          s2=t([0,0,1])
541          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")          self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
542          self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")          self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
543       def test_Rotatation_x_90_1(self):
544            t=Rotatation(point0=[0.,0.,1.],point1=[1.,0.,1.],angle=90*DEG)
545            s0=t([1,0,0])
546            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
547            self.failUnless(self.__distance(s0,numarray.array([1.,1,1.]))<self.ABS_TOL,"s0 is wrong.")
548            s1=t([0,1,0])
549            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
550            self.failUnless(self.__distance(s1,numarray.array([0.,1,2.]))<self.ABS_TOL,"s1 is wrong.")
551            s2=t([0,0,1])
552            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
553            self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
554       def test_Rotatation_y_90_1(self):
555            t=Rotatation(point0=[1.,0.,0.],point1=[1.,1.,0.],angle=90*DEG)
556            s0=t([1,0,0])
557            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
558            self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
559            s1=t([0,1,0])
560            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
561            self.failUnless(self.__distance(s1,numarray.array([1.,1,1.]))<self.ABS_TOL,"s1 is wrong.")
562            s2=t([0,0,1])
563            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
564            self.failUnless(self.__distance(s2,numarray.array([2.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
565       def test_Rotatation_z_90_1(self):
566            t=Rotatation(point0=[0.,1.,0.],point1=[0.,1.,1.],angle=90*DEG)
567            s0=t([1,0,0])
568            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
569            self.failUnless(self.__distance(s0,numarray.array([1.,2,0.]))<self.ABS_TOL,"s0 is wrong.")
570            s1=t([0,1,0])
571            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
572            self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
573            s2=t([0,0,1])
574            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
575            self.failUnless(self.__distance(s2,numarray.array([1.,1,1.]))<self.ABS_TOL,"s2 is wrong.")
576       def test_Rotatation_diag_90_0(self):
577            t=Rotatation(point1=[1.,1.,1.],angle=90*DEG)
578            s0=t([1,-1,0])
579            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
580            self.failUnless(abs(numarray.dot(s0,s0)-2.)<self.ABS_TOL,"s0 length is wrong.")
581            self.failUnless(abs(numarray.dot(s0,numarray.array([1,-1,0])))<self.ABS_TOL,"s0 angle is wrong.")
582            self.failUnless(numarray.dot(_cross(s0,[1,-1,0]),numarray.array([1.,1.,1.]))<0.,"s0 has wrong orientation.")
583            s1=t([0,1,-1])
584            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
585            self.failUnless(abs(numarray.dot(s1,s1)-2.)<self.ABS_TOL,"s1 length is wrong.")
586            self.failUnless(abs(numarray.dot(s1,numarray.array([0,1,-1])))<self.ABS_TOL,"s1 angle is wrong.")
587            self.failUnless(numarray.dot(_cross(s1,[0,1,-1]),numarray.array([1.,1.,1.]))<0.,"s1 has wrong orientation.")
588            s2=t([-1,0,1])
589            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
590            self.failUnless(abs(numarray.dot(s2,s2)-2.)<self.ABS_TOL,"s2 length is wrong.")
591            self.failUnless(abs(numarray.dot(s2,numarray.array([-1,0,1])))<self.ABS_TOL,"s2 angle is wrong.")
592            self.failUnless(numarray.dot(_cross(s2,[-1,0,1]),numarray.array([1.,1.,1.]))<0.,"s2 has wrong orientation.")
593            s3=t([1,1,1])
594            self.failUnless(isinstance(s3,numarray.NumArray),"s3 is not a numarray object.")
595            self.failUnless(self.__distance(s3,numarray.array([1.,1,1.]))<self.ABS_TOL,"s3 is wrong.")
596
598       def setUp(self):
599             resetGlobalPrimitiveIdCounter()
600
601       def test_baseclass(self):
602             p=Primitive()
603
604             id=p.getID()
605             self.failUnless(isinstance(id,int),"id number is not an integer")
606             self.failUnless(not id==Primitive().getID(),"id number is not unique")
607
608             self.failUnless(not p.isPoint(),"generic primitive is not a point.")
609             self.failUnless(not p.isCurve(),"generic primitive is not a curve.")
610             self.failUnless(not p.isCurveLoop(),"generic primitive is not a curve loop.")
611             self.failUnless(not p.isSurface(),"generic primitive is not a surface.")
612             self.failUnless(not p.isSurfaceLoop(),"generic primitive is not a surface loop.")
613
614             hs=p.getHistory()
615             self.failUnless(isinstance(hs,set),"history must be a set")
616             self.failUnless(len(hs)==0,"history should be empty.")
617
618             ps=p.getPoints()
619             self.failUnless(isinstance(ps,set),"point set must be a set")
620             self.failUnless(len(ps)==0,"point set should be empty.")
621
622             p.setLocalScale(1.23)
623
624       def test_point(self):
625           p=Point(1.,2.,3.,local_scale=9.)
626
627           id=p.getID()
628           self.failUnless(isinstance(id,int),"id number is not an integer")
629           self.failUnless(not id==Primitive().getID(),"id number is not unique")
630
631           # check history:
632           hs=p.getHistory()
633           self.failUnless(isinstance(hs,set),"history must be a set")
634           self.failUnless(len(hs)==1,"history must have length 1.")
635           self.failUnless(p in hs,"history must contain point p")
636
637           # check incolved points:
638           ps=p.getPoints()
639           self.failUnless(isinstance(ps,set),"point set must be a set")
640           self.failUnless(len(ps)==1,"point set must have length 1.")
641           self.failUnless(p in ps,"point set must contain point p")
642
643           # check coordinates:
644           c=p.getCoordinates()
645           self.failUnless(isinstance(c,numarray.NumArray),"coordinates are not a numarray object.")
646           self.failUnless(c[0]==1.,"x coordinate is not 1.")
647           self.failUnless(c[1]==2.,"y coordinate is not 2.")
648           self.failUnless(c[2]==3.,"z coordinate is not 3.")
649
650           # reset coordinates:
651           p.setCoordinates([-1.,-2.,-3.])
652           c=p.getCoordinates()
653           self.failUnless(isinstance(c,numarray.NumArray),"new coordinates are not a numarray object.")
654           self.failUnless(c[0]==-1.,"new x coordinate is not -1.")
655           self.failUnless(c[1]==-2.,"new y coordinate is not -2.")
656           self.failUnless(c[2]==-3.,"new z coordinate is not -3.")
657
658           # check for a colocated point:
659           self.failUnless(p.isColocated(Point(-1.,-2.,-3.)),"colocation not detected.")
660           self.failUnless(p.isColocated(numarray.array([-1.,-2.,-3.])),"colocation with numarray representation not detected.")
661           self.failUnless(not p.isColocated(numarray.array([1.,-2.,-3.])),"false colocation detected.")
662           self.failUnless(not p.isColocated(numarray.array([0.,0.,0.])),"false colocation with origin detected.")
663
664           # check for local length scale
665           l=p.getLocalScale()
666           self.failUnless(l==9.,"refinement scale is not 9.")
667
668           # check for new local length scale
669           p.setLocalScale(3.)
670           l=p.getLocalScale()
671           self.failUnless(l==3.,"new refinement scale is not 3.")
672
673           # negative value shouldn't work.
674           self.failUnlessRaises(ValueError,p.setLocalScale,-3.)
675
676           # copy:
677           an_other_p=p.copy()
678           self.failUnless(isinstance(an_other_p ,Point),"copy is not a point")
679           self.failUnless(not an_other_p.getID() == p.getID(),"copy has same Id")
680           self.failUnless(p.isColocated(an_other_p),"p is not colocated with its copy.")
681           self.failUnless(an_other_p.isColocated(p),"the copy is not colocated with p.")
682           self.failUnless(an_other_p.getLocalScale()==3.,"copy has wrong local scale.")
683
684           # modify by Transformation:
685           p.modifyBy(Dilation(-1))
686           self.failUnless(p.isColocated(Point(1.,2.,3.)),"in-place transformation failed")
687
688           # apply Transformation:
689           dil_p=p.apply(Dilation(4))
690           self.failUnless(dil_p.isColocated(Point(4.,8.,12.)),"applying transformation failed")
691           self.failUnless(not dil_p.getID() == p.getID(),"transformed point has same Id")
692           self.failUnless(dil_p.getLocalScale()==3.,"transformed point  has wrong local scale.")
693
695           shift_p=p+[1,1,1]
696           self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by list failed")
697           self.failUnless(not shift_p.getID() == p.getID(),"shift by list has same Id")
698           self.failUnless(shift_p.getLocalScale()==3.,"shift by list has wrong local scale.")
699
700           shift_p=p+numarray.array([1,1,1])
701           self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by numarray failed")
702           self.failUnless(not shift_p.getID() == p.getID(),"shift by numarray has same Id")
703           self.failUnless(shift_p.getLocalScale()==3.,"shift by numarray has wrong local scale.")
705           shift_p=p-[1,1,1]
706           self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -list failed")
707           self.failUnless(not shift_p.getID() == p.getID(),"shift by -list has same Id")
708           self.failUnless(shift_p.getLocalScale()==3.,"shift by -list has wrong local scale.")
709
710           shift_p=p-numarray.array([1,1,1])
711           self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -numarray failed")
712           self.failUnless(not shift_p.getID() == p.getID(),"shift by -numarray has same Id")
713           self.failUnless(shift_p.getLocalScale()==3.,"shift by -numarray has wrong local scale.")
715           p+=[1,1,1]
716           self.failUnless(p.isColocated(Point(2,3.,4)),"modification by list shift failed")
717
718           p+=numarray.array([1,1,1])
719           self.failUnless(p.isColocated(Point(3,4,5)),"modification by numarray shift failed")
720
722           p-=[1,1,1]
723           self.failUnless(p.isColocated(Point(2,3,4)),"modification by -list shift failed")
724
725           p-=numarray.array([1,1,1])
726           self.failUnless(p.isColocated(Point(1,2.,3)),"modification by -numarray shift failed")
727
729           mult_p=2*p
730           self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying int factor failed")
731           self.failUnless(not mult_p.getID() == p.getID(),"shift by int factor has same Id")
732           self.failUnless(mult_p.getLocalScale()==3.,"shift by int factor has wrong local scale.")
733
734           mult_p=2.*p
735           self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying float factor failed")
736           self.failUnless(not mult_p.getID() == p.getID(),"shift by float factor has same Id")
737           self.failUnless(mult_p.getLocalScale()==3.,"shift by float factor has wrong local scale.")
738
739           mult_p=Dilation(2)*p
740           self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying Dilation factor failed")
741           self.failUnless(not mult_p.getID() == p.getID(),"shift by Dilation factor has same Id")
742           self.failUnless(mult_p.getLocalScale()==3.,"shift by Dilation factor has wrong local scale.")
743
745           p*=2
746           self.failUnless(p.isColocated(Point(2,4,6)),"applying in-place int factor failed")
747
748           p*=2.
749           self.failUnless(p.isColocated(Point(4,8,12)),"applying in-place float factor failed")
750
751           p*=Dilation(2)
752           self.failUnless(p.isColocated(Point(8,16,24)),"applying in-place Dilation factor failed")
753
754           # get gmsh code
755           code=p.getGmshCommand(2.)
756           self.failUnless("Point(1) = {8.0 , 16.0, 24.0 , 6.0 };"== code, "wrong gmsh code")
757
758
759  if __name__ == '__main__':  if __name__ == '__main__':
760     suite = unittest.TestSuite()     suite = unittest.TestSuite()