1 
gross 
905 
# $Id: run_visualization_interface.py 798 20060804 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/osl3.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.e8 
33 


def __distance(self,x,y): 
34 


return math.sqrt(numarray.dot(xy,xy)) 
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.)),"inplace 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=pnumarray.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 inplace int factor failed") 
735 



736 


p*=2. 
737 


self.failUnless(p.isColocated(Point(4,8,12)),"applying inplace float factor failed") 
738 



739 


p*=Dilation(2) 
740 


self.failUnless(p.isColocated(Point(8,16,24)),"applying inplace 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 


co=c.getControlPoints() 
761 


self.failUnless(co[0]==p0, "1st control point is wrong.") 
762 


self.failUnless(co[1]==p1, "2nd control point is wrong.") 
763 


self.failUnless(co[2]==p2, "3rd control point is wrong.") 
764 


self.failUnless(co[3]==p3, "4th control point is wrong.") 
765 



766 


c.setLocalScale(3.) 
767 


co=c.getControlPoints() 
768 


self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") 
769 


self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") 
770 


self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") 
771 


self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") 
772 



773 


code=c.getGmshCommand() 
774 


self.failUnless(code == "Spline(6) = {1, 2, 3, 4};", "gmsh command wrong.") 
775 



776 


h=c.getPrimitives() 
777 


self.failUnless(len(h) == 5, "number of primitives in history is wrong.") 
778 


self.failUnless(p0 in h, "missing p0 in history.") 
779 


self.failUnless(p1 in h, "missing p1 in history.") 
780 


self.failUnless(p2 in h, "missing p2 in history.") 
781 


self.failUnless(p3 in h, "missing p3 in history.") 
782 


self.failUnless(c in h, "missing spline curve in history.") 
783 



784 


cp=c.copy() 
785 


self.failUnless(not cp == c, "copy returns same spline curve.") 
786 


cpcp=cp.getControlPoints() 
787 


self.failUnless(p0.isColocated(cpcp[0]),"1st point of copy and source are not collocated.") 
788 


self.failUnless(p1.isColocated(cpcp[1]),"2nd point of copy and source are not collocated.") 
789 


self.failUnless(p2.isColocated(cpcp[2]),"3rd point of copy and source are not collocated.") 
790 


self.failUnless(p3.isColocated(cpcp[3]),"4th point of copy and source are not collocated.") 
791 


self.failUnless(c.isColocated(cp),"spline curve is not collocated with its copy.") 
792 


self.failUnless(not c.isColocated(p0),"spline curve is collocated with point.") 
793 


self.failUnless(not c.isColocated(Spline(p0,p1)),"spline curve is collocated with shorter spline curve.") 
794 


self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") 
795 


self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"spline curve is collocated with defomed spline curve.") 
796 



797 


c.modifyBy(Dilation(1.)) 
798 


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.") 
799 


self.failUnless(p0.isColocated(Point(0,0,0)),"1st point has not been modified through Dilation.") 
800 


self.failUnless(p1.isColocated(Point(1,1,1)),"2nd point has not been modified through Dilation.") 
801 


self.failUnless(p2.isColocated(Point(2,2,2)),"3rd point has not been modified through Dilation.") 
802 


self.failUnless(p3.isColocated(Point(3,3,3)),"4th point has not been modified through Dilation.") 
803 


cp=c.getControlPoints() 
804 


self.failUnless(p0 == cp[0],"1st new point after Dilation.") 
805 


self.failUnless(p1 == cp[1],"2nd new point after Dilation.") 
806 


self.failUnless(p2 == cp[2],"3rd new point after Dilation.") 
807 


self.failUnless(p3 == cp[3],"4th new point after Dilation.") 
808 



809 


dc=c.apply(Dilation(1.)) 
810 


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 


dccp=dc.getControlPoints() 
812 


self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") 
813 


self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") 
814 


self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.") 
815 


self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.") 
816 



817 



818 


def test_BezierCurve(self): 
819 


p0=Point(0,0,0,0.1) 
820 


p1=Point(1,1,1,0.2) 
821 


p2=Point(2,2,2,0.3) 
822 


p3=Point(3,3,3,0.4) 
823 


p4=Point(1,2,3) 
824 



825 


self.failUnlessRaises(TypeError,BezierCurve,p0) 
826 


c=BezierCurve(p0,p1,p2,p3) 
827 



828 


self.failUnless(len(c) == 4, "wrong spline curve length") 
829 


self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") 
830 


self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve") 
831 



832 


co=c.getControlPoints() 
833 


self.failUnless(co[0]==p0, "1st control point is wrong.") 
834 


self.failUnless(co[1]==p1, "2nd control point is wrong.") 
835 


