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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2419 - (hide annotations)
Thu May 14 01:56:18 2009 UTC (13 years, 3 months ago) by jfenwick
File MIME type: text/x-python
File size: 229213 byte(s)
Use os.path.join instead of os.sep in tests
If you can read this message it means svn commit mails are working again.
... Or you are looking at the logs
1 ksteube 1809
2     ########################################################
3 ksteube 1312 #
4 ksteube 1809 # Copyright (c) 2003-2008 by University of Queensland
5     # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7 ksteube 1312 #
8 ksteube 1809 # Primary Business: Queensland, Australia
9     # Licensed under the Open Software License version 3.0
10     # http://www.opensource.org/licenses/osl-3.0.php
11 ksteube 1312 #
12 ksteube 1809 ########################################################
13 gross 905
14 ksteube 1809 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15     Earth Systems Science Computational Center (ESSCC)
16     http://www.uq.edu.au/esscc
17     Primary Business: Queensland, Australia"""
18 gross 905 __license__="""Licensed under the Open Software License version 3.0
19 ksteube 1809 http://www.opensource.org/licenses/osl-3.0.php"""
20 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
21 gross 932
22     import os
23 gross 905 import sys
24     import unittest
25 gross 907 import math
26 gross 905 import numarray
27     from esys.pycad import *
28 gross 933 from esys.pycad.design import Design as Design0
29     from esys.pycad.gmsh import Design as GMSHDesign
30 ksteube 1312 # from esys.pycad.Triangle import Design as TriangleDesign
31 gross 905
32     try:
33     PYCAD_TEST_DATA=os.environ['PYCAD_TEST_DATA']
34     except KeyError:
35     PYCAD_TEST_DATA='.'
36    
37     try:
38     PYCAD_WORKDIR=os.environ['PYCAD_WORKDIR']
39     except KeyError:
40     PYCAD_WORKDIR='.'
41    
42 jfenwick 2419 #PYCAD_TEST_MESH_PATH=PYCAD_TEST_DATA+os.sep+"data_meshes"+os.sep
43     #PYCAD_WORKDIR_PATH=PYCAD_WORKDIR+os.sep
44 gross 905
45 jfenwick 2419
46    
47 gross 907 def _cross(x, y):
48     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]])
49    
50    
51 gross 912 class Test_PyCAD_Transformations(unittest.TestCase):
52 gross 905 ABS_TOL=1.e-8
53     def __distance(self,x,y):
54     return math.sqrt(numarray.dot(x-y,x-y))
55     def test_Translation_x(self):
56     t=Translation([1,0,0])
57     s0=t([1,0,0])
58     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
59     self.failUnless(self.__distance(s0,numarray.array([2,0,0]))<self.ABS_TOL,"s0 is wrong.")
60     s1=t([0,1,0])
61     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
62     self.failUnless(self.__distance(s1,numarray.array([1,1,0]))<self.ABS_TOL,"s1 is wrong.")
63     s2=t([0,0,1])
64     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
65     self.failUnless(self.__distance(s2,numarray.array([1,0,1]))<self.ABS_TOL,"s2 is wrong.")
66     def test_Translation_y(self):
67     t=Translation([0,1,0])
68     s0=t([1,0,0])
69     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
70     self.failUnless(self.__distance(s0,numarray.array([1,1,0]))<self.ABS_TOL,"s0 is wrong.")
71     s1=t([0,1,0])
72     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
73     self.failUnless(self.__distance(s1,numarray.array([0,2,0]))<self.ABS_TOL,"s1 is wrong.")
74     s2=t([0,0,1])
75     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
76     self.failUnless(self.__distance(s2,numarray.array([0,1,1]))<self.ABS_TOL,"s2 is wrong.")
77     def test_Translation_z(self):
78     t=Translation([0,0,1])
79     s0=t([1,0,0])
80     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
81     self.failUnless(self.__distance(s0,numarray.array([1,0,1]))<self.ABS_TOL,"s0 is wrong.")
82     s1=t([0,1,0])
83     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
84     self.failUnless(self.__distance(s1,numarray.array([0,1,1]))<self.ABS_TOL,"s1 is wrong.")
85     s2=t([0,0,1])
86     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
87     self.failUnless(self.__distance(s2,numarray.array([0,0,2]))<self.ABS_TOL,"s2 is wrong.")
88     def test_Dilation_0_two(self):
89     t=Dilation(2.)
90     s0=t([1,0,0])
91     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
92     self.failUnless(self.__distance(s0,numarray.array([2,0,0]))<self.ABS_TOL,"s0 is wrong.")
93     s1=t([0,1,0])
94     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
95     self.failUnless(self.__distance(s1,numarray.array([0,2,0]))<self.ABS_TOL,"s1 is wrong.")
96     s2=t([0,0,1])
97     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
98     self.failUnless(self.__distance(s2,numarray.array([0,0,2]))<self.ABS_TOL,"s2 is wrong.")
99     def test_Dilation_0_half(self):
100     t=Dilation(0.5)
101     s0=t([1,0,0])
102     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
103     self.failUnless(self.__distance(s0,numarray.array([0.5,0,0]))<self.ABS_TOL,"s0 is wrong.")
104     s1=t([0,1,0])
105     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
106     self.failUnless(self.__distance(s1,numarray.array([0,0.5,0]))<self.ABS_TOL,"s1 is wrong.")
107     s2=t([0,0,1])
108     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
109     self.failUnless(self.__distance(s2,numarray.array([0,0,0.5]))<self.ABS_TOL,"s2 is wrong.")
110     def test_Dilation_x_two(self):
111     t=Dilation(2.,[1.,0.,0.])
112     s0=t([1,0,0])
113     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
114     self.failUnless(self.__distance(s0,numarray.array([1,0,0]))<self.ABS_TOL,"s0 is wrong.")
115     s0_1=t([0,0,0])
116     self.failUnless(isinstance(s0_1,numarray.NumArray),"s0_1 is not a numarray object.")
117     self.failUnless(self.__distance(s0_1,numarray.array([-1.,0,0]))<self.ABS_TOL,"s0_1 is wrong.")
118     s1=t([0,1,0])
119     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
120     self.failUnless(self.__distance(s1,numarray.array([-1,2,0]))<self.ABS_TOL,"s1 is wrong.")
121     s2=t([0,0,1])
122     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
123     self.failUnless(self.__distance(s2,numarray.array([-1.,0,2]))<self.ABS_TOL,"s2 is wrong.")
124     def test_Dilation_x_half(self):
125     t=Dilation(0.5,[1.,0.,0.])
126     s0=t([1,0,0])
127     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
128     self.failUnless(self.__distance(s0,numarray.array([1.,0,0]))<self.ABS_TOL,"s0 is wrong.")
129     s0_1=t([0,0,0])
130     self.failUnless(isinstance(s0_1,numarray.NumArray),"s0_1 is not a numarray object.")
131     self.failUnless(self.__distance(s0_1,numarray.array([.5,0,0]))<self.ABS_TOL,"s0_1 is wrong.")
132     s1=t([0,1,0])
133     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
134     self.failUnless(self.__distance(s1,numarray.array([0.5,0.5,0]))<self.ABS_TOL,"s1 is wrong.")
135     s2=t([0,0,1])
136     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
137     self.failUnless(self.__distance(s2,numarray.array([0.5,0,0.5]))<self.ABS_TOL,"s2 is wrong.")
138     def test_Dilation_y_two(self):
139     t=Dilation(2.,[0.,1.,0.])
140     s0=t([1,0,0])
141     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
142     self.failUnless(self.__distance(s0,numarray.array([2.,-1.,0]))<self.ABS_TOL,"s0 is wrong.")
143     s1_1=t([0,0,0])
144     self.failUnless(isinstance(s1_1,numarray.NumArray),"s1_1 is not a numarray object.")
145     self.failUnless(self.__distance(s1_1,numarray.array([0.,-1.,0]))<self.ABS_TOL,"s1_1 is wrong.")
146     s1=t([0,1,0])
147     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
148     self.failUnless(self.__distance(s1,numarray.array([0.,1.,0]))<self.ABS_TOL,"s1 is wrong.")
149     s2=t([0,0,1])
150     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
151     self.failUnless(self.__distance(s2,numarray.array([0.,-1.,2]))<self.ABS_TOL,"s2 is wrong.")
152     def test_Dilation_y_half(self):
153     t=Dilation(0.5,[0.,1.,0.])
154     s0=t([1,0,0])
155     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
156     self.failUnless(self.__distance(s0,numarray.array([0.5,0.5,0]))<self.ABS_TOL,"s0 is wrong.")
157     s1_1=t([0,0,0])
158     self.failUnless(isinstance(s1_1,numarray.NumArray),"s1_1 is not a numarray object.")
159     self.failUnless(self.__distance(s1_1,numarray.array([0,0.5,0]))<self.ABS_TOL,"s1_1 is wrong.")
160     s1=t([0,1,0])
161     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
162     self.failUnless(self.__distance(s1,numarray.array([0.,1.,0]))<self.ABS_TOL,"s1 is wrong.")
163     s2=t([0,0,1])
164     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
165     self.failUnless(self.__distance(s2,numarray.array([0.,0.5,0.5]))<self.ABS_TOL,"s2 is wrong.")
166     def test_Dilation_z_two(self):
167     t=Dilation(2.,[0.,0.,1.])
168     s0=t([1,0,0])
169     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
170     self.failUnless(self.__distance(s0,numarray.array([2.,0.,-1.]))<self.ABS_TOL,"s0 is wrong.")
171     s2_1=t([0,0,0])
172     self.failUnless(isinstance(s2_1,numarray.NumArray),"s2_1 is not a numarray object.")
173     self.failUnless(self.__distance(s2_1,numarray.array([0.,0.,-1.]))<self.ABS_TOL,"s2_1 is wrong.")
174     s1=t([0,1,0])
175     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
176     self.failUnless(self.__distance(s1,numarray.array([0.,2.,-1.]))<self.ABS_TOL,"s1 is wrong.")
177     s2=t([0,0,1])
178     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
179     self.failUnless(self.__distance(s2,numarray.array([0.,0.,1.]))<self.ABS_TOL,"s2 is wrong.")
180     def test_Dilation_z_half(self):
181     t=Dilation(0.5,[0.,0.,1.])
182     s0=t([1,0,0])
183     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
184     self.failUnless(self.__distance(s0,numarray.array([0.5,0.,0.5]))<self.ABS_TOL,"s0 is wrong.")
185     s2_1=t([0,0,0])
186     self.failUnless(isinstance(s2_1,numarray.NumArray),"s2_1 is not a numarray object.")
187     self.failUnless(self.__distance(s2_1,numarray.array([0,0,0.5]))<self.ABS_TOL,"s2_1 is wrong.")
188     s1=t([0,1,0])
189     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
190     self.failUnless(self.__distance(s1,numarray.array([0.,0.5,0.5]))<self.ABS_TOL,"s1 is wrong.")
191     s2=t([0,0,1])
192     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
193     self.failUnless(self.__distance(s2,numarray.array([0.,0.,1.]))<self.ABS_TOL,"s2 is wrong.")
194     def test_Reflection_x_offset0(self):
195     t=Reflection([1.,0.,0.])
196     s0=t([1,0,0])
197     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
198     self.failUnless(self.__distance(s0,numarray.array([-1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
199     s1=t([0,1,0])
200     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
201     self.failUnless(self.__distance(s1,numarray.array([0,1,0]))<self.ABS_TOL,"s1 is wrong.")
202     s2=t([0,0,1])
203     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
204     self.failUnless(self.__distance(s2,numarray.array([0,0,1]))<self.ABS_TOL,"s2 is wrong.")
205     s=t([1,2,3])
206     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
207     self.failUnless(self.__distance(s,numarray.array([-1.,2,3]))<self.ABS_TOL,"s is wrong.")
208     def test_Reflection_x_offset2(self):
209     t=Reflection([-2.,0.,0.],offset=-4)
210     s0=t([1,0,0])
211     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
212     self.failUnless(self.__distance(s0,numarray.array([3.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
213     s1=t([0,1,0])
214     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
215     self.failUnless(self.__distance(s1,numarray.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.")
216     s2=t([0,0,1])
217     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
218     self.failUnless(self.__distance(s2,numarray.array([4,0,1]))<self.ABS_TOL,"s2 is wrong.")
219     s=t([1,2,3])
220     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
221     self.failUnless(self.__distance(s,numarray.array([3.,2,3]))<self.ABS_TOL,"s is wrong.")
222     def test_Reflection_x_offset2_vector(self):
223     t=Reflection([1.,0.,0.],offset=[2,0,0])
224     s0=t([1,0,0])
225     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
226     self.failUnless(self.__distance(s0,numarray.array([3.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
227     s1=t([0,1,0])
228     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
229     self.failUnless(self.__distance(s1,numarray.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.")
230     s2=t([0,0,1])
231     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
232     self.failUnless(self.__distance(s2,numarray.array([4,0,1]))<self.ABS_TOL,"s2 is wrong.")
233     s=t([1,2,3])
234     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
235     self.failUnless(self.__distance(s,numarray.array([3.,2,3]))<self.ABS_TOL,"s is wrong.")
236 gross 907 def test_Reflection_y_offset0(self):
237     t=Reflection([0.,1.,0.])
238     s0=t([1,0,0])
239     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
240     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
241     s1=t([0,1,0])
242     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
243     self.failUnless(self.__distance(s1,numarray.array([0,-1,0]))<self.ABS_TOL,"s1 is wrong.")
244     s2=t([0,0,1])
245     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
246     self.failUnless(self.__distance(s2,numarray.array([0,0,1]))<self.ABS_TOL,"s2 is wrong.")
247     s=t([1,2,3])
248     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
249     self.failUnless(self.__distance(s,numarray.array([1.,-2,3]))<self.ABS_TOL,"s is wrong.")
250     def test_Reflection_y_offset2(self):
251     t=Reflection([0.,-2.,0.],offset=-4)
252     s0=t([1,0,0])
253     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
254     self.failUnless(self.__distance(s0,numarray.array([1.,4,0.]))<self.ABS_TOL,"s0 is wrong.")
255     s1=t([0,1,0])
256     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
257     self.failUnless(self.__distance(s1,numarray.array([0,3,0]))<self.ABS_TOL,"s1 is wrong.")
258     s2=t([0,0,1])
259     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
260     self.failUnless(self.__distance(s2,numarray.array([0,4,1]))<self.ABS_TOL,"s2 is wrong.")
261     s=t([1,2,3])
262     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
263     self.failUnless(self.__distance(s,numarray.array([1.,2,3]))<self.ABS_TOL,"s is wrong.")
264     def test_Reflection_y_offset2_vector(self):
265     t=Reflection([0.,1.,0.],offset=[0,2,0])
266     s0=t([1,0,0])
267     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
268     self.failUnless(self.__distance(s0,numarray.array([1.,4,0.]))<self.ABS_TOL,"s0 is wrong.")
269     s1=t([0,1,0])
270     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
271     self.failUnless(self.__distance(s1,numarray.array([0,3,0]))<self.ABS_TOL,"s1 is wrong.")
272     s2=t([0,0,1])
273     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
274     self.failUnless(self.__distance(s2,numarray.array([0,4,1]))<self.ABS_TOL,"s2 is wrong.")
275     s=t([1,2,3])
276     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
277     self.failUnless(self.__distance(s,numarray.array([1.,2,3]))<self.ABS_TOL,"s is wrong.")
278     def test_Reflection_z_offset0(self):
279     t=Reflection([0.,0.,1.])
280     s0=t([1,0,0])
281     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
282     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
283     s1=t([0,1,0])
284     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
285     self.failUnless(self.__distance(s1,numarray.array([0,1,0]))<self.ABS_TOL,"s1 is wrong.")
286     s2=t([0,0,1])
287     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
288     self.failUnless(self.__distance(s2,numarray.array([0,0,-1]))<self.ABS_TOL,"s2 is wrong.")
289     s=t([1,2,3])
290     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
291     self.failUnless(self.__distance(s,numarray.array([1.,2,-3]))<self.ABS_TOL,"s is wrong.")
292     def test_Reflection_z_offset2(self):
293     t=Reflection([0.,0.,-2.],offset=-4)
294     s0=t([1,0,0])
295     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
296     self.failUnless(self.__distance(s0,numarray.array([1.,0,4.]))<self.ABS_TOL,"s0 is wrong.")
297     s1=t([0,1,0])
298     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
299     self.failUnless(self.__distance(s1,numarray.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.")
300     s2=t([0,0,1])
301     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
302     self.failUnless(self.__distance(s2,numarray.array([0,0,3]))<self.ABS_TOL,"s2 is wrong.")
303     s=t([1,2,3])
304     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
305     self.failUnless(self.__distance(s,numarray.array([1.,2,1]))<self.ABS_TOL,"s is wrong.")
306     def test_Reflection_z_offset2_vector(self):
307     t=Reflection([0.,0.,1.],offset=[0,0,2])
308     s0=t([1,0,0])
309     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
310     self.failUnless(self.__distance(s0,numarray.array([1.,0,4.]))<self.ABS_TOL,"s0 is wrong.")
311     s1=t([0,1,0])
312     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
313     self.failUnless(self.__distance(s1,numarray.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.")
314     s2=t([0,0,1])
315     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
316     self.failUnless(self.__distance(s2,numarray.array([0,0,3]))<self.ABS_TOL,"s2 is wrong.")
317     s=t([1,2,3])
318     self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.")
319     self.failUnless(self.__distance(s,numarray.array([1.,2,1]))<self.ABS_TOL,"s is wrong.")
320     def test_Rotatation_x_90_0(self):
321 gross 916 t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=90*DEG)
322 gross 907 s0=t([1,0,0])
323     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
324     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
325     s1=t([0,1,0])
326     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
327 gross 910 self.failUnless(self.__distance(s1,numarray.array([0.,0,1.]))<self.ABS_TOL,"s1 is wrong.")
328 gross 907 s2=t([0,0,1])
329     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
330 gross 910 self.failUnless(self.__distance(s2,numarray.array([0.,-1.,0.]))<self.ABS_TOL,"s2 is wrong.")
331 gross 907 def test_Rotatation_x_30_0(self):
332 gross 916 t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=30*DEG)
333 gross 907 s0=t([1,0,0])
334     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
335     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
336     s1=t([0,1,0])
337     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
338     self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
339     self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
340 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))<0.,"s1 has wrong orientation.")
341 gross 907 s2=t([0,0,1])
342     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
343     self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
344     self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
345 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))<0.,"s2 has wrong orientation.")
346 gross 907 def test_Rotatation_x_330_0(self):
347 gross 916 t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=330*DEG)
348 gross 907 s0=t([1,0,0])
349     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
350     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
351     s1=t([0,1,0])
352     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
353     self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
354     self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
355 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))>0.,"s1 has wrong orientation.")
356 gross 907 s2=t([0,0,1])
357     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
358     self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
359     self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
360 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.")
361 gross 907 def test_Rotatation_x_90(self):
362 gross 916 t=Rotatation(axis=[-1.,0.,0.],point=[2.,0.,0.],angle=90*DEG)
363 gross 907 s0=t([1,0,0])
364     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
365     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
366     s1=t([0,1,0])
367     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
368 gross 910 self.failUnless(self.__distance(s1,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s1 is wrong.")
369 gross 907 s2=t([0,0,1])
370     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
371 gross 910 self.failUnless(self.__distance(s2,numarray.array([0.,1.,0.]))<self.ABS_TOL,"s2 is wrong.")
372 gross 907 def test_Rotatation_x_30(self):
373 gross 916 t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=30*DEG)
374 gross 907 s0=t([1,0,0])
375     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
376     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
377     s1=t([0,1,0])
378     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
379     self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
380     self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
381 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.")
382 gross 907 s2=t([0,0,1])
383     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
384     self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
385     self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
386 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.")
387 gross 907 def test_Rotatation_x_330(self):
388 gross 916 t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=330*DEG)
389 gross 907 s0=t([1,0,0])
390     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
391     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
392     s1=t([0,1,0])
393     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
394     self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
395     self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
396 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.")
397 gross 907 s2=t([0,0,1])
398     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
399     self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
400     self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
401 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.")
402 gross 907 def test_Rotatation_y_90_0(self):
403 gross 916 t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=90*DEG)
404 gross 907 s0=t([1,0,0])
405     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
406 gross 910 self.failUnless(self.__distance(s0,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s0 is wrong.")
407 gross 907 s1=t([0,5,0])
408     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
409     self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
410     s2=t([0,0,1])
411     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
412 gross 910 self.failUnless(self.__distance(s2,numarray.array([1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
413 gross 907 def test_Rotatation_y_30_0(self):
414 gross 916 t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=30*DEG)
415 gross 907 s0=t([1,0,0])
416     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
417     self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
418     self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
419 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))<0.,"s0 has wrong orientation.")
420 gross 907 s1=t([0,5,0])
421     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
422     self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
423     s2=t([0,0,1])
424     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
425     self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
426     self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
427 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))<0.,"s2 has wrong orientation.")
428 gross 907 def test_Rotatation_y_330_0(self):
429 gross 916 t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=330*DEG)
430 gross 907 s0=t([1,0,0])
431     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
432     self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
433     self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
434 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))>0.,"s0 has wrong orientation.")
435 gross 907 s1=t([0,1,0])
436     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
437     self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
438     s2=t([0,0,1])
439     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
440     self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
441     self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
442 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.")
443 gross 907 def test_Rotatation_y_90(self):
444 gross 916 t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=90*DEG)
445 gross 907 s0=t([1,0,0])
446     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
447 gross 910 self.failUnless(self.__distance(s0,numarray.array([0.,0,1.]))<self.ABS_TOL,"s0 is wrong.")
448     s1=t([0,5,0])
449 gross 907 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
450 gross 910 self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
451 gross 907 s2=t([0,0,1])
452     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
453 gross 910 self.failUnless(self.__distance(s2,numarray.array([-1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
454 gross 907 def test_Rotatation_y_30(self):
455 gross 916 t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=30*DEG)
456 gross 907 s0=t([1,0,0])
457     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
458     self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
459     self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
460 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.")
461 gross 907 s1=t([0,1,0])
462     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
463     self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
464     s2=t([0,0,1])
465     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
466     self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
467     self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
468 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.")
469 gross 907 def test_Rotatation_y_330(self):
470 gross 916 t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=330*DEG)
471 gross 907 s0=t([1,0,0])
472     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
473     self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
474     self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
475 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.")
476 gross 907 s1=t([0,1,0])
477     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
478     self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
479     s2=t([0,0,1])
480     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
481     self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
482     self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
483 gross 910 self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.")
484 gross 907 def test_Rotatation_z_90_0(self):
485 gross 916 t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=90*DEG)
486 gross 907 s0=t([1,0,0])
487     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
488 gross 910 self.failUnless(self.__distance(s0,numarray.array([0.,1,0.]))<self.ABS_TOL,"s0 is wrong.")
489 gross 907 s1=t([0,5,0])
490     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
491 gross 910 self.failUnless(self.__distance(s1,numarray.array([-5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
492 gross 907 s2=t([0,0,1])
493     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
494     self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
495     def test_Rotatation_z_30_0(self):
496 gross 916 t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=30*DEG)
497 gross 907 s0=t([1,0,0])
498     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
499     self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
500     self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
501 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))<0.,"s0 has wrong orientation.")
502 gross 907 s1=t([0,5,0])
503     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
504     self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
505     self.failUnless(abs(s1[1]/5.-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
506 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,5,0]),numarray.array([0.,0.,1.]))<0.,"s1 has wrong orientation.")
507 gross 907 s2=t([0,0,1])
508     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
509     self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
510     def test_Rotatation_z_330_0(self):
511 gross 916 t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=330*DEG)
512 gross 907 s0=t([1,0,0])
513     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
514     self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
515     self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
516 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))>0.,"s0 has wrong orientation.")
517 gross 907 s1=t([0,5,0])
518     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
519     self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
520     self.failUnless(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
521 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.")
522 gross 907 def test_Rotatation_z_90(self):
523 gross 916 t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=90*DEG)
524 gross 907 s0=t([1,0,0])
525     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
526 gross 910 self.failUnless(self.__distance(s0,numarray.array([0.,-1,0.]))<self.ABS_TOL,"s0 is wrong.")
527     s1=t([0,5,0])
528 gross 907 self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
529 gross 910 self.failUnless(self.__distance(s1,numarray.array([5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
530 gross 907 s2=t([0,0,1])
531     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
532     self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
533     def test_Rotatation_z_30(self):
534 gross 916 t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=30*DEG)
535 gross 907 s0=t([1,0,0])
536     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
537     self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
538     self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
539 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.")
540 gross 907 s1=t([0,1,0])
541     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
542     self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
543     self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
544 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.")
545 gross 907 s2=t([0,0,1])
546     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
547     self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
548     def test_Rotatation_z_330(self):
549 gross 916 t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=330*DEG)
550 gross 907 s0=t([1,0,0])
551     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
552     self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
553     self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
554 gross 910 self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.")
555 gross 907 s1=t([0,1,0])
556     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
557     self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
558     self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
559 gross 910 self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.")
560 gross 907 s2=t([0,0,1])
561     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
562     self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
563 gross 910 def test_Rotatation_x_90_1(self):
564 gross 916 t=Rotatation(point=[0.,0.,1.],axis=[1.,0.,0.],angle=90*DEG)
565 gross 910 s0=t([1,0,0])
566     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
567     self.failUnless(self.__distance(s0,numarray.array([1.,1,1.]))<self.ABS_TOL,"s0 is wrong.")
568     s1=t([0,1,0])
569     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
570     self.failUnless(self.__distance(s1,numarray.array([0.,1,2.]))<self.ABS_TOL,"s1 is wrong.")
571     s2=t([0,0,1])
572     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
573     self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
574     def test_Rotatation_y_90_1(self):
575 gross 916 t=Rotatation(point=[1.,0.,0.],axis=[0.,1.,0.],angle=90*DEG)
576 gross 910 s0=t([1,0,0])
577     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
578     self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
579     s1=t([0,1,0])
580     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
581     self.failUnless(self.__distance(s1,numarray.array([1.,1,1.]))<self.ABS_TOL,"s1 is wrong.")
582     s2=t([0,0,1])
583     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
584     self.failUnless(self.__distance(s2,numarray.array([2.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
585     def test_Rotatation_z_90_1(self):
586 gross 916 t=Rotatation(point=[0.,1.,0.],axis=[0.,0.,1.],angle=90*DEG)
587 gross 910 s0=t([1,0,0])
588     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
589     self.failUnless(self.__distance(s0,numarray.array([1.,2,0.]))<self.ABS_TOL,"s0 is wrong.")
590     s1=t([0,1,0])
591     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
592     self.failUnless(self.__distance(s1,numarray.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
593     s2=t([0,0,1])
594     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
595     self.failUnless(self.__distance(s2,numarray.array([1.,1,1.]))<self.ABS_TOL,"s2 is wrong.")
596     def test_Rotatation_diag_90_0(self):
597 gross 916 t=Rotatation(axis=[1.,1.,1.],angle=90*DEG)
598 gross 910 s0=t([1,-1,0])
599     self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.")
600     self.failUnless(abs(numarray.dot(s0,s0)-2.)<self.ABS_TOL,"s0 length is wrong.")
601     self.failUnless(abs(numarray.dot(s0,numarray.array([1,-1,0])))<self.ABS_TOL,"s0 angle is wrong.")
602     self.failUnless(numarray.dot(_cross(s0,[1,-1,0]),numarray.array([1.,1.,1.]))<0.,"s0 has wrong orientation.")
603     s1=t([0,1,-1])
604     self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.")
605     self.failUnless(abs(numarray.dot(s1,s1)-2.)<self.ABS_TOL,"s1 length is wrong.")
606     self.failUnless(abs(numarray.dot(s1,numarray.array([0,1,-1])))<self.ABS_TOL,"s1 angle is wrong.")
607     self.failUnless(numarray.dot(_cross(s1,[0,1,-1]),numarray.array([1.,1.,1.]))<0.,"s1 has wrong orientation.")
608     s2=t([-1,0,1])
609     self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.")
610     self.failUnless(abs(numarray.dot(s2,s2)-2.)<self.ABS_TOL,"s2 length is wrong.")
611     self.failUnless(abs(numarray.dot(s2,numarray.array([-1,0,1])))<self.ABS_TOL,"s2 angle is wrong.")
612     self.failUnless(numarray.dot(_cross(s2,[-1,0,1]),numarray.array([1.,1.,1.]))<0.,"s2 has wrong orientation.")
613     s3=t([1,1,1])
614     self.failUnless(isinstance(s3,numarray.NumArray),"s3 is not a numarray object.")
615     self.failUnless(self.__distance(s3,numarray.array([1.,1,1.]))<self.ABS_TOL,"s3 is wrong.")
616 gross 912
617     class Test_PyCAD_Primitives(unittest.TestCase):
618     def setUp(self):
619 gross 915 resetGlobalPrimitiveIdCounter()
620 gross 912
621 gross 929 def test_Primitive(self):
622 gross 912 p=Primitive()
623    
624     id=p.getID()
625     self.failUnless(isinstance(id,int),"id number is not an integer")
626 gross 915 self.failUnless(not id==Primitive().getID(),"id number is not unique")
627 gross 912
628 gross 929 self.failUnless(p==p.getUnderlyingPrimitive(),"getUnderlyingPrimitive does not return self.")
629 gross 912
630 gross 929 def test_ReversePrimitive(self):
631     p=Primitive()
632    
633     rp=ReversePrimitive(p)
634     self.failUnless(p.getID()==rp.getID(),"reverse primitive does not have same id like source")
635     self.failUnless(p==rp.getUnderlyingPrimitive(),"getUnderlyingPrimitive does return source.")
636     self.failUnless(p == -rp,"reverse or reverse does not return source.")
637    
638     def test_Point(self):
639 gross 912 p=Point(1.,2.,3.,local_scale=9.)
640    
641     id=p.getID()
642     self.failUnless(isinstance(id,int),"id number is not an integer")
643 gross 915 self.failUnless(not id==Primitive().getID(),"id number is not unique")
644 gross 912
645 gross 929 # check reverse point
646     self.failUnless(p == -p,"reverse is not working.")
647    
648 gross 915 # check history:
649 gross 916 hs=p.getPrimitives()
650 gross 912 self.failUnless(len(hs)==1,"history must have length 1.")
651     self.failUnless(p in hs,"history must contain point p")
652    
653 gross 915 # check incolved points:
654 gross 916 ps=p.getConstructionPoints()
655 gross 912 self.failUnless(len(ps)==1,"point set must have length 1.")
656     self.failUnless(p in ps,"point set must contain point p")
657    
658 gross 915 # check coordinates:
659 gross 912 c=p.getCoordinates()
660     self.failUnless(isinstance(c,numarray.NumArray),"coordinates are not a numarray object.")
661     self.failUnless(c[0]==1.,"x coordinate is not 1.")
662     self.failUnless(c[1]==2.,"y coordinate is not 2.")
663     self.failUnless(c[2]==3.,"z coordinate is not 3.")
664    
665 gross 915 # reset coordinates:
666     p.setCoordinates([-1.,-2.,-3.])
667 gross 912 c=p.getCoordinates()
668     self.failUnless(isinstance(c,numarray.NumArray),"new coordinates are not a numarray object.")
669     self.failUnless(c[0]==-1.,"new x coordinate is not -1.")
670     self.failUnless(c[1]==-2.,"new y coordinate is not -2.")
671     self.failUnless(c[2]==-3.,"new z coordinate is not -3.")
672    
673 gross 915 # check for a colocated point:
674 gross 912 self.failUnless(p.isColocated(Point(-1.,-2.,-3.)),"colocation not detected.")
675 gross 916 self.failUnless(not p.isColocated(numarray.array([-1.,-2.,-3.])),"colocation with numarray representation not detected.")
676     self.failUnless(not p.isColocated(Point(1.,-2.,-3.)),"false colocation detected.")
677     self.failUnless(not p.isColocated(Point(0.,0.,0.)),"false colocation with origin detected.")
678 gross 912
679 gross 915 # check for local length scale
680 gross 912 l=p.getLocalScale()
681     self.failUnless(l==9.,"refinement scale is not 9.")
682    
683 gross 915 # check for new local length scale
684 gross 912 p.setLocalScale(3.)
685     l=p.getLocalScale()
686     self.failUnless(l==3.,"new refinement scale is not 3.")
687    
688 gross 915 # negative value shouldn't work.
689     self.failUnlessRaises(ValueError,p.setLocalScale,-3.)
690    
691     # copy:
692     an_other_p=p.copy()
693     self.failUnless(isinstance(an_other_p ,Point),"copy is not a point")
694     self.failUnless(not an_other_p.getID() == p.getID(),"copy has same Id")
695     self.failUnless(p.isColocated(an_other_p),"p is not colocated with its copy.")
696     self.failUnless(an_other_p.isColocated(p),"the copy is not colocated with p.")
697     self.failUnless(an_other_p.getLocalScale()==3.,"copy has wrong local scale.")
698    
699     # modify by Transformation:
700     p.modifyBy(Dilation(-1))
701     self.failUnless(p.isColocated(Point(1.,2.,3.)),"in-place transformation failed")
702    
703     # apply Transformation:
704     dil_p=p.apply(Dilation(4))
705     self.failUnless(dil_p.isColocated(Point(4.,8.,12.)),"applying transformation failed")
706     self.failUnless(not dil_p.getID() == p.getID(),"transformed point has same Id")
707     self.failUnless(dil_p.getLocalScale()==3.,"transformed point has wrong local scale.")
708    
709     # overloaded add:
710     shift_p=p+[1,1,1]
711     self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by list failed")
712     self.failUnless(not shift_p.getID() == p.getID(),"shift by list has same Id")
713     self.failUnless(shift_p.getLocalScale()==3.,"shift by list has wrong local scale.")
714    
715     shift_p=p+numarray.array([1,1,1])
716     self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by numarray failed")
717     self.failUnless(not shift_p.getID() == p.getID(),"shift by numarray has same Id")
718     self.failUnless(shift_p.getLocalScale()==3.,"shift by numarray has wrong local scale.")
719     # overloaded minus
720     shift_p=p-[1,1,1]
721     self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -list failed")
722     self.failUnless(not shift_p.getID() == p.getID(),"shift by -list has same Id")
723     self.failUnless(shift_p.getLocalScale()==3.,"shift by -list has wrong local scale.")
724    
725     shift_p=p-numarray.array([1,1,1])
726     self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -numarray failed")
727     self.failUnless(not shift_p.getID() == p.getID(),"shift by -numarray has same Id")
728     self.failUnless(shift_p.getLocalScale()==3.,"shift by -numarray has wrong local scale.")
729     # overloaded inplace add:
730     p+=[1,1,1]
731     self.failUnless(p.isColocated(Point(2,3.,4)),"modification by list shift failed")
732    
733     p+=numarray.array([1,1,1])
734     self.failUnless(p.isColocated(Point(3,4,5)),"modification by numarray shift failed")
735    
736     # overloaded inplace add:
737     p-=[1,1,1]
738     self.failUnless(p.isColocated(Point(2,3,4)),"modification by -list shift failed")
739    
740     p-=numarray.array([1,1,1])
741     self.failUnless(p.isColocated(Point(1,2.,3)),"modification by -numarray shift failed")
742    
743     #overloaded multiplication:
744     mult_p=2*p
745     self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying int factor failed")
746     self.failUnless(not mult_p.getID() == p.getID(),"shift by int factor has same Id")
747     self.failUnless(mult_p.getLocalScale()==3.,"shift by int factor has wrong local scale.")
748    
749     mult_p=2.*p
750     self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying float factor failed")
751     self.failUnless(not mult_p.getID() == p.getID(),"shift by float factor has same Id")
752     self.failUnless(mult_p.getLocalScale()==3.,"shift by float factor has wrong local scale.")
753    
754     mult_p=Dilation(2)*p
755     self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying Dilation factor failed")
756     self.failUnless(not mult_p.getID() == p.getID(),"shift by Dilation factor has same Id")
757     self.failUnless(mult_p.getLocalScale()==3.,"shift by Dilation factor has wrong local scale.")
758    
759     #overloaded inplace multiplication:
760     p*=2
761     self.failUnless(p.isColocated(Point(2,4,6)),"applying in-place int factor failed")
762    
763     p*=2.
764     self.failUnless(p.isColocated(Point(4,8,12)),"applying in-place float factor failed")
765    
766     p*=Dilation(2)
767     self.failUnless(p.isColocated(Point(8,16,24)),"applying in-place Dilation factor failed")
768    
769 gross 929 def test_Spline(self):
770 gross 916 p0=Point(0,0,0,0.1)
771     p1=Point(1,1,1,0.2)
772     p2=Point(2,2,2,0.3)
773     p3=Point(3,3,3,0.4)
774     p4=Point(1,2,3)
775    
776 gross 931 self.failUnlessRaises(ValueError,Spline,p0)
777 gross 916 c=Spline(p0,p1,p2,p3)
778 gross 915
779 gross 916 self.failUnless(len(c) == 4, "wrong spline curve length")
780     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
781     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
782    
783 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
784     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
785    
786 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
787     self.failUnless(not c.isColocated(Spline(p0,p1,p2)),"spline is colocated with spline of different length.")
788     self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
789     self.failUnless(c.isColocated(Spline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
790     self.failUnless(c.isColocated(Spline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
791     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
792    
793 gross 916 co=c.getControlPoints()
794     self.failUnless(co[0]==p0, "1st control point is wrong.")
795     self.failUnless(co[1]==p1, "2nd control point is wrong.")
796     self.failUnless(co[2]==p2, "3rd control point is wrong.")
797     self.failUnless(co[3]==p3, "4th control point is wrong.")
798    
799     c.setLocalScale(3.)
800     co=c.getControlPoints()
801     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
802     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
803     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
804     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
805    
806     h=c.getPrimitives()
807     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
808     self.failUnless(p0 in h, "missing p0 in history.")
809     self.failUnless(p1 in h, "missing p1 in history.")
810     self.failUnless(p2 in h, "missing p2 in history.")
811     self.failUnless(p3 in h, "missing p3 in history.")
812     self.failUnless(c in h, "missing spline curve in history.")
813    
814     cp=c.copy()
815 gross 919 cpcp=cp.getControlPoints()
816 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
817 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
818     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
819     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
820     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
821     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
822 gross 916
823     c.modifyBy(Dilation(-1.))
824 gross 919 cp=c.getControlPoints()
825 gross 916 self.failUnless(c.isColocated(Spline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
826     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
827     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
828     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
829     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
830    
831     dc=c.apply(Dilation(-1.))
832 gross 919 dccp=dc.getControlPoints()
833 gross 916 self.failUnless(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
834     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
835 gross 929 self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
836 gross 916 self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
837 gross 929 self.failUnless(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
838 gross 916 self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
839 gross 929 self.failUnless(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
840 gross 916 self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
841 gross 929 self.failUnless(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
842 gross 916
843 gross 929 def test_ReverseSpline(self):
844     p0=Point(0,0,0,0.1)
845     p1=Point(1,1,1,0.2)
846     p2=Point(2,2,2,0.3)
847     p3=Point(3,3,3,0.4)
848     p4=Point(1,2,3)
849    
850     CC0=Spline(p0,p1,p2,p3)
851     c=-CC0
852 gross 916
853 gross 929 self.failUnless(len(c) == 4, "wrong reverse spline curve length")
854     self.failUnless(c.getStartPoint()==p3, "wrong start point of reverse spline curve")
855     self.failUnless(c.getEndPoint()==p0, "wrong end point of reverse spline curve")
856    
857 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
858     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
859    
860 gross 929 self.failUnless(not c.isColocated(p1),"reverse spline is colocated with point.")
861     self.failUnless(not c.isColocated(Spline(p0,p1,p2)),"reverse spline is colocated with spline of different length.")
862     self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"reverse spline is colocated with spline with different point.")
863     self.failUnless(c.isColocated(Spline(p0,p1,p2,p3)),"reverse spline is not colocated with spline with same points but opposite direction.")
864     self.failUnless(c.isColocated(Spline(p3,p2,p1,p0)),"reverse spline is not colocated with spline with same points.")
865     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
866    
867     co=c.getControlPoints()
868     self.failUnless(co[0]==p3, "1st control point is wrong.")
869     self.failUnless(co[1]==p2, "2nd control point is wrong.")
870     self.failUnless(co[2]==p1, "3rd control point is wrong.")
871     self.failUnless(co[3]==p0, "4th control point is wrong.")
872    
873     c.setLocalScale(3.)
874     co=c.getControlPoints()
875     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
876     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
877     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
878     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
879    
880     h=c.getPrimitives()
881     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
882     self.failUnless(p0 in h, "missing p0 in history.")
883     self.failUnless(p1 in h, "missing p1 in history.")
884     self.failUnless(p2 in h, "missing p2 in history.")
885     self.failUnless(p3 in h, "missing p3 in history.")
886     self.failUnless(CC0 in h, "missing spline curve in history.")
887    
888     cp=c.copy()
889     cpcp=cp.getControlPoints()
890     self.failUnless(not cp == c, "copy returns same spline curve.")
891     self.failUnless(not cp == CC0, "copy returns same spline curve.")
892     self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
893     self.failUnless(not p3 == cpcp[0],"1st point of deep copy and souce are the same.")
894     self.failUnless(not p2 == cpcp[1],"2st point of deep copy and source are the same.")
895     self.failUnless(not p1 == cpcp[2],"3st point of deep copy and source are the same.")
896     self.failUnless(not p0 == cpcp[3],"4st point of deep copy and source are the same.")
897    
898     c.modifyBy(Dilation(-1.))
899     cp=c.getControlPoints()
900     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.")
901     self.failUnless(p3 == cp[0],"1st new point after Dilation.")
902     self.failUnless(p2 == cp[1],"2nd new point after Dilation.")
903     self.failUnless(p1 == cp[2],"3rd new point after Dilation.")
904     self.failUnless(p0 == cp[3],"4th new point after Dilation.")
905    
906     dc=c.apply(Dilation(-1.))
907     dccp=dc.getControlPoints()
908     self.failUnless(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
909     self.failUnless(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
910     self.failUnless(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
911     self.failUnless(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
912     self.failUnless(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
913    
914 gross 916 def test_BezierCurve(self):
915     p0=Point(0,0,0,0.1)
916     p1=Point(1,1,1,0.2)
917     p2=Point(2,2,2,0.3)
918     p3=Point(3,3,3,0.4)
919     p4=Point(1,2,3)
920    
921 gross 931 self.failUnlessRaises(ValueError,BezierCurve,p0)
922 gross 916 c=BezierCurve(p0,p1,p2,p3)
923    
924     self.failUnless(len(c) == 4, "wrong spline curve length")
925     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
926     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
927    
928 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
929     self.failUnless(not c.isColocated(BezierCurve(p0,p1,p2)),"spline is colocated with spline of different length.")
930     self.failUnless(not c.isColocated(BezierCurve(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
931     self.failUnless(c.isColocated(BezierCurve(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
932     self.failUnless(c.isColocated(BezierCurve(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
933     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
934    
935 gross 916 co=c.getControlPoints()
936     self.failUnless(co[0]==p0, "1st control point is wrong.")
937     self.failUnless(co[1]==p1, "2nd control point is wrong.")
938     self.failUnless(co[2]==p2, "3rd control point is wrong.")
939     self.failUnless(co[3]==p3, "4th control point is wrong.")
940    
941     c.setLocalScale(3.)
942     co=c.getControlPoints()
943     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
944     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
945     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
946     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
947    
948     h=c.getPrimitives()
949     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
950     self.failUnless(p0 in h, "missing p0 in history.")
951     self.failUnless(p1 in h, "missing p1 in history.")
952     self.failUnless(p2 in h, "missing p2 in history.")
953     self.failUnless(p3 in h, "missing p3 in history.")
954     self.failUnless(c in h, "missing spline curve in history.")
955    
956     cp=c.copy()
957 gross 919 cpcp=cp.getControlPoints()
958 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
959 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
960     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
961     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
962     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
963     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
964 gross 916
965     c.modifyBy(Dilation(-1.))
966 gross 919 cp=c.getControlPoints()
967 gross 916 self.failUnless(c.isColocated(BezierCurve(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
968     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
969     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
970     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
971     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
972    
973     dc=c.apply(Dilation(-1.))
974 gross 919 dccp=dc.getControlPoints()
975 gross 916 self.failUnless(dc.isColocated(BezierCurve(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
976     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
977     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
978     self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
979     self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
980    
981     def test_BSpline(self):
982     p0=Point(0,0,0,0.1)
983     p1=Point(1,1,1,0.2)
984     p2=Point(2,2,2,0.3)
985     p3=Point(3,3,3,0.4)
986     p4=Point(1,2,3)
987    
988 gross 931 self.failUnlessRaises(ValueError,BSpline,p0)
989 gross 916 c=BSpline(p0,p1,p2,p3)
990    
991     self.failUnless(len(c) == 4, "wrong spline curve length")
992     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
993     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
994    
995 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
996     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
997    
998 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
999     self.failUnless(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
1000     self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
1001     self.failUnless(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
1002     self.failUnless(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1003     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
1004    
1005 gross 916 co=c.getControlPoints()
1006     self.failUnless(co[0]==p0, "1st control point is wrong.")
1007     self.failUnless(co[1]==p1, "2nd control point is wrong.")
1008     self.failUnless(co[2]==p2, "3rd control point is wrong.")
1009     self.failUnless(co[3]==p3, "4th control point is wrong.")
1010    
1011     c.setLocalScale(3.)
1012     co=c.getControlPoints()
1013     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1014     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1015     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
1016     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
1017    
1018     h=c.getPrimitives()
1019     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
1020     self.failUnless(p0 in h, "missing p0 in history.")
1021     self.failUnless(p1 in h, "missing p1 in history.")
1022     self.failUnless(p2 in h, "missing p2 in history.")
1023     self.failUnless(p3 in h, "missing p3 in history.")
1024     self.failUnless(c in h, "missing spline curve in history.")
1025    
1026     cp=c.copy()
1027 gross 919 cpcp=cp.getControlPoints()
1028 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
1029 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
1030     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1031     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1032     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
1033     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
1034 gross 916
1035     c.modifyBy(Dilation(-1.))
1036 gross 919 cp=c.getControlPoints()
1037 gross 916 self.failUnless(c.isColocated(BSpline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
1038     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
1039     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
1040     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
1041     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
1042    
1043     dc=c.apply(Dilation(-1.))
1044 gross 919 dccp=dc.getControlPoints()
1045 gross 916 self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
1046     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1047 gross 929 self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1048 gross 916 self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1049 gross 929 self.failUnless(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1050 gross 916 self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
1051 gross 929 self.failUnless(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
1052 gross 916 self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
1053 gross 929 self.failUnless(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
1054 gross 916
1055 gross 929 def test_ReverseBSpline(self):
1056     p0=Point(0,0,0,0.1)
1057     p1=Point(1,1,1,0.2)
1058     p2=Point(2,2,2,0.3)
1059     p3=Point(3,3,3,0.4)
1060     p4=Point(1,2,3)
1061    
1062     CC0=BSpline(p0,p1,p2,p3)
1063     c=-CC0
1064    
1065     self.failUnless(len(c) == 4, "wrong spline curve length")
1066     self.failUnless(c.getStartPoint()==p3, "wrong start point of spline curve")
1067     self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve")
1068    
1069 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1070     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1071    
1072 gross 929 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
1073     self.failUnless(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
1074     self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
1075     self.failUnless(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
1076     self.failUnless(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1077     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
1078    
1079     co=c.getControlPoints()
1080     self.failUnless(co[0]==p3, "1st control point is wrong.")
1081     self.failUnless(co[1]==p2, "2nd control point is wrong.")
1082     self.failUnless(co[2]==p1, "3rd control point is wrong.")
1083     self.failUnless(co[3]==p0, "4th control point is wrong.")
1084    
1085     c.setLocalScale(3.)
1086     co=c.getControlPoints()
1087     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1088     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1089     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
1090     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
1091    
1092     h=c.getPrimitives()
1093     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
1094     self.failUnless(p0 in h, "missing p0 in history.")
1095     self.failUnless(p1 in h, "missing p1 in history.")
1096     self.failUnless(p2 in h, "missing p2 in history.")
1097     self.failUnless(p3 in h, "missing p3 in history.")
1098     self.failUnless(CC0 in h, "missing spline curve in history.")
1099    
1100     cp=c.copy()
1101     cpcp=cp.getControlPoints()
1102     self.failUnless(not cp == c, "copy returns same spline curve.")
1103     self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
1104     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1105     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1106     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
1107     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
1108    
1109     c.modifyBy(Dilation(-1.))
1110     cp=c.getControlPoints()
1111     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.")
1112     self.failUnless(p3 == cp[0],"1st new point after Dilation.")
1113     self.failUnless(p2 == cp[1],"2nd new point after Dilation.")
1114     self.failUnless(p1 == cp[2],"3rd new point after Dilation.")
1115     self.failUnless(p0 == cp[3],"4th new point after Dilation.")
1116    
1117     dc=c.apply(Dilation(-1.))
1118     dccp=dc.getControlPoints()
1119     self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
1120     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1121     self.failUnless(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
1122     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1123     self.failUnless(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
1124     self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
1125     self.failUnless(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1126     self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
1127     self.failUnless(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1128    
1129 gross 916 def test_LineSegment(self):
1130     p0=Point(0,0,0,0.1)
1131     p1=Point(1,1,1,0.2)
1132     p4=Point(1,2,3)
1133    
1134     self.failUnlessRaises(TypeError,Line,p0)
1135     self.failUnlessRaises(TypeError,Line,p0,p1,p4)
1136    
1137     c=Line(p0,p1)
1138    
1139     self.failUnless(len(c) == 2, "wrong spline curve length")
1140     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
1141     self.failUnless(c.getEndPoint()==p1, "wrong end point of spline curve")
1142    
1143 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1144     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1145    
1146 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
1147     self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
1148     self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
1149     self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1150     self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
1151    
1152 gross 916 co=c.getControlPoints()
1153     self.failUnless(co[0]==p0, "1st control point is wrong.")
1154     self.failUnless(co[1]==p1, "2nd control point is wrong.")
1155    
1156     c.setLocalScale(3.)
1157     co=c.getControlPoints()
1158     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1159     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1160    
1161     h=c.getPrimitives()
1162     self.failUnless(len(h) == 3, "number of primitives in history is wrong.")
1163     self.failUnless(p0 in h, "missing p0 in history.")
1164     self.failUnless(p1 in h, "missing p1 in history.")
1165     self.failUnless(c in h, "missing spline curve in history.")
1166    
1167     cp=c.copy()
1168 gross 919 cpcp=cp.getControlPoints()
1169 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
1170 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
1171     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1172     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1173 gross 916
1174     c.modifyBy(Dilation(-1.))
1175 gross 919 cp=c.getControlPoints()
1176 gross 916 self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1177     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
1178     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
1179    
1180     dc=c.apply(Dilation(-1.))
1181 gross 919 dccp=dc.getControlPoints()
1182 gross 916 self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1183     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1184 gross 929 self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1185 gross 916 self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1186 gross 929 self.failUnless(dccp[1].isColocated(Point(1,1,1)),"2st point of Dilation is is wrongly located.")
1187 gross 916
1188 gross 929 def test_ReverseLineSegment(self):
1189     p0=Point(0,0,0,0.1)
1190     p1=Point(1,1,1,0.2)
1191     p4=Point(1,2,3)
1192    
1193     self.failUnlessRaises(TypeError,Line,p0)
1194     self.failUnlessRaises(TypeError,Line,p0,p1,p4)
1195    
1196     CC0=Line(p0,p1)
1197     c=-CC0
1198    
1199 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1200     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1201    
1202 gross 929 self.failUnless(len(c) == 2, "wrong spline curve length")
1203     self.failUnless(c.getStartPoint()==p1, "wrong start point of spline curve")
1204     self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve")
1205    
1206     self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
1207     self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
1208     self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
1209     self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1210     self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
1211    
1212     co=c.getControlPoints()
1213     self.failUnless(co[0]==p1, "1st control point is wrong.")
1214     self.failUnless(co[1]==p0, "2nd control point is wrong.")
1215    
1216     c.setLocalScale(3.)
1217     co=c.getControlPoints()
1218     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1219     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1220    
1221     h=c.getPrimitives()
1222     self.failUnless(len(h) == 3, "number of primitives in history is wrong.")
1223     self.failUnless(p0 in h, "missing p0 in history.")
1224     self.failUnless(p1 in h, "missing p1 in history.")
1225     self.failUnless(CC0 in h, "missing spline curve in history.")
1226    
1227     cp=c.copy()
1228     cpcp=cp.getControlPoints()
1229     self.failUnless(not cp == c, "copy returns same spline curve.")
1230     self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
1231     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1232     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1233    
1234     c.modifyBy(Dilation(-1.))
1235     cp=c.getControlPoints()
1236     self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1237     self.failUnless(p1 == cp[0],"1st new point after Dilation.")
1238     self.failUnless(p0 == cp[1],"2nd new point after Dilation.")
1239    
1240     dc=c.apply(Dilation(-1.))
1241     dccp=dc.getControlPoints()
1242     self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1243     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1244     self.failUnless(dccp[0].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1245     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1246     self.failUnless(dccp[1].isColocated(Point(0,0,0)),"2st point of Dilation is is wrongly located.")
1247    
1248     def test_Arc(self):
1249 gross 917 center=Point(0,0,0,0.1)
1250     p_start=Point(1,1,1,0.2)
1251     p_end=Point(1,2,3)
1252 gross 919 p4=Point(10,2,3)
1253 gross 917
1254     self.failUnlessRaises(TypeError,Arc,Primitive())
1255 gross 916
1256 gross 917 c=Arc(center,p_start,p_end)
1257    
1258     self.failUnless(c.getCenterPoint()==center, "wrong center point")
1259     self.failUnless(c.getStartPoint()==p_start, "wrong start point")
1260     self.failUnless(c.getEndPoint()==p_end, "wrong end point")
1261    
1262 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1263     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1264    
1265 gross 919 self.failUnless(not c.isColocated(p4),"spline is colocated with point.")
1266     self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1267     self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1268     self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.")
1269     self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.")
1270     self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1271     self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.")
1272    
1273 gross 917 h=c.getPrimitives()
1274     self.failUnless(len(h) == 4, "number of primitives in history is wrong.")
1275     self.failUnless(center in h, "missing center in history.")
1276     self.failUnless(p_start in h, "missing p_start in history.")
1277     self.failUnless(p_end in h, "missing p_end in history.")
1278     self.failUnless(c in h, "missing spline curve in history.")
1279    
1280    
1281     c.setLocalScale(3.)
1282     self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1283     self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1284     self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1285    
1286     cp=c.copy()
1287     self.failUnless(isinstance(cp,Arc), "copy returns is not an arc.")
1288     self.failUnless(not cp == c, "copy returns same arc.")
1289 gross 919 self.failUnless(cp.isColocated(Arc(center,p_start,p_end)),"arc is not colocated with its copy.")
1290     self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1291     self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1292     self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1293 gross 917
1294     c.modifyBy(Dilation(-1.))
1295 gross 919 self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1296     self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.")
1297     self.failUnless(c.getStartPoint() == p_start,"wrong start point after dilation.")
1298     self.failUnless(c.getEndPoint() == p_end,"wrong end point after dilation.")
1299 gross 917
1300     dc=c.apply(Dilation(-1.))
1301 gross 919 self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1302     self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1303 gross 929 self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1304 gross 919 self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1305 gross 929 self.failUnless(dc.getStartPoint().isColocated(Point(1,1,1)),"start point of dilation is wrong.")
1306 gross 919 self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1307 gross 929 self.failUnless(dc.getEndPoint().isColocated(Point(1,2,3)),"end point of dilation is wrong.")
1308 gross 917
1309 gross 929 def test_ReverseArc(self):
1310     center=Point(0,0,0,0.1)
1311     p_start=Point(1,1,1,0.2)
1312     p_end=Point(1,2,3)
1313     p4=Point(10,2,3)
1314    
1315     self.failUnlessRaises(TypeError,Arc,Primitive())
1316    
1317     CC0=Arc(center,p_start,p_end)
1318     c=-CC0
1319    
1320     self.failUnless(c.getCenterPoint()==center, "wrong center point")
1321     self.failUnless(c.getStartPoint()==p_end, "wrong start point")
1322     self.failUnless(c.getEndPoint()==p_start, "wrong end point")
1323    
1324 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1325     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1326    
1327 gross 929 self.failUnless(not c.isColocated(p4),"spline is colocated with point.")
1328     self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1329     self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1330     self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.")
1331     self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.")
1332     self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1333     self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.")
1334    
1335     h=c.getPrimitives()
1336     self.failUnless(len(h) == 4, "number of primitives in history is wrong.")
1337     self.failUnless(center in h, "missing center in history.")
1338     self.failUnless(p_start in h, "missing p_start in history.")
1339     self.failUnless(p_end in h, "missing p_end in history.")
1340     self.failUnless(CC0 in h, "missing spline curve in history.")
1341    
1342    
1343     c.setLocalScale(3.)
1344     self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1345     self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1346     self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1347    
1348     cp=c.copy()
1349     self.failUnless(isinstance(cp,ReverseArc), "copy returns is not an arc.")
1350     self.failUnless(not cp == c, "copy returns same arc.")
1351     self.failUnless(cp.isColocated(Arc(center,p_end,p_start)),"arc is not colocated with its copy.")
1352     self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1353     self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1354     self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1355    
1356     c.modifyBy(Dilation(-1.))
1357     self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1358     self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.")
1359     self.failUnless(c.getStartPoint() == p_end,"wrong start point after dilation.")
1360     self.failUnless(c.getEndPoint() == p_start,"wrong end point after dilation.")
1361    
1362     dc=c.apply(Dilation(-1.))
1363     self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1364     self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1365     self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1366     self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1367     self.failUnless(dc.getStartPoint().isColocated(Point(1,2,3)),"start point of dilation is wrong.")
1368     self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1369     self.failUnless(dc.getEndPoint().isColocated(Point(1,1,1)),"end point of dilation is wrong.")
1370    
1371 ksteube 1312 def test_Ellipse(self):
1372     center=Point(0,0,0,0.1)
1373     main_axis_point=Point(0,1,0,0.1)
1374     p_start=Point(1,1,1,0.2)
1375     p_end=Point(1,2,3)
1376     p4=Point(10,2,3)
1377    
1378     self.failUnlessRaises(TypeError,Ellipse,Primitive())
1379     self.failUnlessRaises(TypeError,Ellipse,center,center,p_start,p_end)
1380     self.failUnlessRaises(TypeError,Ellipse,center,main_axis_point,p_start,p_start)
1381    
1382    
1383     c=Ellipse(center,main_axis_point,p_start,p_end)
1384    
1385     self.failUnless(c.getCenterPoint()==center, "wrong center point")
1386     self.failUnless(c.getStartPoint()==p_start, "wrong start point")
1387     self.failUnless(c.getEndPoint()==p_end, "wrong end point")
1388     self.failUnless(c.getPointOnMainAxis()==main_axis_point, "wrong point on main axis")
1389    
1390     self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1391     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1392    
1393     self.failUnless(not c.isColocated(p4),"spline is colocated with point.")
1394     self.failUnless(not c.isColocated(Ellipse(center,main_axis_point,p4,p_end)),"spline is colocated with spline with differnt start point.")
1395     self.failUnless(not c.isColocated(Ellipse(center,main_axis_point,p_start,p4)),"spline is colocated with spline with differnt end point.")
1396     self.failUnless(not c.isColocated(Ellipse(center,p4,p_start,p_end)),"spline is colocated with spline with differnt main axis point.")
1397     self.failUnless(not c.isColocated(Ellipse(p4,main_axis_point,p_start,p_end)),"spline is colocated with spline with differnt center.")
1398     self.failUnless(c.isColocated(Ellipse(center,main_axis_point,p_start,p_end)),"spline is not colocated with spline with same points.")
1399     self.failUnless(c.isColocated(Ellipse(center,main_axis_point,p_start,p_end)),"spline is not colocated with spline with same points.")
1400     self.failUnless(c.isColocated(Ellipse(center,main_axis_point,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1401     self.failUnless(not c.isColocated(Curve(center,main_axis_point,p_start,p_end)),"spline curve is identified with curve.")
1402    
1403     h=c.getPrimitives()
1404     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
1405     self.failUnless(center in h, "missing center in history.")
1406     self.failUnless(p_start in h, "missing p_start in history.")
1407     self.failUnless(p_end in h, "missing p_end in history.")
1408     self.failUnless(main_axis_point in h, "missing main_axi