/[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 3774 - (hide annotations)
Wed Jan 18 06:29:34 2012 UTC (7 years, 9 months ago) by jfenwick
File MIME type: text/x-python
File size: 235636 byte(s)
dudley, pasowrap, pycad

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