self.failUnless(co[2]==p2, "3rd control point is wrong.") 
836 


self.failUnless(co[3]==p3, "4th control point is wrong.") 
837 



838 


c.setLocalScale(3.) 
839 


co=c.getControlPoints() 
840 


self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") 
841 


self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") 
842 


self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") 
843 


self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") 
844 



845 


code=c.getGmshCommand() 
846 


self.failUnless(code == "Bezier(6) = {1, 2, 3, 4};", "gmsh command wrong.") 
847 



848 


h=c.getPrimitives() 
849 


self.failUnless(len(h) == 5, "number of primitives in history is wrong.") 
850 


self.failUnless(p0 in h, "missing p0 in history.") 
851 


self.failUnless(p1 in h, "missing p1 in history.") 
852 


self.failUnless(p2 in h, "missing p2 in history.") 
853 


self.failUnless(p3 in h, "missing p3 in history.") 
854 


self.failUnless(c in h, "missing spline curve in history.") 
855 



856 


cp=c.copy() 
857 


self.failUnless(not cp == c, "copy returns same spline curve.") 
858 


cpcp=cp.getControlPoints() 
859 


self.failUnless(p0.isColocated(cpcp[0]),"1st point of copy and source are not collocated.") 
860 


self.failUnless(p1.isColocated(cpcp[1]),"2nd point of copy and source are not collocated.") 
861 


self.failUnless(p2.isColocated(cpcp[2]),"3rd point of copy and source are not collocated.") 
862 


self.failUnless(p3.isColocated(cpcp[3]),"4th point of copy and source are not collocated.") 
863 


self.failUnless(c.isColocated(cp),"spline curve is not collocated with its copy.") 
864 


self.failUnless(not c.isColocated(p0),"spline curve is collocated with point.") 
865 


self.failUnless(not c.isColocated(BezierCurve(p0,p1)),"spline curve is collocated with shorter spline curve.") 
866 


self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") 
867 


self.failUnless(not c.isColocated(BezierCurve(p0,p1,p4,p3)),"spline curve is collocated with defomed spline curve.") 
868 



869 


c.modifyBy(Dilation(1.)) 
870 


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.") 
871 


self.failUnless(p0.isColocated(Point(0,0,0)),"1st point has not been modified through Dilation.") 
872 


self.failUnless(p1.isColocated(Point(1,1,1)),"2nd point has not been modified through Dilation.") 
873 


self.failUnless(p2.isColocated(Point(2,2,2)),"3rd point has not been modified through Dilation.") 
874 


self.failUnless(p3.isColocated(Point(3,3,3)),"4th point has not been modified through Dilation.") 
875 


cp=c.getControlPoints() 
876 


self.failUnless(p0 == cp[0],"1st new point after Dilation.") 
877 


self.failUnless(p1 == cp[1],"2nd new point after Dilation.") 
878 


self.failUnless(p2 == cp[2],"3rd new point after Dilation.") 
879 


self.failUnless(p3 == cp[3],"4th new point after Dilation.") 
880 



881 


dc=c.apply(Dilation(1.)) 
882 


