/[escript]/trunk/pycad/test/python/run_pycad_test.py
ViewVC logotype

Annotation of /trunk/pycad/test/python/run_pycad_test.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 925 - (hide annotations)
Wed Jan 10 22:40:00 2007 UTC (14 years, 3 months ago) by gross
File MIME type: text/x-python
File size: 69929 byte(s)
testing for CurvedLoop added.
1 gross 905 # $Id: run_visualization_interface.py 798 2006-08-04 01:05:36Z gross $
2    
3     __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
4     http://www.access.edu.au
5     Primary Business: Queensland, Australia"""
6     __license__="""Licensed under the Open Software License version 3.0
7     http://www.opensource.org/licenses/osl-3.0.php"""
8     import sys
9     import unittest
10 gross 907 import math
11 gross 905 import numarray
12     from esys.pycad import *
13    
14     try:
15     PYCAD_TEST_DATA=os.environ['PYCAD_TEST_DATA']
16     except KeyError:
17     PYCAD_TEST_DATA='.'
18    
19     try:
20     PYCAD_WORKDIR=os.environ['PYCAD_WORKDIR']
21     except KeyError:
22     PYCAD_WORKDIR='.'
23    
24     PYCAD_TEST_MESH_PATH=PYCAD_TEST_DATA+"/data_meshes/"
25     PYCAD_WORKDIR_PATH=PYCAD_WORKDIR+"/"
26    
27 gross 907 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    
31 gross 912 class Test_PyCAD_Transformations(unittest.TestCase):
32 gross 905 ABS_TOL=1.e-8
33     def __distance(self,x,y):
34     return math.sqrt(numarray.dot(x-y,x-y))
35     def test_Translation_x(self):
36     t=Translation([1,0,0])
37     s0=t([1,0,0])
38     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
39     self.failUnless(self.__distance(s0,numarray.array([2,0,0]))<self.ABS_TOL,"s0 is wrong.")
40     s1=t([0,1,0])
41     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
42     self.failUnless(self.__distance(s1,numarray.array([1,1,0]))<self.ABS_TOL,"s1 is wrong.")
43     s2=t([0,0,1])
44     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
45     self.failUnless(self.__distance(s2,numarray.array([1,0,1]))<self.ABS_TOL,"s2 is wrong.")
46     def test_Translation_y(self):
47     t=Translation([0,1,0])
48     s0=t([1,0,0])
49     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
50     self.failUnless(self.__distance(s0,numarray.array([1,1,0]))<self.ABS_TOL,"s0 is wrong.")
51     s1=t([0,1,0])
52     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
53     self.failUnless(self.__distance(s1,numarray.array([0,2,0]))<self.ABS_TOL,"s1 is wrong.")
54     s2=t([0,0,1])
55     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
56     self.failUnless(self.__distance(s2,numarray.array([0,1,1]))<self.ABS_TOL,"s2 is wrong.")
57     def test_Translation_z(self):
58     t=Translation([0,0,1])
59     s0=t([1,0,0])
60     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
61     self.failUnless(self.__distance(s0,numarray.array([1,0,1]))<self.ABS_TOL,"s0 is wrong.")
62     s1=t([0,1,0])
63     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
64     self.failUnless(self.__distance(s1,numarray.array([0,1,1]))<self.ABS_TOL,"s1 is wrong.")
65     s2=t([0,0,1])
66     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
67     self.failUnless(self.__distance(s2,numarray.array([0,0,2]))<self.ABS_TOL,"s2 is wrong.")
68     def test_Dilation_0_two(self):
69     t=Dilation(2.)
70     s0=t([1,0,0])
71     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
72     self.failUnless(self.__distance(s0,numarray.array([2,0,0]))<self.ABS_TOL,"s0 is wrong.")
73     s1=t([0,1,0])
74     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
75     self.failUnless(self.__distance(s1,numarray.array([0,2,0]))<self.ABS_TOL,"s1 is wrong.")
76     s2=t([0,0,1])
77     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
78     self.failUnless(self.__distance(s2,numarray.array([0,0,2]))<self.ABS_TOL,"s2 is wrong.")
79     def test_Dilation_0_half(self):
80     t=Dilation(0.5)
81     s0=t([1,0,0])
82     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
83     self.failUnless(self.__distance(s0,numarray.array([0.5,0,0]))<self.ABS_TOL,"s0 is wrong.")
84     s1=t([0,1,0])
85     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
86     self.failUnless(self.__distance(s1,numarray.array([0,0.5,0]))<self.ABS_TOL,"s1 is wrong.")
87     s2=t([0,0,1])
88     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
89     self.failUnless(self.__distance(s2,numarray.array([0,0,0.5]))<self.ABS_TOL,"s2 is wrong.")
90     def test_Dilation_x_two(self):
91     t=Dilation(2.,[1.,0.,0.])
92     s0=t([1,0,0])
93     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
94     self.failUnless(self.__distance(s0,numarray.array([1,0,0]))<self.ABS_TOL,"s0 is wrong.")
95     s0_1=t([0,0,0])
96     self.failUnless(isinstance(s0_1,numarray.NumArray),"s0_1 is not a numarray object.")
97     self.failUnless(self.__distance(s0_1,numarray.array([-1.,0,0]))<self.ABS_TOL,"s0_1 is wrong.")
98     s1=t([0,1,0])
99     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
100     self.failUnless(self.__distance(s1,numarray.array([-1,2,0]))<self.ABS_TOL,"s1 is wrong.")
101     s2=t([0,0,1])
102     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
103     self.failUnless(self.__distance(s2,numarray.array([-1.,0,2]))<self.ABS_TOL,"s2 is wrong.")
104     def test_Dilation_x_half(self):
105     t=Dilation(0.5,[1.,0.,0.])
106     s0=t([1,0,0])
107     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
108     self.failUnless(self.__distance(s0,numarray.array([1.,0,0]))<self.ABS_TOL,"s0 is wrong.")
109     s0_1=t([0,0,0])
110     self.failUnless(isinstance(s0_1,numarray.NumArray),"s0_1 is not a numarray object.")
111     self.failUnless(self.__distance(s0_1,numarray.array([.5,0,0]))<self.ABS_TOL,"s0_1 is wrong.")
112     s1=t([0,1,0])
113     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
114     self.failUnless(self.__distance(s1,numarray.array([0.5,0.5,0]))<self.ABS_TOL,"s1 is wrong.")
115     s2=t([0,0,1])
116     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
117     self.failUnless(self.__distance(s2,numarray.array([0.5,0,0.5]))<self.ABS_TOL,"s2 is wrong.")
118     def test_Dilation_y_two(self):
119     t=Dilation(2.,[0.,1.,0.])
120     s0=t([1,0,0])
121     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
122     self.failUnless(self.__distance(s0,numarray.array([2.,-1.,0]))<self.ABS_TOL,"s0 is wrong.")
123     s1_1=t([0,0,0])
124     self.failUnless(isinstance(s1_1,numarray.NumArray),"s1_1 is not a numarray object.")
125     self.failUnless(self.__distance(s1_1,numarray.array([0.,-1.,0]))<self.ABS_TOL,"s1_1 is wrong.")
126     s1=t([0,1,0])
127     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
128     self.failUnless(self.__distance(s1,numarray.array([0.,1.,0]))<self.ABS_TOL,"s1 is wrong.")
129     s2=t([0,0,1])
130     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
131     self.failUnless(self.__distance(s2,numarray.array([0.,-1.,2]))<self.ABS_TOL,"s2 is wrong.")
132     def test_Dilation_y_half(self):
133     t=Dilation(0.5,[0.,1.,0.])
134     s0=t([1,0,0])
135     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
136     self.failUnless(self.__distance(s0,numarray.array([0.5,0.5,0]))<self.ABS_TOL,"s0 is wrong.")
137     s1_1=t([0,0,0])
138     self.failUnless(isinstance(s1_1,numarray.NumArray),"s1_1 is not a numarray object.")
139     self.failUnless(self.__distance(s1_1,numarray.array([0,0.5,0]))<self.ABS_TOL,"s1_1 is wrong.")
140     s1=t([0,1,0])
141     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
142     self.failUnless(self.__distance(s1,numarray.array([0.,1.,0]))<self.ABS_TOL,"s1 is wrong.")
143     s2=t([0,0,1])
144     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
145     self.failUnless(self.__distance(s2,numarray.array([0.,0.5,0.5]))<self.ABS_TOL,"s2 is wrong.")
146     def test_Dilation_z_two(self):
147     t=Dilation(2.,[0.,0.,1.])
148     s0=t([1,0,0])
149     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
150     self.failUnless(self.__distance(s0,numarray.array([2.,0.,-1.]))<self.ABS_TOL,"s0 is wrong.")
151     s2_1=t([0,0,0])
152     self.failUnless(isinstance(s2_1,numarray.NumArray),"s2_1 is not a numarray object.")
153     self.failUnless(self.__distance(s2_1,numarray.array([0.,0.,-1.]))<self.ABS_TOL,"s2_1 is wrong.")
154     s1=t([0,1,0])
155     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
156     self.failUnless(self.__distance(s1,numarray.array([0.,2.,-1.]))<self.ABS_TOL,"s1 is wrong.")
157     s2=t([0,0,1])
158     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
159     self.failUnless(self.__distance(s2,numarray.array([0.,0.,1.]))<self.ABS_TOL,"s2 is wrong.")
160     def test_Dilation_z_half(self):
161     t=Dilation(0.5,[0.,0.,1.])
162     s0=t([1,0,0])
163     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
164     self.failUnless(self.__distance(s0,numarray.array([0.5,0.,0.5]))<self.ABS_TOL,"s0 is wrong.")
165     s2_1=t([0,0,0])
166     self.failUnless(isinstance(s2_1,numarray.NumArray),"s2_1 is not a numarray object.")
167     self.failUnless(self.__distance(s2_1,numarray.array([0,0,0.5]))<self.ABS_TOL,"s2_1 is wrong.")
168     s1=t([0,1,0])
169     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
170     self.failUnless(self.__distance(s1,numarray.array([0.,0.5,0.5]))<self.ABS_TOL,"s1 is wrong.")
171     s2=t([0,0,1])
172     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
173     self.failUnless(self.__distance(s2,numarray.array([0.,0.,1.]))<self.ABS_TOL,"s2 is wrong.")
174     def test_Reflection_x_offset0(self):
175     t=Reflection([1.,0.,0.])
176     s0=t([1,0,0])
177     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
178     self.failUnless(self.__distance(s0,numarray.array([-1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
179     s1=t([0,1,0])
180     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
181     self.failUnless(self.__distance(s1,numarray.array([0,1,0]))<self.ABS_TOL,"s1 is wrong.")
182     s2=t([0,0,1])
183     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
184     self.failUnless(self.__distance(s2,numarray.array([0,0,1]))<self.ABS_TOL,"s2 is wrong.")
185     s=t([1,2,3])
186     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
187     self.failUnless(self.__distance(s,numarray.array([-1.,2,3]))<self.ABS_TOL,"s is wrong.")
188     def test_Reflection_x_offset2(self):
189     t=Reflection([-2.,0.,0.],offset=-4)
190     s0=t([1,0,0])
191     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
192     self.failUnless(self.__distance(s0,numarray.array([3.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
193     s1=t([0,1,0])
194     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
195     self.failUnless(self.__distance(s1,numarray.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.")
196     s2=t([0,0,1])
197     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
198     self.failUnless(self.__distance(s2,numarray.array([4,0,1]))<self.ABS_TOL,"s2 is wrong.")
199     s=t([1,2,3])
200     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
201     self.failUnless(self.__distance(s,numarray.array([3.,2,3]))<self.ABS_TOL,"s is wrong.")
202     def test_Reflection_x_offset2_vector(self):
203     t=Reflection([1.,0.,0.],offset=[2,0,0])
204     s0=t([1,0,0])
205     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
206     self.failUnless(self.__distance(s0,numarray.array([3.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
207     s1=t([0,1,0])
208     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
209     self.failUnless(self.__distance(s1,numarray.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.")
210     s2=t([0,0,1])
211     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
212     self.failUnless(self.__distance(s2,numarray.array([4,0,1]))<self.ABS_TOL,"s2 is wrong.")
213     s=t([1,2,3])
214     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.")
216 gross 907 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 gross 916 t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=90*DEG)
302 gross 907 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 gross 910 self.failUnless(self.__distance(s1,numarray.array([0.,0,1.]))<self.ABS_TOL,"s1 is wrong.")
308 gross 907 s2=t([0,0,1])
309     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
310 gross 910 self.failUnless(self.__distance(s2,numarray.array([0.,-1.,0.]))<self.ABS_TOL,"s2 is wrong.")
311 gross 907 def test_Rotatation_x_30_0(self):
312 gross 916 t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=30*DEG)
313 gross 907 s0=t([1,0,0])
314     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
315     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
316     s1=t([0,1,0])
317     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.")
319     self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
320 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))<0.,"s1 has wrong orientation.")
321 gross 907 s2=t([0,0,1])
322     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.")
324     self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
325 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))<0.,"s2 has wrong orientation.")
326 gross 907 def test_Rotatation_x_330_0(self):
327 gross 916 t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=330*DEG)
328 gross 907 s0=t([1,0,0])
329     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
330     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
331     s1=t([0,1,0])
332     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.")
334     self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
335 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))>0.,"s1 has wrong orientation.")
336 gross 907 s2=t([0,0,1])
337     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.")
339     self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
340 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.")
341 gross 907 def test_Rotatation_x_90(self):
342 gross 916 t=Rotatation(axis=[-1.,0.,0.],point=[2.,0.,0.],angle=90*DEG)
343 gross 907 s0=t([1,0,0])
344     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
345     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
346     s1=t([0,1,0])
347     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
348 gross 910 self.failUnless(self.__distance(s1,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s1 is wrong.")
349 gross 907 s2=t([0,0,1])
350     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
351 gross 910 self.failUnless(self.__distance(s2,numarray.array([0.,1.,0.]))<self.ABS_TOL,"s2 is wrong.")
352 gross 907 def test_Rotatation_x_30(self):
353 gross 916 t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=30*DEG)
354 gross 907 s0=t([1,0,0])
355     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
356     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
357     s1=t([0,1,0])
358     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.")
360     self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
361 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.")
362 gross 907 s2=t([0,0,1])
363     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.")
365     self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
366 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.")
367 gross 907 def test_Rotatation_x_330(self):
368 gross 916 t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=330*DEG)
369 gross 907 s0=t([1,0,0])
370     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
371     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
372     s1=t([0,1,0])
373     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.")
375     self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
376 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.")
377 gross 907 s2=t([0,0,1])
378     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.")
380     self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
381 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.")
382 gross 907 def test_Rotatation_y_90_0(self):
383 gross 916 t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=90*DEG)
384 gross 907 s0=t([1,0,0])
385     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
386 gross 910 self.failUnless(self.__distance(s0,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s0 is wrong.")
387 gross 907 s1=t([0,5,0])
388     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.")
390     s2=t([0,0,1])
391     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
392 gross 910 self.failUnless(self.__distance(s2,numarray.array([1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
393 gross 907 def test_Rotatation_y_30_0(self):
394 gross 916 t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=30*DEG)
395 gross 907 s0=t([1,0,0])
396     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.")
398     self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
399 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))<0.,"s0 has wrong orientation.")
400 gross 907 s1=t([0,5,0])
401     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.")
403     s2=t([0,0,1])
404     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.")
406     self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
407 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))<0.,"s2 has wrong orientation.")
408 gross 907 def test_Rotatation_y_330_0(self):
409 gross 916 t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=330*DEG)
410 gross 907 s0=t([1,0,0])
411     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.")
413     self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
414 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))>0.,"s0 has wrong orientation.")
415 gross 907 s1=t([0,1,0])
416     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.")
418     s2=t([0,0,1])
419     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.")
421     self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
422 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.")
423 gross 907 def test_Rotatation_y_90(self):
424 gross 916 t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=90*DEG)
425 gross 907 s0=t([1,0,0])
426     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
427 gross 910 self.failUnless(self.__distance(s0,numarray.array([0.,0,1.]))<self.ABS_TOL,"s0 is wrong.")
428     s1=t([0,5,0])
429 gross 907 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
430 gross 910 self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
431 gross 907 s2=t([0,0,1])
432     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
433 gross 910 self.failUnless(self.__distance(s2,numarray.array([-1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
434 gross 907 def test_Rotatation_y_30(self):
435 gross 916 t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=30*DEG)
436 gross 907 s0=t([1,0,0])
437     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.")
439     self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
440 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.")
441 gross 907 s1=t([0,1,0])
442     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.")
444     s2=t([0,0,1])
445     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.")
447     self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
448 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.")
449 gross 907 def test_Rotatation_y_330(self):
450 gross 916 t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=330*DEG)
451 gross 907 s0=t([1,0,0])
452     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.")
454     self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
455 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.")
456 gross 907 s1=t([0,1,0])
457     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.")
459     s2=t([0,0,1])
460     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.")
462     self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
463 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.")
464 gross 907 def test_Rotatation_z_90_0(self):
465 gross 916 t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=90*DEG)
466 gross 907 s0=t([1,0,0])
467     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
468 gross 910 self.failUnless(self.__distance(s0,numarray.array([0.,1,0.]))<self.ABS_TOL,"s0 is wrong.")
469 gross 907 s1=t([0,5,0])
470     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
471 gross 910 self.failUnless(self.__distance(s1,numarray.array([-5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
472 gross 907 s2=t([0,0,1])
473     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.")
475     def test_Rotatation_z_30_0(self):
476 gross 916 t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=30*DEG)
477 gross 907 s0=t([1,0,0])
478     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.")
480     self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
481 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))<0.,"s0 has wrong orientation.")
482 gross 907 s1=t([0,5,0])
483     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.")
485     self.failUnless(abs(s1[1]/5.-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
486 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,5,0]),numarray.array([0.,0.,1.]))<0.,"s1 has wrong orientation.")
487 gross 907 s2=t([0,0,1])
488     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.")
490     def test_Rotatation_z_330_0(self):
491 gross 916 t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=330*DEG)
492 gross 907 s0=t([1,0,0])
493     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.")
495     self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
496 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))>0.,"s0 has wrong orientation.")
497 gross 907 s1=t([0,5,0])
498     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.")
500     self.failUnless(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
501 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.")
502 gross 907 def test_Rotatation_z_90(self):
503 gross 916 t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=90*DEG)
504 gross 907 s0=t([1,0,0])
505     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
506 gross 910 self.failUnless(self.__distance(s0,numarray.array([0.,-1,0.]))<self.ABS_TOL,"s0 is wrong.")
507     s1=t([0,5,0])
508 gross 907 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
509 gross 910 self.failUnless(self.__distance(s1,numarray.array([5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
510 gross 907 s2=t([0,0,1])
511     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.")
513     def test_Rotatation_z_30(self):
514 gross 916 t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=30*DEG)
515 gross 907 s0=t([1,0,0])
516     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.")
518     self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
519 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.")
520 gross 907 s1=t([0,1,0])
521     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.")
523     self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
524 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.")
525 gross 907 s2=t([0,0,1])
526     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.")
528     def test_Rotatation_z_330(self):
529 gross 916 t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=330*DEG)
530 gross 907 s0=t([1,0,0])
531     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.")
533     self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
534 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.")
535 gross 907 s1=t([0,1,0])
536     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.")
538     self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
539 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.")
540 gross 907 s2=t([0,0,1])
541     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.")
543 gross 910 def test_Rotatation_x_90_1(self):
544 gross 916 t=Rotatation(point=[0.,0.,1.],axis=[1.,0.,0.],angle=90*DEG)
545 gross 910 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 gross 916 t=Rotatation(point=[1.,0.,0.],axis=[0.,1.,0.],angle=90*DEG)
556 gross 910 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 gross 916 t=Rotatation(point=[0.,1.,0.],axis=[0.,0.,1.],angle=90*DEG)
567 gross 910 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 gross 916 t=Rotatation(axis=[1.,1.,1.],angle=90*DEG)
578 gross 910 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 gross 912
597     class Test_PyCAD_Primitives(unittest.TestCase):
598     def setUp(self):
599 gross 915 resetGlobalPrimitiveIdCounter()
600 gross 912
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 gross 915 self.failUnless(not id==Primitive().getID(),"id number is not unique")
607 gross 912
608 gross 916 hs=p.getPrimitives()
609 gross 912 self.failUnless(len(hs)==0,"history should be empty.")
610    
611 gross 916 ps=p.getConstructionPoints()
612 gross 912 self.failUnless(len(ps)==0,"point set should be empty.")
613    
614     def test_point(self):
615     p=Point(1.,2.,3.,local_scale=9.)
616    
617     id=p.getID()
618     self.failUnless(isinstance(id,int),"id number is not an integer")
619 gross 915 self.failUnless(not id==Primitive().getID(),"id number is not unique")
620 gross 912
621 gross 915 # check history:
622 gross 916 hs=p.getPrimitives()
623 gross 912 self.failUnless(len(hs)==1,"history must have length 1.")
624     self.failUnless(p in hs,"history must contain point p")
625    
626 gross 915 # check incolved points:
627 gross 916 ps=p.getConstructionPoints()
628 gross 912 self.failUnless(len(ps)==1,"point set must have length 1.")
629     self.failUnless(p in ps,"point set must contain point p")
630    
631 gross 915 # check coordinates:
632 gross 912 c=p.getCoordinates()
633     self.failUnless(isinstance(c,numarray.NumArray),"coordinates are not a numarray object.")
634     self.failUnless(c[0]==1.,"x coordinate is not 1.")
635     self.failUnless(c[1]==2.,"y coordinate is not 2.")
636     self.failUnless(c[2]==3.,"z coordinate is not 3.")
637    
638 gross 915 # reset coordinates:
639     p.setCoordinates([-1.,-2.,-3.])
640 gross 912 c=p.getCoordinates()
641     self.failUnless(isinstance(c,numarray.NumArray),"new coordinates are not a numarray object.")
642     self.failUnless(c[0]==-1.,"new x coordinate is not -1.")
643     self.failUnless(c[1]==-2.,"new y coordinate is not -2.")
644     self.failUnless(c[2]==-3.,"new z coordinate is not -3.")
645    
646 gross 915 # check for a colocated point:
647 gross 912 self.failUnless(p.isColocated(Point(-1.,-2.,-3.)),"colocation not detected.")
648 gross 916 self.failUnless(not p.isColocated(numarray.array([-1.,-2.,-3.])),"colocation with numarray representation not detected.")
649     self.failUnless(not p.isColocated(Point(1.,-2.,-3.)),"false colocation detected.")
650     self.failUnless(not p.isColocated(Point(0.,0.,0.)),"false colocation with origin detected.")
651 gross 912
652 gross 915 # check for local length scale
653 gross 912 l=p.getLocalScale()
654     self.failUnless(l==9.,"refinement scale is not 9.")
655    
656 gross 915 # check for new local length scale
657 gross 912 p.setLocalScale(3.)
658     l=p.getLocalScale()
659     self.failUnless(l==3.,"new refinement scale is not 3.")
660    
661 gross 915 # negative value shouldn't work.
662     self.failUnlessRaises(ValueError,p.setLocalScale,-3.)
663    
664     # copy:
665     an_other_p=p.copy()
666     self.failUnless(isinstance(an_other_p ,Point),"copy is not a point")
667     self.failUnless(not an_other_p.getID() == p.getID(),"copy has same Id")
668     self.failUnless(p.isColocated(an_other_p),"p is not colocated with its copy.")
669     self.failUnless(an_other_p.isColocated(p),"the copy is not colocated with p.")
670     self.failUnless(an_other_p.getLocalScale()==3.,"copy has wrong local scale.")
671    
672     # modify by Transformation:
673     p.modifyBy(Dilation(-1))
674     self.failUnless(p.isColocated(Point(1.,2.,3.)),"in-place transformation failed")
675    
676     # apply Transformation:
677     dil_p=p.apply(Dilation(4))
678     self.failUnless(dil_p.isColocated(Point(4.,8.,12.)),"applying transformation failed")
679     self.failUnless(not dil_p.getID() == p.getID(),"transformed point has same Id")
680     self.failUnless(dil_p.getLocalScale()==3.,"transformed point has wrong local scale.")
681    
682     # overloaded add:
683     shift_p=p+[1,1,1]
684     self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by list failed")
685     self.failUnless(not shift_p.getID() == p.getID(),"shift by list has same Id")
686     self.failUnless(shift_p.getLocalScale()==3.,"shift by list has wrong local scale.")
687    
688     shift_p=p+numarray.array([1,1,1])
689     self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by numarray failed")
690     self.failUnless(not shift_p.getID() == p.getID(),"shift by numarray has same Id")
691     self.failUnless(shift_p.getLocalScale()==3.,"shift by numarray has wrong local scale.")
692     # overloaded minus
693     shift_p=p-[1,1,1]
694     self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -list failed")
695     self.failUnless(not shift_p.getID() == p.getID(),"shift by -list has same Id")
696     self.failUnless(shift_p.getLocalScale()==3.,"shift by -list has wrong local scale.")
697    
698     shift_p=p-numarray.array([1,1,1])
699     self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -numarray failed")
700     self.failUnless(not shift_p.getID() == p.getID(),"shift by -numarray has same Id")
701     self.failUnless(shift_p.getLocalScale()==3.,"shift by -numarray has wrong local scale.")
702     # overloaded inplace add:
703     p+=[1,1,1]
704     self.failUnless(p.isColocated(Point(2,3.,4)),"modification by list shift failed")
705    
706     p+=numarray.array([1,1,1])
707     self.failUnless(p.isColocated(Point(3,4,5)),"modification by numarray shift failed")
708    
709     # overloaded inplace add:
710     p-=[1,1,1]
711     self.failUnless(p.isColocated(Point(2,3,4)),"modification by -list shift failed")
712    
713     p-=numarray.array([1,1,1])
714     self.failUnless(p.isColocated(Point(1,2.,3)),"modification by -numarray shift failed")
715    
716     #overloaded multiplication:
717     mult_p=2*p
718     self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying int factor failed")
719     self.failUnless(not mult_p.getID() == p.getID(),"shift by int factor has same Id")
720     self.failUnless(mult_p.getLocalScale()==3.,"shift by int factor has wrong local scale.")
721    
722     mult_p=2.*p
723     self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying float factor failed")
724     self.failUnless(not mult_p.getID() == p.getID(),"shift by float factor has same Id")
725     self.failUnless(mult_p.getLocalScale()==3.,"shift by float factor has wrong local scale.")
726    
727     mult_p=Dilation(2)*p
728     self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying Dilation factor failed")
729     self.failUnless(not mult_p.getID() == p.getID(),"shift by Dilation factor has same Id")
730     self.failUnless(mult_p.getLocalScale()==3.,"shift by Dilation factor has wrong local scale.")
731    
732     #overloaded inplace multiplication:
733     p*=2
734     self.failUnless(p.isColocated(Point(2,4,6)),"applying in-place int factor failed")
735    
736     p*=2.
737     self.failUnless(p.isColocated(Point(4,8,12)),"applying in-place float factor failed")
738    
739     p*=Dilation(2)
740     self.failUnless(p.isColocated(Point(8,16,24)),"applying in-place Dilation factor failed")
741    
742     # get gmsh code
743     code=p.getGmshCommand(2.)
744     self.failUnless("Point(1) = {8.0 , 16.0, 24.0 , 6.0 };"== code, "wrong gmsh code")
745    
746 gross 916 def test_spline(self):
747     p0=Point(0,0,0,0.1)
748     p1=Point(1,1,1,0.2)
749     p2=Point(2,2,2,0.3)
750     p3=Point(3,3,3,0.4)
751     p4=Point(1,2,3)
752    
753     self.failUnlessRaises(TypeError,Spline,p0)
754     c=Spline(p0,p1,p2,p3)
755 gross 915
756 gross 916 self.failUnless(len(c) == 4, "wrong spline curve length")
757     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
758     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
759    
760 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
761     self.failUnless(not c.isColocated(Spline(p0,p1,p2)),"spline is colocated with spline of different length.")
762     self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
763     self.failUnless(c.isColocated(Spline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
764     self.failUnless(c.isColocated(Spline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
765     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
766    
767 gross 916 co=c.getControlPoints()
768     self.failUnless(co[0]==p0, "1st control point is wrong.")
769     self.failUnless(co[1]==p1, "2nd control point is wrong.")
770     self.failUnless(co[2]==p2, "3rd control point is wrong.")
771     self.failUnless(co[3]==p3, "4th control point is wrong.")
772    
773     c.setLocalScale(3.)
774     co=c.getControlPoints()
775     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
776     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
777     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
778     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
779    
780     code=c.getGmshCommand()
781     self.failUnless(code == "Spline(6) = {1, 2, 3, 4};", "gmsh command wrong.")
782    
783     h=c.getPrimitives()
784     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
785     self.failUnless(p0 in h, "missing p0 in history.")
786     self.failUnless(p1 in h, "missing p1 in history.")
787     self.failUnless(p2 in h, "missing p2 in history.")
788     self.failUnless(p3 in h, "missing p3 in history.")
789     self.failUnless(c in h, "missing spline curve in history.")
790    
791     cp=c.copy()
792 gross 919 cpcp=cp.getControlPoints()
793 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
794 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
795     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
796     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
797     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
798     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
799 gross 916
800     c.modifyBy(Dilation(-1.))
801 gross 919 cp=c.getControlPoints()
802 gross 916 self.failUnless(c.isColocated(Spline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
803     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
804     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
805     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
806     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
807    
808     dc=c.apply(Dilation(-1.))
809 gross 919 dccp=dc.getControlPoints()
810 gross 916 self.failUnless(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
811     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
812     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
813     self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
814     self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
815    
816    
817     def test_BezierCurve(self):
818     p0=Point(0,0,0,0.1)
819     p1=Point(1,1,1,0.2)
820     p2=Point(2,2,2,0.3)
821     p3=Point(3,3,3,0.4)
822     p4=Point(1,2,3)
823    
824     self.failUnlessRaises(TypeError,BezierCurve,p0)
825     c=BezierCurve(p0,p1,p2,p3)
826    
827     self.failUnless(len(c) == 4, "wrong spline curve length")
828     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
829     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
830    
831 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
832     self.failUnless(not c.isColocated(BezierCurve(p0,p1,p2)),"spline is colocated with spline of different length.")
833     self.failUnless(not c.isColocated(BezierCurve(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
834     self.failUnless(c.isColocated(BezierCurve(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
835     self.failUnless(c.isColocated(BezierCurve(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
836     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
837    
838 gross 916 co=c.getControlPoints()
839     self.failUnless(co[0]==p0, "1st control point is wrong.")
840     self.failUnless(co[1]==p1, "2nd control point is wrong.")
841     self.failUnless(co[2]==p2, "3rd control point is wrong.")
842     self.failUnless(co[3]==p3, "4th control point is wrong.")
843    
844     c.setLocalScale(3.)
845     co=c.getControlPoints()
846     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
847     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
848     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
849     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
850    
851     code=c.getGmshCommand()
852     self.failUnless(code == "Bezier(6) = {1, 2, 3, 4};", "gmsh command wrong.")
853    
854     h=c.getPrimitives()
855     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
856     self.failUnless(p0 in h, "missing p0 in history.")
857     self.failUnless(p1 in h, "missing p1 in history.")
858     self.failUnless(p2 in h, "missing p2 in history.")
859     self.failUnless(p3 in h, "missing p3 in history.")
860     self.failUnless(c in h, "missing spline curve in history.")
861    
862     cp=c.copy()
863 gross 919 cpcp=cp.getControlPoints()
864 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
865 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
866     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
867     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
868     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
869     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
870 gross 916
871     c.modifyBy(Dilation(-1.))
872 gross 919 cp=c.getControlPoints()
873 gross 916 self.failUnless(c.isColocated(BezierCurve(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
874     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
875     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
876     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
877     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
878    
879     dc=c.apply(Dilation(-1.))
880 gross 919 dccp=dc.getControlPoints()
881 gross 916 self.failUnless(dc.isColocated(BezierCurve(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
882     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
883     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
884     self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
885     self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
886    
887     def test_BSpline(self):
888     p0=Point(0,0,0,0.1)
889     p1=Point(1,1,1,0.2)
890     p2=Point(2,2,2,0.3)
891     p3=Point(3,3,3,0.4)
892     p4=Point(1,2,3)
893    
894     self.failUnlessRaises(TypeError,BSpline,p0)
895     c=BSpline(p0,p1,p2,p3)
896    
897     self.failUnless(len(c) == 4, "wrong spline curve length")
898     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
899     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
900    
901 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
902     self.failUnless(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
903     self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
904     self.failUnless(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
905     self.failUnless(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
906     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
907    
908 gross 916 co=c.getControlPoints()
909     self.failUnless(co[0]==p0, "1st control point is wrong.")
910     self.failUnless(co[1]==p1, "2nd control point is wrong.")
911     self.failUnless(co[2]==p2, "3rd control point is wrong.")
912     self.failUnless(co[3]==p3, "4th control point is wrong.")
913    
914     c.setLocalScale(3.)
915     co=c.getControlPoints()
916     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
917     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
918     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
919     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
920    
921     code=c.getGmshCommand()
922     self.failUnless(code == "BSpline(6) = {1, 2, 3, 4};", "gmsh command wrong.")
923    
924     h=c.getPrimitives()
925     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
926     self.failUnless(p0 in h, "missing p0 in history.")
927     self.failUnless(p1 in h, "missing p1 in history.")
928     self.failUnless(p2 in h, "missing p2 in history.")
929     self.failUnless(p3 in h, "missing p3 in history.")
930     self.failUnless(c in h, "missing spline curve in history.")
931    
932     cp=c.copy()
933 gross 919 cpcp=cp.getControlPoints()
934 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
935 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
936     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
937     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
938     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
939     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
940 gross 916
941     c.modifyBy(Dilation(-1.))
942 gross 919 cp=c.getControlPoints()
943 gross 916 self.failUnless(c.isColocated(BSpline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
944     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
945     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
946     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
947     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
948    
949     dc=c.apply(Dilation(-1.))
950 gross 919 dccp=dc.getControlPoints()
951 gross 916 self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
952     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
953     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
954     self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
955     self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
956    
957     def test_LineSegment(self):
958     p0=Point(0,0,0,0.1)
959     p1=Point(1,1,1,0.2)
960     p4=Point(1,2,3)
961    
962     self.failUnlessRaises(TypeError,Line,p0)
963     self.failUnlessRaises(TypeError,Line,p0,p1,p4)
964    
965     c=Line(p0,p1)
966    
967     self.failUnless(len(c) == 2, "wrong spline curve length")
968     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
969     self.failUnless(c.getEndPoint()==p1, "wrong end point of spline curve")
970    
971 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
972     self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
973     self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
974     self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
975     self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
976    
977 gross 916 co=c.getControlPoints()
978     self.failUnless(co[0]==p0, "1st control point is wrong.")
979     self.failUnless(co[1]==p1, "2nd control point is wrong.")
980    
981     c.setLocalScale(3.)
982     co=c.getControlPoints()
983     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
984     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
985    
986     code=c.getGmshCommand()
987     self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.")
988    
989     h=c.getPrimitives()
990     self.failUnless(len(h) == 3, "number of primitives in history is wrong.")
991     self.failUnless(p0 in h, "missing p0 in history.")
992     self.failUnless(p1 in h, "missing p1 in history.")
993     self.failUnless(c in h, "missing spline curve in history.")
994    
995     cp=c.copy()
996 gross 919 cpcp=cp.getControlPoints()
997 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
998 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
999     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1000     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1001 gross 916
1002     c.modifyBy(Dilation(-1.))
1003 gross 919 cp=c.getControlPoints()
1004 gross 916 self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1005     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
1006     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
1007    
1008     dc=c.apply(Dilation(-1.))
1009 gross 919 dccp=dc.getControlPoints()
1010 gross 916 self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1011     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1012     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1013    
1014 gross 917 def test_arc(self):
1015     center=Point(0,0,0,0.1)
1016     p_start=Point(1,1,1,0.2)
1017     p_end=Point(1,2,3)
1018 gross 919 p4=Point(10,2,3)
1019 gross 917
1020     self.failUnlessRaises(TypeError,Arc,Primitive())
1021 gross 916
1022 gross 917 c=Arc(center,p_start,p_end)
1023    
1024     self.failUnless(c.getCenterPoint()==center, "wrong center point")
1025     self.failUnless(c.getStartPoint()==p_start, "wrong start point")
1026     self.failUnless(c.getEndPoint()==p_end, "wrong end point")
1027    
1028     code=c.getGmshCommand()
1029 gross 919 self.failUnless(code == "Circle(6) = {2, 1, 3};", "gmsh command wrong.")
1030 gross 917
1031 gross 919 self.failUnless(not c.isColocated(p4),"spline is colocated with point.")
1032     self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1033     self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1034     self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.")
1035     self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.")
1036     self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1037     self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.")
1038    
1039 gross 917 h=c.getPrimitives()
1040     self.failUnless(len(h) == 4, "number of primitives in history is wrong.")
1041     self.failUnless(center in h, "missing center in history.")
1042     self.failUnless(p_start in h, "missing p_start in history.")
1043     self.failUnless(p_end in h, "missing p_end in history.")
1044     self.failUnless(c in h, "missing spline curve in history.")
1045    
1046    
1047     c.setLocalScale(3.)
1048     self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1049     self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1050     self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1051    
1052     cp=c.copy()
1053     self.failUnless(isinstance(cp,Arc), "copy returns is not an arc.")
1054     self.failUnless(not cp == c, "copy returns same arc.")
1055 gross 919 self.failUnless(cp.isColocated(Arc(center,p_start,p_end)),"arc is not colocated with its copy.")
1056     self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1057     self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1058     self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1059 gross 917
1060     c.modifyBy(Dilation(-1.))
1061 gross 919 self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1062     self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.")
1063     self.failUnless(c.getStartPoint() == p_start,"wrong start point after dilation.")
1064     self.failUnless(c.getEndPoint() == p_end,"wrong end point after dilation.")
1065 gross 917
1066     dc=c.apply(Dilation(-1.))
1067 gross 919 self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1068     self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1069     self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1070     self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1071 gross 917
1072 gross 923 def test_CurveLoop(self):
1073     p0=Point(0,0,0,0.1)
1074     p1=Point(1,1,1,0.2)
1075     p2=Point(2,2,2,0.3)
1076     p3=Point(3,3,3,0.4)
1077     p4=Point(1,2,3)
1078 gross 925 p5=Point(10,20,3)
1079     p6=Point(1,2,30)
1080 gross 917
1081 gross 923 l01=Line(p0,p1)
1082     l12=Arc(p3,p1,p2)
1083     l20=Spline(p2,p4,p0)
1084    
1085     lx=Line(p2,p3)
1086     ly=Line(p3,p1)
1087    
1088     c=CurveLoop(l01,l12,l20)
1089     c=CurveLoop(l01,l20,l12)
1090     self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,lx,l20,msg="loop detected.")
1091     self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,l20,l20,msg="douple not detected.")
1092     self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,l20,ly,msg="loop detected.")
1093    
1094     code=c.getGmshCommand()
1095     self.failUnless(code == "Line Loop(14) = {8, 9, 10};", "gmsh command wrong.")
1096    
1097 gross 925
1098     self.failUnless(not c.isColocated(p4),"CurveLoop is colocated with point.")
1099     self.failUnless(c.isColocated(c),"CurveLoop is not colocated with its self.")
1100     self.failUnless(c.isColocated(CurveLoop(l01,l12,l20)),"CurveLoop is not colocated with its copy.")
1101     self.failUnless(c.isColocated(CurveLoop(l20,l01,l12)),"CurveLoop is not colocated with its copy with shifted points.")
1102     self.failUnless(c.isColocated(CurveLoop(l20,l12,l01)),"CurveLoop is not colocated with its copy with shuffled points.")
1103     self.failUnless(not c.isColocated(CurveLoop(lx,ly,l12)),"CurveLoop is colocated with different CurveLoop.")
1104    
1105     self.failUnless(len(c) == 3, "wrong length")
1106    
1107     c.setLocalScale(3.)
1108     self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.")
1109     self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.")
1110     self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.")
1111     self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.")
1112    
1113 gross 923 cc=c.getCurves()
1114     self.failUnless(len(cc) == 3, "too many curves.")
1115     self.failUnless(l01 in cc, "l01 is missing")
1116     self.failUnless(l12 in cc, "l12 is missing")
1117     self.failUnless(l20 in cc, "l20 is missing")
1118 gross 925
1119     p=c.getPrimitives()
1120     self.failUnless(len(p) == 9, "too many primitives.")
1121     self.failUnless(l01 in p, "l01 is missing")
1122     self.failUnless(l12 in p, "l21 is missing")
1123     self.failUnless(l20 in p, "l20 is missing")
1124     self.failUnless(p0 in p, "p0 is missing")
1125     self.failUnless(p1 in p, "p1 is missing")
1126     self.failUnless(p2 in p, "p2 is missing")
1127     self.failUnless(p3 in p, "p3 is missing")
1128     self.failUnless(p4 in p, "p4 is missing")
1129    
1130     cp=c.copy()
1131     self.failUnless(isinstance(cp,CurveLoop), "copy returns is not an arc.")
1132     self.failUnless(not cp == c, "copy equals source")
1133     cc=cp.getCurves()
1134     self.failUnless(len(cc) == 3, "too many primitives in copy.")
1135     self.failUnless(not l01 in cc,"copy uses l01.")
1136     self.failUnless(not l12 in cc,"copy uses l12.")
1137     self.failUnless(not l20 in cc,"copy uses l20.")
1138    
1139     p0_m=Point(0,0,0)
1140     p1_m=Point(-1,-1,-1)
1141     p2_m=Point(-2,-2,-2)
1142     p3_m=Point(-3,-3,-3)
1143     p4_m=Point(-1,-2,-3)
1144    
1145     l01_m=Line(p0_m,p1_m)
1146     l12_m=Arc(p3_m,p1_m,p2_m)
1147     l20_m=Spline(p2_m,p4_m,p0_m)
1148    
1149     dc=c.apply(Dilation(-1.))
1150     self.failUnless(dc.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"dilation is wrong.")
1151     cc=dc.getCurves()
1152     self.failUnless(len(cc) == 3, "too many primitives in dilation result.")
1153     self.failUnless(not l01 in cc,"l01 is in dilation result.")
1154     self.failUnless(not l12 in cc,"l12 is in dilation result.")
1155     self.failUnless(not l20 in cc,"l20 is in dilation result.")
1156    
1157     c.modifyBy(Dilation(-1.))
1158     self.failUnless(c.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"inplace dilation is wrong.")
1159     cc=c.getCurves()
1160     self.failUnless(len(cc) == 3, "too many primitives in modified object.")
1161     self.failUnless(l01 in cc,"l01 missed in modified object.")
1162     self.failUnless(l12 in cc,"l12 missed in modified object.")
1163     self.failUnless(l20 in cc,"l20 missed in modified object.")
1164    
1165 gross 923
1166 gross 905 if __name__ == '__main__':
1167     suite = unittest.TestSuite()
1168 gross 912 suite.addTest(unittest.makeSuite(Test_PyCAD_Transformations))
1169     suite.addTest(unittest.makeSuite(Test_PyCAD_Primitives))
1170 gross 905 s=unittest.TextTestRunner(verbosity=2).run(suite)
1171     if s.wasSuccessful():
1172     sys.exit(0)
1173     else:
1174     sys.exit(1)

  ViewVC Help
Powered by ViewVC 1.1.26