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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 912 - (show annotations)
Wed Dec 6 03:29:49 2006 UTC (11 years, 5 months ago) by gross
File MIME type: text/x-python
File size: 43093 byte(s)
modellib.WriteVTK has been rewritten. Instead of only three data objects scalar,
vector, tensor it takes now up to 20 data objects data0 ... data19 and writes it into a 
single VTK file. There is also the possibilty to define individiual name tags name0,..., name19.
If no name is given the corresponding attribute name of the Link target is used. 
This simplifies the usage and increases efficiency.



1 # $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 import math
11 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 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 class Test_PyCAD_Transformations(unittest.TestCase):
32 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 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(self.__distance(s1,numarray.array([0.,0,1.]))<self.ABS_TOL,"s1 is wrong.")
308 s2=t([0,0,1])
309 self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
310 self.failUnless(self.__distance(s2,numarray.array([0.,-1.,0.]))<self.ABS_TOL,"s2 is wrong.")
311 def test_Rotatation_x_30_0(self):
312 t=Rotatation(point1=[1.,0.,0.],angle=30*DEG)
313 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 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))<0.,"s1 has wrong orientation.")
321 s2=t([0,0,1])
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 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))<0.,"s2 has wrong orientation.")
326 def test_Rotatation_x_330_0(self):
327 t=Rotatation(point1=[1.,0.,0.],angle=330*DEG)
328 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 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))>0.,"s1 has wrong orientation.")
336 s2=t([0,0,1])
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 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.")
341 def test_Rotatation_x_90(self):
342 t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=90*DEG)
343 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 self.failUnless(self.__distance(s1,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s1 is wrong.")
349 s2=t([0,0,1])
350 self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
351 self.failUnless(self.__distance(s2,numarray.array([0.,1.,0.]))<self.ABS_TOL,"s2 is wrong.")
352 def test_Rotatation_x_30(self):
353 t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=30*DEG)
354 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 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.")
362 s2=t([0,0,1])
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 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.")
367 def test_Rotatation_x_330(self):
368 t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=330*DEG)
369 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 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.")
377 s2=t([0,0,1])
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 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.")
382 def test_Rotatation_y_90_0(self):
383 t=Rotatation(point1=[0.,1.,0.],angle=90*DEG)
384 s0=t([1,0,0])
385 self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
386 self.failUnless(self.__distance(s0,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s0 is wrong.")
387 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 self.failUnless(self.__distance(s2,numarray.array([1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
393 def test_Rotatation_y_30_0(self):
394 t=Rotatation(point1=[0.,1.,0.],angle=30*DEG)
395 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 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))<0.,"s0 has wrong orientation.")
400 s1=t([0,5,0])
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 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))<0.,"s2 has wrong orientation.")
408 def test_Rotatation_y_330_0(self):
409 t=Rotatation(point1=[0.,1.,0.],angle=330*DEG)
410 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 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))>0.,"s0 has wrong orientation.")
415 s1=t([0,1,0])
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 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.")
423 def test_Rotatation_y_90(self):
424 t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=90*DEG)
425 s0=t([1,0,0])
426 self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
427 self.failUnless(self.__distance(s0,numarray.array([0.,0,1.]))<self.ABS_TOL,"s0 is wrong.")
428 s1=t([0,5,0])
429 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
430 self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
431 s2=t([0,0,1])
432 self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
433 self.failUnless(self.__distance(s2,numarray.array([-1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
434 def test_Rotatation_y_30(self):
435 t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=30*DEG)
436 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 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.")
441 s1=t([0,1,0])
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 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.")
449 def test_Rotatation_y_330(self):
450 t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=330*DEG)
451 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 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.")
456 s1=t([0,1,0])
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 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.")
464 def test_Rotatation_z_90_0(self):
465 t=Rotatation(point1=[0.,0.,1.],angle=90*DEG)
466 s0=t([1,0,0])
467 self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
468 self.failUnless(self.__distance(s0,numarray.array([0.,1,0.]))<self.ABS_TOL,"s0 is wrong.")
469 s1=t([0,5,0])
470 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
471 self.failUnless(self.__distance(s1,numarray.array([-5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
472 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 t=Rotatation(point1=[0.,0.,1.],angle=30*DEG)
477 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 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))<0.,"s0 has wrong orientation.")
482 s1=t([0,5,0])
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 self.failUnless(numarray.dot(_cross(s1,[0,5,0]),numarray.array([0.,0.,1.]))<0.,"s1 has wrong orientation.")
487 s2=t([0,0,1])
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 t=Rotatation(point1=[0.,0.,1.],angle=330*DEG)
492 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 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))>0.,"s0 has wrong orientation.")
497 s1=t([0,5,0])
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 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.")
502 def test_Rotatation_z_90(self):
503 t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=90*DEG)
504 s0=t([1,0,0])
505 self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
506 self.failUnless(self.__distance(s0,numarray.array([0.,-1,0.]))<self.ABS_TOL,"s0 is wrong.")
507 s1=t([0,5,0])
508 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
509 self.failUnless(self.__distance(s1,numarray.array([5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
510 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 t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=30*DEG)
515 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 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.")
520 s1=t([0,1,0])
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 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.")
525 s2=t([0,0,1])
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 t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=330*DEG)
530 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 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.")
535 s1=t([0,1,0])
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 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.")
540 s2=t([0,0,1])
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 def test_Rotatation_x_90_1(self):
544 t=Rotatation(point0=[0.,0.,1.],point1=[1.,0.,1.],angle=90*DEG)
545 s0=t([1,0,0])
546 self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
547 self.failUnless(self.__distance(s0,numarray.array([1.,1,1.]))<self.ABS_TOL,"s0 is wrong.")
548 s1=t([0,1,0])
549 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
550 self.failUnless(self.__distance(s1,numarray.array([0.,1,2.]))<self.ABS_TOL,"s1 is wrong.")
551 s2=t([0,0,1])
552 self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
553 self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
554 def test_Rotatation_y_90_1(self):
555 t=Rotatation(point0=[1.,0.,0.],point1=[1.,1.,0.],angle=90*DEG)
556 s0=t([1,0,0])
557 self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
558 self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
559 s1=t([0,1,0])
560 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
561 self.failUnless(self.__distance(s1,numarray.array([1.,1,1.]))<self.ABS_TOL,"s1 is wrong.")
562 s2=t([0,0,1])
563 self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
564 self.failUnless(self.__distance(s2,numarray.array([2.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
565 def test_Rotatation_z_90_1(self):
566 t=Rotatation(point0=[0.,1.,0.],point1=[0.,1.,1.],angle=90*DEG)
567 s0=t([1,0,0])
568 self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
569 self.failUnless(self.__distance(s0,numarray.array([1.,2,0.]))<self.ABS_TOL,"s0 is wrong.")
570 s1=t([0,1,0])
571 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
572 self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
573 s2=t([0,0,1])
574 self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
575 self.failUnless(self.__distance(s2,numarray.array([1.,1,1.]))<self.ABS_TOL,"s2 is wrong.")
576 def test_Rotatation_diag_90_0(self):
577 t=Rotatation(point1=[1.,1.,1.],angle=90*DEG)
578 s0=t([1,-1,0])
579 self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
580 self.failUnless(abs(numarray.dot(s0,s0)-2.)<self.ABS_TOL,"s0 length is wrong.")
581 self.failUnless(abs(numarray.dot(s0,numarray.array([1,-1,0])))<self.ABS_TOL,"s0 angle is wrong.")
582 self.failUnless(numarray.dot(_cross(s0,[1,-1,0]),numarray.array([1.,1.,1.]))<0.,"s0 has wrong orientation.")
583 s1=t([0,1,-1])
584 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
585 self.failUnless(abs(numarray.dot(s1,s1)-2.)<self.ABS_TOL,"s1 length is wrong.")
586 self.failUnless(abs(numarray.dot(s1,numarray.array([0,1,-1])))<self.ABS_TOL,"s1 angle is wrong.")
587 self.failUnless(numarray.dot(_cross(s1,[0,1,-1]),numarray.array([1.,1.,1.]))<0.,"s1 has wrong orientation.")
588 s2=t([-1,0,1])
589 self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
590 self.failUnless(abs(numarray.dot(s2,s2)-2.)<self.ABS_TOL,"s2 length is wrong.")
591 self.failUnless(abs(numarray.dot(s2,numarray.array([-1,0,1])))<self.ABS_TOL,"s2 angle is wrong.")
592 self.failUnless(numarray.dot(_cross(s2,[-1,0,1]),numarray.array([1.,1.,1.]))<0.,"s2 has wrong orientation.")
593 s3=t([1,1,1])
594 self.failUnless(isinstance(s3,numarray.NumArray),"s3 is not a numarray object.")
595 self.failUnless(self.__distance(s3,numarray.array([1.,1,1.]))<self.ABS_TOL,"s3 is wrong.")
596
597 class Test_PyCAD_Primitives(unittest.TestCase):
598 def setUp(self):
599 global global_primitive_id_counter
600 self.id0=global_primitive_id_counter
601
602 def test_baseclass(self):
603 p=Primitive()
604
605 id=p.getID()
606 print id
607 self.failUnless(isinstance(id,int),"id number is not an integer")
608 self.failUnless(id==self.id0,"id number is expected to be %s."%self.id0)
609
610 self.failUnless(not p.isPoint(),"generic primitive is not a point.")
611 self.failUnless(not p.isCurve(),"generic primitive is not a curve.")
612 self.failUnless(not p.isCurveLoop(),"generic primitive is not a curve loop.")
613 self.failUnless(not p.isSurface(),"generic primitive is not a surface.")
614 self.failUnless(not p.isSurfaceLoop(),"generic primitive is not a surface loop.")
615
616 hs=p.getHistory()
617 self.failUnless(isinstance(hs,set),"history must be a set")
618 self.failUnless(len(hs)==0,"history should be empty.")
619
620 ps=p.getPoints()
621 self.failUnless(isinstance(ps,set),"point set must be a set")
622 self.failUnless(len(ps)==0,"point set should be empty.")
623
624 p.setLocalScale(1.23)
625
626 def test_point(self):
627 p=Point(1.,2.,3.,local_scale=9.)
628
629 id=p.getID()
630 self.failUnless(isinstance(id,int),"id number is not an integer")
631 self.failUnless(id==self.id0,"id number is expected to be %s"%self.id0)
632
633 hs=p.getHistory()
634 self.failUnless(isinstance(hs,set),"history must be a set")
635 self.failUnless(len(hs)==1,"history must have length 1.")
636 self.failUnless(p in hs,"history must contain point p")
637
638 ps=p.getPoints()
639 self.failUnless(isinstance(ps,set),"point set must be a set")
640 self.failUnless(len(ps)==1,"point set must have length 1.")
641 self.failUnless(p in ps,"point set must contain point p")
642
643 c=p.getCoordinates()
644 self.failUnless(isinstance(c,numarray.NumArray),"coordinates are not a numarray object.")
645 self.failUnless(c[0]==1.,"x coordinate is not 1.")
646 self.failUnless(c[1]==2.,"y coordinate is not 2.")
647 self.failUnless(c[2]==3.,"z coordinate is not 3.")
648
649 p.setCoordinates(-1.,-2.,-3.)
650 c=p.getCoordinates()
651 self.failUnless(isinstance(c,numarray.NumArray),"new coordinates are not a numarray object.")
652 self.failUnless(c[0]==-1.,"new x coordinate is not -1.")
653 self.failUnless(c[1]==-2.,"new y coordinate is not -2.")
654 self.failUnless(c[2]==-3.,"new z coordinate is not -3.")
655
656 self.failUnless(p.isColocated(Point(-1.,-2.,-3.)),"colocation not detected.")
657 self.failUnless(p.isColocated(numarray.array([-1.,-2.,-3.])),"colocation with numarray representation not detected.")
658 self.failUnless(not p.isColocated(numarray.array([1.,-2.,-3.])),"false colocation detected.")
659 self.failUnless(not p.isColocated(numarray.array([0.,0.,0.])),"false colocation with origin detected.")
660
661 l=p.getLocalScale()
662 self.failUnless(l==9.,"refinement scale is not 9.")
663
664 p.setLocalScale(3.)
665 l=p.getLocalScale()
666 self.failUnless(l==3.,"new refinement scale is not 3.")
667 self.UnlessRaises(ValueError,p.setLocalScale,-3.)
668
669 if __name__ == '__main__':
670 suite = unittest.TestSuite()
671 suite.addTest(unittest.makeSuite(Test_PyCAD_Transformations))
672 suite.addTest(unittest.makeSuite(Test_PyCAD_Primitives))
673 s=unittest.TextTestRunner(verbosity=2).run(suite)
674 if s.wasSuccessful():
675 sys.exit(0)
676 else:
677 sys.exit(1)

  ViewVC Help
Powered by ViewVC 1.1.26