self.failUnless(dc.isColocated(BezierCurve(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") 
883 


dccp=dc.getControlPoints() 
884 


self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") 
885 


self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") 
886 


self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.") 
887 


self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.") 
888 



889 


def test_BSpline(self): 
890 


p0=Point(0,0,0,0.1) 
891 


p1=Point(1,1,1,0.2) 
892 


p2=Point(2,2,2,0.3) 
893 


p3=Point(3,3,3,0.4) 
894 


p4=Point(1,2,3) 
895 



896 


self.failUnlessRaises(TypeError,BSpline,p0) 
897 


c=BSpline(p0,p1,p2,p3) 
898 



899 


self.failUnless(len(c) == 4, "wrong spline curve length") 
900 


self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") 
901 


self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve") 
902 



903 


co=c.getControlPoints() 
904 


self.failUnless(co[0]==p0, "1st control point is wrong.") 
905 


self.failUnless(co[1]==p1, "2nd control point is wrong.") 
906 


self.failUnless(co[2]==p2, "3rd control point is wrong.") 
907 


self.failUnless(co[3]==p3, "4th control point is wrong.") 
908 



909 


c.setLocalScale(3.) 
910 


co=c.getControlPoints() 
911 


self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") 
912 


self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") 
913 


self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") 
914 


self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") 
915 



916 


code=c.getGmshCommand() 
917 


self.failUnless(code == "BSpline(6) = {1, 2, 3, 4};", "gmsh command wrong.") 
918 



919 


h=c.getPrimitives() 
920 


self.failUnless(len(h) == 5, "number of primitives in history is wrong.") 
921 


self.failUnless(p0 in h, "missing p0 in history.") 
922 


self.failUnless(p1 in h, "missing p1 in history.") 
923 


self.failUnless(p2 in h, "missing p2 in history.") 
924 


self.failUnless(p3 in h, "missing p3 in history.") 
925 


self.failUnless(c in h, "missing spline curve in history.") 
926 



927 


cp=c.copy() 
928 


self.failUnless(not cp == c, "copy returns same spline curve.") 
929 


cpcp=cp.getControlPoints() 
930 


self.failUnless(p0.isColocated(cpcp[0]),"1st point of copy and source are not collocated.") 
931 


self.failUnless(p1.isColocated(cpcp[1]),"2nd point of copy and source are not collocated.") 
932 


self.failUnless(p2.isColocated(cpcp[2]),"3rd point of copy and source are not collocated.") 
933 


self.failUnless(p3.isColocated(cpcp[3]),"4th point of copy and source are not collocated.") 
934 


self.failUnless(c.isColocated(cp),"spline curve is not collocated with its copy.") 
935 


self.failUnless(not c.isColocated(p0),"spline curve is collocated with point.") 
936 


self.failUnless(not c.isColocated(BSpline(p0,p1)),"spline curve is collocated with shorter spline curve.") 
937 


self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") 
938 


self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline curve is collocated with defomed spline curve.") 
939 



940 


c.modifyBy(Dilation(1.)) 
941 


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.") 
942 


self.failUnless(p0.isColocated(Point(0,0,0)),"1st point has not been modified through Dilation.") 
943 


self.failUnless(p1.isColocated(Point(1,1,1)),"2nd point has not been modified through Dilation.") 
944 


self.failUnless(p2.isColocated(Point(2,2,2)),"3rd point has not been modified through Dilation.") 
945 


self.failUnless(p3.isColocated(Point(3,3,3)),"4th point has not been modified through Dilation.") 
946 


cp=c.getControlPoints() 
947 


self.failUnless(p0 == cp[0],"1st new point after Dilation.") 
948 


self.failUnless(p1 == cp[1],"2nd new point after Dilation.") 
949 


self.failUnless(p2 == cp[2],"3rd new point after Dilation.") 
950 


self.failUnless(p3 == cp[3],"4th new point after Dilation.") 
951 



952 


dc=c.apply(Dilation(1.)) 
953 


self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") 
954 


dccp=dc.getControlPoints() 
955 


self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") 
956 


self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") 
957 


self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.") 
958 


self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.") 
959 



960 


def test_LineSegment(self): 
961 


p0=Point(0,0,0,0.1) 
962 


p1=Point(1,1,1,0.2) 
963 


p4=Point(1,2,3) 
964 



965 


self.failUnlessRaises(TypeError,Line,p0) 
966 


self.failUnlessRaises(TypeError,Line,p0,p1,p4) 
967 



968 


c=Line(p0,p1) 
969 



970 


self.failUnless(len(c) == 2, "wrong spline curve length") 
971 


self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") 
972 


self.failUnless(c.getEndPoint()==p1, "wrong end point of spline curve") 
973 



974 


co=c.getControlPoints() 
975 


self.failUnless(co[0]==p0, "1st control point is wrong.") 
976 


self.failUnless(co[1]==p1, "2nd control point is wrong.") 
977 



978 


c.setLocalScale(3.) 
979 


co=c.getControlPoints() 
980 


self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") 
981 


self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") 
982 



983 


code=c.getGmshCommand() 
984 


self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.") 
985 



986 


h=c.getPrimitives() 
987 


self.failUnless(len(h) == 3, "number of primitives in history is wrong.") 
988 


self.failUnless(p0 in h, "missing p0 in history.") 
989 


self.failUnless(p1 in h, "missing p1 in history.") 
990 


self.failUnless(c in h, "missing spline curve in history.") 
991 



992 


cp=c.copy() 
993 


self.failUnless(not cp == c, "copy returns same spline curve.") 
994 


cpcp=cp.getControlPoints() 
995 


self.failUnless(p0.isColocated(cpcp[0]),"1st point of copy and source are not collocated.") 
996 


self.failUnless(p1.isColocated(cpcp[1]),"2nd point of copy and source are not collocated.") 
997 


self.failUnless(c.isColocated(cp),"spline curve is not collocated with its copy.") 
998 


self.failUnless(not c.isColocated(p0),"spline curve is collocated with point.") 
999 


self.failUnless(not c.isColocated(Curve(p0,p1)),"spline curve is identified with curve.") 
1000 


self.failUnless(not c.isColocated(Line(p0,p4)),"spline curve is collocated with defomed spline curve.") 
1001 



1002 


c.modifyBy(Dilation(1.)) 
1003 


self.failUnless(c.isColocated(Line(Point(0,0,0),Point(1,1,1))),"inplace dilation is wrong.") 
1004 


self.failUnless(p0.isColocated(Point(0,0,0)),"1st point has not been modified through Dilation.") 
1005 


self.failUnless(p1.isColocated(Point(1,1,1)),"2nd point has not been modified through Dilation.") 
1006 


cp=c.getControlPoints() 
1007 


self.failUnless(p0 == cp[0],"1st new point after Dilation.") 
1008 


self.failUnless(p1 == cp[1],"2nd new point after Dilation.") 
1009 



1010 


dc=c.apply(Dilation(1.)) 
1011 


self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.") 
1012 


dccp=dc.getControlPoints() 
1013 


self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") 
1014 


self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") 
1015 



1016 
gross 
917 
def test_arc(self): 
1017 


center=Point(0,0,0,0.1) 
1018 


p_start=Point(1,1,1,0.2) 
1019 


p_end=Point(1,2,3) 
1020 



1021 


self.failUnlessRaises(TypeError,Arc,Primitive()) 
1022 
gross 
916 

1023 
gross 
917 
c=Arc(center,p_start,p_end) 
1024 



1025 


self.failUnless(c.getCenterPoint()==center, "wrong center point") 
1026 


self.failUnless(c.getStartPoint()==p_start, "wrong start point") 
1027 


self.failUnless(c.getEndPoint()==p_end, "wrong end point") 
1028 



1029 


code=c.getGmshCommand() 
1030 


self.failUnless(code == "Circle(5) = {2, 1, 3};", "gmsh command wrong.") 
1031 



1032 


h=c.getPrimitives() 
1033 


self.failUnless(len(h) == 4, "number of primitives in history is wrong.") 
1034 


self.failUnless(center in h, "missing center in history.") 
1035 


self.failUnless(p_start in h, "missing p_start in history.") 
1036 


self.failUnless(p_end in h, "missing p_end in history.") 
1037 


self.failUnless(c in h, "missing spline curve in history.") 
1038 



1039 



1040 


c.setLocalScale(3.) 
1041 


self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.") 
1042 


self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.") 
1043 


self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.") 
1044 



1045 


cp=c.copy() 
1046 


self.failUnless(isinstance(cp,Arc), "copy returns is not an arc.") 
1047 


self.failUnless(not cp == c, "copy returns same arc.") 
1048 



1049 


cpcp=cp.getControlPoints() 
1050 


self.failUnless(center.isColocated(cpcp[0]),"1st point of copy and source are not collocated.") 
1051 


self.failUnless(p_start.isColocated(cpcp[1]),"2nd point of copy and source are not collocated.") 
1052 


self.failUnless(c.isColocated(cp),"spline curve is not collocated with its copy.") 
1053 


self.failUnless(not c.isColocated(center),"spline curve is collocated with point.") 
1054 


self.failUnless(not c.isColocated(Curve(center,p_start)),"spline curve is identified with curve.") 
1055 


self.failUnless(not c.isColocated(Line(center,p4)),"spline curve is collocated with defomed spline curve.") 
1056 



1057 


c.modifyBy(Dilation(1.)) 
1058 


self.failUnless(c.isColocated(Line(Point(0,0,0),Point(1,1,1))),"inplace dilation is wrong.") 
1059 


self.failUnless(center.isColocated(Point(0,0,0)),"1st point has not been modified through Dilation.") 
1060 


self.failUnless(p_start.isColocated(Point(1,1,1)),"2nd point has not been modified through Dilation.") 
1061 


cp=c.getControlPoints() 
1062 


self.failUnless(center == cp[0],"1st new point after Dilation.") 
1063 


self.failUnless(p_start == cp[1],"2nd new point after Dilation.") 
1064 



1065 


dc=c.apply(Dilation(1.)) 
1066 


self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.") 
1067 


dccp=dc.getControlPoints() 
1068 


self.failUnless(not center == dccp[0],"1st point of Dilation is identical to source.") 
1069 


self.failUnless(not p_start == dccp[1],"2nd point of Dilation is identical to source.") 
1070 



1071 



1072 
gross 
905 
if __name__ == '__main__': 
1073 


suite = unittest.TestSuite() 
1074 
gross 
912 
suite.addTest(unittest.makeSuite(Test_PyCAD_Transformations)) 
1075 


suite.addTest(unittest.makeSuite(Test_PyCAD_Primitives)) 
1076 
gross 
905 
s=unittest.TextTestRunner(verbosity=2).run(suite) 
1077 


if s.wasSuccessful(): 
1078 


sys.exit(0) 
1079 


else: 
1080 


sys.exit(1) 