revision 906 by gross, Mon Nov 20 11:23:24 2006 UTC revision 907 by gross, Wed Nov 22 09:54:19 2006 UTC
# Line 7  __license__="""Licensed under the Open S Line 7  __license__="""Licensed under the Open S
8  import sys  import sys
9  import unittest  import unittest
10    import math
11  import numarray  import numarray
12  from esys.pycad import *  from esys.pycad import *
13
# Line 23  except KeyError: Line 24  except KeyError:
26
27    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]])
29
30
32     ABS_TOL=1.e-8     ABS_TOL=1.e-8
33     def __distance(self,x,y):     def __distance(self,x,y):
# Line 208  class Test_PyCAD(unittest.TestCase): Line 213  class Test_PyCAD(unittest.TestCase):
213          s=t([1,2,3])          s=t([1,2,3])
214          self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")          self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
215          self.failUnless(self.__distance(s,numarray.array([3.,2,3]))<self.ABS_TOL,"s is wrong.")          self.failUnless(self.__distance(s,numarray.array([3.,2,3]))<self.ABS_TOL,"s is wrong.")
216       def test_Reflection_y_offset0(self):
217            t=Reflection([0.,1.,0.])
218            s0=t([1,0,0])
219            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
220            self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
221            s1=t([0,1,0])
222            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
223            self.failUnless(self.__distance(s1,numarray.array([0,-1,0]))<self.ABS_TOL,"s1 is wrong.")
224            s2=t([0,0,1])
225            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
226            self.failUnless(self.__distance(s2,numarray.array([0,0,1]))<self.ABS_TOL,"s2 is wrong.")
227            s=t([1,2,3])
228            self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
229            self.failUnless(self.__distance(s,numarray.array([1.,-2,3]))<self.ABS_TOL,"s is wrong.")
230       def test_Reflection_y_offset2(self):
231            t=Reflection([0.,-2.,0.],offset=-4)
232            s0=t([1,0,0])
233            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
234            self.failUnless(self.__distance(s0,numarray.array([1.,4,0.]))<self.ABS_TOL,"s0 is wrong.")
235            s1=t([0,1,0])
236            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
237            self.failUnless(self.__distance(s1,numarray.array([0,3,0]))<self.ABS_TOL,"s1 is wrong.")
238            s2=t([0,0,1])
239            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
240            self.failUnless(self.__distance(s2,numarray.array([0,4,1]))<self.ABS_TOL,"s2 is wrong.")
241            s=t([1,2,3])
242            self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
243            self.failUnless(self.__distance(s,numarray.array([1.,2,3]))<self.ABS_TOL,"s is wrong.")
244       def test_Reflection_y_offset2_vector(self):
245            t=Reflection([0.,1.,0.],offset=[0,2,0])
246            s0=t([1,0,0])
247            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
248            self.failUnless(self.__distance(s0,numarray.array([1.,4,0.]))<self.ABS_TOL,"s0 is wrong.")
249            s1=t([0,1,0])
250            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
251            self.failUnless(self.__distance(s1,numarray.array([0,3,0]))<self.ABS_TOL,"s1 is wrong.")
252            s2=t([0,0,1])
253            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
254            self.failUnless(self.__distance(s2,numarray.array([0,4,1]))<self.ABS_TOL,"s2 is wrong.")
255            s=t([1,2,3])
256            self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
257            self.failUnless(self.__distance(s,numarray.array([1.,2,3]))<self.ABS_TOL,"s is wrong.")
258       def test_Reflection_z_offset0(self):
259            t=Reflection([0.,0.,1.])
260            s0=t([1,0,0])
261            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
262            self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
263            s1=t([0,1,0])
264            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
265            self.failUnless(self.__distance(s1,numarray.array([0,1,0]))<self.ABS_TOL,"s1 is wrong.")
266            s2=t([0,0,1])
267            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
268            self.failUnless(self.__distance(s2,numarray.array([0,0,-1]))<self.ABS_TOL,"s2 is wrong.")
269            s=t([1,2,3])
270            self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
271            self.failUnless(self.__distance(s,numarray.array([1.,2,-3]))<self.ABS_TOL,"s is wrong.")
272       def test_Reflection_z_offset2(self):
273            t=Reflection([0.,0.,-2.],offset=-4)
274            s0=t([1,0,0])
275            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
276            self.failUnless(self.__distance(s0,numarray.array([1.,0,4.]))<self.ABS_TOL,"s0 is wrong.")
277            s1=t([0,1,0])
278            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
279            self.failUnless(self.__distance(s1,numarray.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.")
280            s2=t([0,0,1])
281            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
282            self.failUnless(self.__distance(s2,numarray.array([0,0,3]))<self.ABS_TOL,"s2 is wrong.")
283            s=t([1,2,3])
284            self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
285            self.failUnless(self.__distance(s,numarray.array([1.,2,1]))<self.ABS_TOL,"s is wrong.")
286       def test_Reflection_z_offset2_vector(self):
287            t=Reflection([0.,0.,1.],offset=[0,0,2])
288            s0=t([1,0,0])
289            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
290            self.failUnless(self.__distance(s0,numarray.array([1.,0,4.]))<self.ABS_TOL,"s0 is wrong.")
291            s1=t([0,1,0])
292            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
293            self.failUnless(self.__distance(s1,numarray.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.")
294            s2=t([0,0,1])
295            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
296            self.failUnless(self.__distance(s2,numarray.array([0,0,3]))<self.ABS_TOL,"s2 is wrong.")
297            s=t([1,2,3])
298            self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
299            self.failUnless(self.__distance(s,numarray.array([1.,2,1]))<self.ABS_TOL,"s is wrong.")
300       def test_Rotatation_x_90_0(self):
301            t=Rotatation(point1=[1.,0.,0.],angle=90*DEG)
302            s0=t([1,0,0])
303            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
304            self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
305            s1=t([0,1,0])
306            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.")
308            self.failUnless(abs(s1[1]-math.cos(90*DEG))<self.ABS_TOL,"s1 angle is wrong.")
309            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))>0.,"s1 has wrong orientation.")
310            s2=t([0,0,1])
311            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
312            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
313            self.failUnless(abs(s2[2]-math.cos(90*DEG))<self.ABS_TOL,"s2 angle is wrong.")
314            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.")
315       def test_Rotatation_x_30_0(self):
316            t=Rotatation(point1=[1.,0.,0.],angle=30*DEG)
317            s0=t([1,0,0])
318            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
319            self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
320            s1=t([0,1,0])
321            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
322            self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
323            self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
324            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))>0.,"s1 has wrong orientation.")
325            s2=t([0,0,1])
326            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
327            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
328            self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
329            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.")
330       def test_Rotatation_x_330_0(self):
331            t=Rotatation(point1=[1.,0.,0.],angle=330*DEG)
332            s0=t([1,0,0])
333            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
334            self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
335            s1=t([0,1,0])
336            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
337            self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
338            self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
339            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))<0.,"s1 has wrong orientation.")
340            s2=t([0,0,1])
341            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
342            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
343            self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
344            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))<0.,"s2 has wrong orientation.")
345       def test_Rotatation_x_90(self):
346            t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=90*DEG)
347            s0=t([1,0,0])
348            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
349            self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
350            s1=t([0,1,0])
351            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
352            self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
353            self.failUnless(abs(s1[1]-math.cos(90*DEG))<self.ABS_TOL,"s1 angle is wrong.")
354            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.")
355            s2=t([0,0,1])
356            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
357            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
358            self.failUnless(abs(s2[2]-math.cos(90*DEG))<self.ABS_TOL,"s2 angle is wrong.")
359            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.")
360       def test_Rotatation_x_30(self):
361            t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=30*DEG)
362            s0=t([1,0,0])
363            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
364            self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
365            s1=t([0,1,0])
366            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
367            self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
368            self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
369            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.")
370            s2=t([0,0,1])
371            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
372            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
373            self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
374            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.")
375       def test_Rotatation_x_330(self):
376            t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=330*DEG)
377            s0=t([1,0,0])
378            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
379            self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
380            s1=t([0,1,0])
381            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
382            self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
383            self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
384            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.")
385            s2=t([0,0,1])
386            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
387            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
388            self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
389            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.")
390       def test_Rotatation_y_90_0(self):
391            t=Rotatation(point1=[0.,1.,0.],angle=90*DEG)
392            s0=t([1,0,0])
393            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
394            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
395            self.failUnless(abs(s0[0]-math.cos(90*DEG))<self.ABS_TOL,"s0 angle is wrong.")
396            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))>0.,"s0 has wrong orientation.")
397            s1=t([0,5,0])
398            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
399            self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
400            s2=t([0,0,1])
401            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
402            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
403            self.failUnless(abs(s2[2]-math.cos(90*DEG))<self.ABS_TOL,"s2 angle is wrong.")
404            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.")
405       def test_Rotatation_y_30_0(self):
406            t=Rotatation(point1=[0.,1.,0.],angle=30*DEG)
407            s0=t([1,0,0])
408            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
409            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
410            self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
411            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))>0.,"s0 has wrong orientation.")
412            s1=t([0,5,0])
413            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
414            self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
415            s2=t([0,0,1])
416            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
417            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
418            self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
419            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.")
420       def test_Rotatation_y_330_0(self):
421            t=Rotatation(point1=[0.,1.,0.],angle=330*DEG)
422            s0=t([1,0,0])
423            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
424            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
425            self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
426            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))<0.,"s0 has wrong orientation.")
427            s1=t([0,1,0])
428            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
429            self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
430            s2=t([0,0,1])
431            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
432            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
433            self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
434            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))<0.,"s2 has wrong orientation.")
435       def test_Rotatation_y_90(self):
436            t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=90*DEG)
437            s0=t([1,0,0])
438            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
439            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
440            self.failUnless(abs(s0[0]-math.cos(90*DEG))<self.ABS_TOL,"s0 angle is wrong.")
441            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.")
442            s1=t([0,1,0])
443            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
444            self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
445            s2=t([0,0,1])
446            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
447            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
448            self.failUnless(abs(s2[2]-math.cos(90*DEG))<self.ABS_TOL,"s2 angle is wrong.")
449            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.")
450       def test_Rotatation_y_30(self):
451            t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=30*DEG)
452            s0=t([1,0,0])
453            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
454            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
455            self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
456            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.")
457            s1=t([0,1,0])
458            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
459            self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
460            s2=t([0,0,1])
461            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
462            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
463            self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
464            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.")
465       def test_Rotatation_y_330(self):
466            t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=330*DEG)
467            s0=t([1,0,0])
468            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
469            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
470            self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
471            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.")
472            s1=t([0,1,0])
473            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
474            self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
475            s2=t([0,0,1])
476            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
477            self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
478            self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
479            self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.")
480       def test_Rotatation_z_90_0(self):
481            t=Rotatation(point1=[0.,0.,1.],angle=90*DEG)
482            s0=t([1,0,0])
483            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
484            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
485            self.failUnless(abs(s0[0]-math.cos(90*DEG))<self.ABS_TOL,"s0 angle is wrong.")
486            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))>0.,"s0 has wrong orientation.")
487            s1=t([0,5,0])
488            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
489            self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
490            self.failUnless(abs(s1[1]/5.-math.cos(90*DEG))<self.ABS_TOL,"s1 angle is wrong.")
491            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.")
492            s2=t([0,0,1])
493            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
494            self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
495       def test_Rotatation_z_30_0(self):
496            t=Rotatation(point1=[0.,0.,1.],angle=30*DEG)
497            s0=t([1,0,0])
498            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
499            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
500            self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
501            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))>0.,"s0 has wrong orientation.")
502            s1=t([0,5,0])
503            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
504            self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
505            self.failUnless(abs(s1[1]/5.-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
506            self.failUnless(numarray.dot(_cross(s1,[0,5,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.")
507            s2=t([0,0,1])
508            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
509            self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
510       def test_Rotatation_z_330_0(self):
511            t=Rotatation(point1=[0.,0.,1.],angle=330*DEG)
512            s0=t([1,0,0])
513            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
514            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
515            self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
516            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))<0.,"s0 has wrong orientation.")
517            s1=t([0,5,0])
518            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
519            self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
520            self.failUnless(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
521            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))<0.,"s1 has wrong orientation.")
522       def test_Rotatation_z_90(self):
523            t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=90*DEG)
524            s0=t([1,0,0])
525            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
526            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
527            self.failUnless(abs(s0[0]-math.cos(90*DEG))<self.ABS_TOL,"s0 angle is wrong.")
528            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.")
529            s1=t([0,1,0])
530            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
531            self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
532            self.failUnless(abs(s1[1]-math.cos(90*DEG))<self.ABS_TOL,"s1 angle is wrong.")
533            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.")
534            s2=t([0,0,1])
535            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
536            self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
537       def test_Rotatation_z_30(self):
538            t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=30*DEG)
539            s0=t([1,0,0])
540            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
541            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
542            self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
543            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.")
544            s1=t([0,1,0])
545            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
546            self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
547            self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
548            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.")
549            s2=t([0,0,1])
550            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
551            self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
552       def test_Rotatation_z_330(self):
553            t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=330*DEG)
554            s0=t([1,0,0])
555            self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
556            self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
557            self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
558            self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.")
559            s1=t([0,1,0])
560            self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
561            self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
562            self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
563            self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.")
564            s2=t([0,0,1])
565            self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
566            self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
567  if __name__ == '__main__':  if __name__ == '__main__':
568     suite = unittest.TestSuite()     suite = unittest.TestSuite()