Parent Directory
|
Revision Log
pycad test fixed.
1 | ksteube | 1809 | |
2 | ######################################################## | ||
3 | ksteube | 1312 | # |
4 | jfenwick | 2548 | # Copyright (c) 2003-2009 by University of Queensland |
5 | ksteube | 1809 | # 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 | jfenwick | 2549 | __copyright__="""Copyright (c) 2003-2009 by University of Queensland |
15 | ksteube | 1809 | 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 | jfenwick | 2455 | import numpy |
27 | gross | 905 | 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 | 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]]) |
49 | gross | 907 | |
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 | jfenwick | 2455 | return math.sqrt(numpy.dot(x-y,x-y)) |
55 | gross | 905 | def test_Translation_x(self): |
56 | t=Translation([1,0,0]) | ||
57 | s0=t([1,0,0]) | ||
58 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
59 | self.failUnless(self.__distance(s0,numpy.array([2,0,0]))<self.ABS_TOL,"s0 is wrong.") | ||
60 | gross | 905 | s1=t([0,1,0]) |
61 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
62 | self.failUnless(self.__distance(s1,numpy.array([1,1,0]))<self.ABS_TOL,"s1 is wrong.") | ||
63 | gross | 905 | s2=t([0,0,1]) |
64 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
65 | self.failUnless(self.__distance(s2,numpy.array([1,0,1]))<self.ABS_TOL,"s2 is wrong.") | ||
66 | gross | 905 | def test_Translation_y(self): |
67 | t=Translation([0,1,0]) | ||
68 | s0=t([1,0,0]) | ||
69 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
70 | self.failUnless(self.__distance(s0,numpy.array([1,1,0]))<self.ABS_TOL,"s0 is wrong.") | ||
71 | gross | 905 | s1=t([0,1,0]) |
72 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
73 | self.failUnless(self.__distance(s1,numpy.array([0,2,0]))<self.ABS_TOL,"s1 is wrong.") | ||
74 | gross | 905 | s2=t([0,0,1]) |
75 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
76 | self.failUnless(self.__distance(s2,numpy.array([0,1,1]))<self.ABS_TOL,"s2 is wrong.") | ||
77 | gross | 905 | def test_Translation_z(self): |
78 | t=Translation([0,0,1]) | ||
79 | s0=t([1,0,0]) | ||
80 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
81 | self.failUnless(self.__distance(s0,numpy.array([1,0,1]))<self.ABS_TOL,"s0 is wrong.") | ||
82 | gross | 905 | s1=t([0,1,0]) |
83 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
84 | self.failUnless(self.__distance(s1,numpy.array([0,1,1]))<self.ABS_TOL,"s1 is wrong.") | ||
85 | gross | 905 | s2=t([0,0,1]) |
86 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
87 | self.failUnless(self.__distance(s2,numpy.array([0,0,2]))<self.ABS_TOL,"s2 is wrong.") | ||
88 | gross | 905 | def test_Dilation_0_two(self): |
89 | t=Dilation(2.) | ||
90 | s0=t([1,0,0]) | ||
91 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
92 | self.failUnless(self.__distance(s0,numpy.array([2,0,0]))<self.ABS_TOL,"s0 is wrong.") | ||
93 | gross | 905 | s1=t([0,1,0]) |
94 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
95 | self.failUnless(self.__distance(s1,numpy.array([0,2,0]))<self.ABS_TOL,"s1 is wrong.") | ||
96 | gross | 905 | s2=t([0,0,1]) |
97 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
98 | self.failUnless(self.__distance(s2,numpy.array([0,0,2]))<self.ABS_TOL,"s2 is wrong.") | ||
99 | gross | 905 | def test_Dilation_0_half(self): |
100 | t=Dilation(0.5) | ||
101 | s0=t([1,0,0]) | ||
102 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
103 | self.failUnless(self.__distance(s0,numpy.array([0.5,0,0]))<self.ABS_TOL,"s0 is wrong.") | ||
104 | gross | 905 | s1=t([0,1,0]) |
105 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
106 | self.failUnless(self.__distance(s1,numpy.array([0,0.5,0]))<self.ABS_TOL,"s1 is wrong.") | ||
107 | gross | 905 | s2=t([0,0,1]) |
108 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
109 | self.failUnless(self.__distance(s2,numpy.array([0,0,0.5]))<self.ABS_TOL,"s2 is wrong.") | ||
110 | gross | 905 | def test_Dilation_x_two(self): |
111 | t=Dilation(2.,[1.,0.,0.]) | ||
112 | s0=t([1,0,0]) | ||
113 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
114 | self.failUnless(self.__distance(s0,numpy.array([1,0,0]))<self.ABS_TOL,"s0 is wrong.") | ||
115 | gross | 905 | s0_1=t([0,0,0]) |
116 | jfenwick | 2455 | self.failUnless(isinstance(s0_1,numpy.ndarray),"s0_1 is not an ndarray object.") |
117 | self.failUnless(self.__distance(s0_1,numpy.array([-1.,0,0]))<self.ABS_TOL,"s0_1 is wrong.") | ||
118 | gross | 905 | s1=t([0,1,0]) |
119 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
120 | self.failUnless(self.__distance(s1,numpy.array([-1,2,0]))<self.ABS_TOL,"s1 is wrong.") | ||
121 | gross | 905 | s2=t([0,0,1]) |
122 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
123 | self.failUnless(self.__distance(s2,numpy.array([-1.,0,2]))<self.ABS_TOL,"s2 is wrong.") | ||
124 | gross | 905 | def test_Dilation_x_half(self): |
125 | t=Dilation(0.5,[1.,0.,0.]) | ||
126 | s0=t([1,0,0]) | ||
127 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
128 | self.failUnless(self.__distance(s0,numpy.array([1.,0,0]))<self.ABS_TOL,"s0 is wrong.") | ||
129 | gross | 905 | s0_1=t([0,0,0]) |
130 | jfenwick | 2455 | self.failUnless(isinstance(s0_1,numpy.ndarray),"s0_1 is not an ndarray object.") |
131 | self.failUnless(self.__distance(s0_1,numpy.array([.5,0,0]))<self.ABS_TOL,"s0_1 is wrong.") | ||
132 | gross | 905 | s1=t([0,1,0]) |
133 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
134 | self.failUnless(self.__distance(s1,numpy.array([0.5,0.5,0]))<self.ABS_TOL,"s1 is wrong.") | ||
135 | gross | 905 | s2=t([0,0,1]) |
136 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
137 | self.failUnless(self.__distance(s2,numpy.array([0.5,0,0.5]))<self.ABS_TOL,"s2 is wrong.") | ||
138 | gross | 905 | def test_Dilation_y_two(self): |
139 | t=Dilation(2.,[0.,1.,0.]) | ||
140 | s0=t([1,0,0]) | ||
141 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
142 | self.failUnless(self.__distance(s0,numpy.array([2.,-1.,0]))<self.ABS_TOL,"s0 is wrong.") | ||
143 | gross | 905 | s1_1=t([0,0,0]) |
144 | jfenwick | 2455 | self.failUnless(isinstance(s1_1,numpy.ndarray),"s1_1 is not an ndarray object.") |
145 | self.failUnless(self.__distance(s1_1,numpy.array([0.,-1.,0]))<self.ABS_TOL,"s1_1 is wrong.") | ||
146 | gross | 905 | s1=t([0,1,0]) |
147 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
148 | self.failUnless(self.__distance(s1,numpy.array([0.,1.,0]))<self.ABS_TOL,"s1 is wrong.") | ||
149 | gross | 905 | s2=t([0,0,1]) |
150 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
151 | self.failUnless(self.__distance(s2,numpy.array([0.,-1.,2]))<self.ABS_TOL,"s2 is wrong.") | ||
152 | gross | 905 | def test_Dilation_y_half(self): |
153 | t=Dilation(0.5,[0.,1.,0.]) | ||
154 | s0=t([1,0,0]) | ||
155 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
156 | self.failUnless(self.__distance(s0,numpy.array([0.5,0.5,0]))<self.ABS_TOL,"s0 is wrong.") | ||
157 | gross | 905 | s1_1=t([0,0,0]) |
158 | jfenwick | 2455 | self.failUnless(isinstance(s1_1,numpy.ndarray),"s1_1 is not an ndarray object.") |
159 | self.failUnless(self.__distance(s1_1,numpy.array([0,0.5,0]))<self.ABS_TOL,"s1_1 is wrong.") | ||
160 | gross | 905 | s1=t([0,1,0]) |
161 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
162 | self.failUnless(self.__distance(s1,numpy.array([0.,1.,0]))<self.ABS_TOL,"s1 is wrong.") | ||
163 | gross | 905 | s2=t([0,0,1]) |
164 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
165 | self.failUnless(self.__distance(s2,numpy.array([0.,0.5,0.5]))<self.ABS_TOL,"s2 is wrong.") | ||
166 | gross | 905 | def test_Dilation_z_two(self): |
167 | t=Dilation(2.,[0.,0.,1.]) | ||
168 | s0=t([1,0,0]) | ||
169 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
170 | self.failUnless(self.__distance(s0,numpy.array([2.,0.,-1.]))<self.ABS_TOL,"s0 is wrong.") | ||
171 | gross | 905 | s2_1=t([0,0,0]) |
172 | jfenwick | 2455 | self.failUnless(isinstance(s2_1,numpy.ndarray),"s2_1 is not an ndarray object.") |
173 | self.failUnless(self.__distance(s2_1,numpy.array([0.,0.,-1.]))<self.ABS_TOL,"s2_1 is wrong.") | ||
174 | gross | 905 | s1=t([0,1,0]) |
175 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
176 | self.failUnless(self.__distance(s1,numpy.array([0.,2.,-1.]))<self.ABS_TOL,"s1 is wrong.") | ||
177 | gross | 905 | s2=t([0,0,1]) |
178 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
179 | self.failUnless(self.__distance(s2,numpy.array([0.,0.,1.]))<self.ABS_TOL,"s2 is wrong.") | ||
180 | gross | 905 | def test_Dilation_z_half(self): |
181 | t=Dilation(0.5,[0.,0.,1.]) | ||
182 | s0=t([1,0,0]) | ||
183 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
184 | self.failUnless(self.__distance(s0,numpy.array([0.5,0.,0.5]))<self.ABS_TOL,"s0 is wrong.") | ||
185 | gross | 905 | s2_1=t([0,0,0]) |
186 | jfenwick | 2455 | self.failUnless(isinstance(s2_1,numpy.ndarray),"s2_1 is not an ndarray object.") |
187 | self.failUnless(self.__distance(s2_1,numpy.array([0,0,0.5]))<self.ABS_TOL,"s2_1 is wrong.") | ||
188 | gross | 905 | s1=t([0,1,0]) |
189 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
190 | self.failUnless(self.__distance(s1,numpy.array([0.,0.5,0.5]))<self.ABS_TOL,"s1 is wrong.") | ||
191 | gross | 905 | s2=t([0,0,1]) |
192 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
193 | self.failUnless(self.__distance(s2,numpy.array([0.,0.,1.]))<self.ABS_TOL,"s2 is wrong.") | ||
194 | gross | 905 | def test_Reflection_x_offset0(self): |
195 | t=Reflection([1.,0.,0.]) | ||
196 | s0=t([1,0,0]) | ||
197 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
198 | self.failUnless(self.__distance(s0,numpy.array([-1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
199 | gross | 905 | s1=t([0,1,0]) |
200 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
201 | self.failUnless(self.__distance(s1,numpy.array([0,1,0]))<self.ABS_TOL,"s1 is wrong.") | ||
202 | gross | 905 | s2=t([0,0,1]) |
203 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
204 | self.failUnless(self.__distance(s2,numpy.array([0,0,1]))<self.ABS_TOL,"s2 is wrong.") | ||
205 | gross | 905 | s=t([1,2,3]) |
206 | jfenwick | 2455 | self.failUnless(isinstance(s,numpy.ndarray),"s is not an ndarray object.") |
207 | self.failUnless(self.__distance(s,numpy.array([-1.,2,3]))<self.ABS_TOL,"s is wrong.") | ||
208 | gross | 905 | def test_Reflection_x_offset2(self): |
209 | t=Reflection([-2.,0.,0.],offset=-4) | ||
210 | s0=t([1,0,0]) | ||
211 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
212 | self.failUnless(self.__distance(s0,numpy.array([3.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
213 | gross | 905 | s1=t([0,1,0]) |
214 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
215 | self.failUnless(self.__distance(s1,numpy.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.") | ||
216 | gross | 905 | s2=t([0,0,1]) |
217 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
218 | self.failUnless(self.__distance(s2,numpy.array([4,0,1]))<self.ABS_TOL,"s2 is wrong.") | ||
219 | gross | 905 | s=t([1,2,3]) |
220 | jfenwick | 2455 | self.failUnless(isinstance(s,numpy.ndarray),"s is not an ndarray object.") |
221 | self.failUnless(self.__distance(s,numpy.array([3.,2,3]))<self.ABS_TOL,"s is wrong.") | ||
222 | gross | 905 | def test_Reflection_x_offset2_vector(self): |
223 | t=Reflection([1.,0.,0.],offset=[2,0,0]) | ||
224 | s0=t([1,0,0]) | ||
225 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
226 | self.failUnless(self.__distance(s0,numpy.array([3.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
227 | gross | 905 | s1=t([0,1,0]) |
228 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
229 | self.failUnless(self.__distance(s1,numpy.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.") | ||
230 | gross | 905 | s2=t([0,0,1]) |
231 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
232 | self.failUnless(self.__distance(s2,numpy.array([4,0,1]))<self.ABS_TOL,"s2 is wrong.") | ||
233 | gross | 905 | s=t([1,2,3]) |
234 | jfenwick | 2455 | self.failUnless(isinstance(s,numpy.ndarray),"s is not an ndarray object.") |
235 | self.failUnless(self.__distance(s,numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
240 | self.failUnless(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
241 | gross | 907 | s1=t([0,1,0]) |
242 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
243 | self.failUnless(self.__distance(s1,numpy.array([0,-1,0]))<self.ABS_TOL,"s1 is wrong.") | ||
244 | gross | 907 | s2=t([0,0,1]) |
245 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
246 | self.failUnless(self.__distance(s2,numpy.array([0,0,1]))<self.ABS_TOL,"s2 is wrong.") | ||
247 | gross | 907 | s=t([1,2,3]) |
248 | jfenwick | 2455 | self.failUnless(isinstance(s,numpy.ndarray),"s is not an ndarray object.") |
249 | self.failUnless(self.__distance(s,numpy.array([1.,-2,3]))<self.ABS_TOL,"s is wrong.") | ||
250 | gross | 907 | def test_Reflection_y_offset2(self): |
251 | t=Reflection([0.,-2.,0.],offset=-4) | ||
252 | s0=t([1,0,0]) | ||
253 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
254 | self.failUnless(self.__distance(s0,numpy.array([1.,4,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
255 | gross | 907 | s1=t([0,1,0]) |
256 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
257 | self.failUnless(self.__distance(s1,numpy.array([0,3,0]))<self.ABS_TOL,"s1 is wrong.") | ||
258 | gross | 907 | s2=t([0,0,1]) |
259 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
260 | self.failUnless(self.__distance(s2,numpy.array([0,4,1]))<self.ABS_TOL,"s2 is wrong.") | ||
261 | gross | 907 | s=t([1,2,3]) |
262 | jfenwick | 2455 | self.failUnless(isinstance(s,numpy.ndarray),"s is not an ndarray object.") |
263 | self.failUnless(self.__distance(s,numpy.array([1.,2,3]))<self.ABS_TOL,"s is wrong.") | ||
264 | gross | 907 | def test_Reflection_y_offset2_vector(self): |
265 | t=Reflection([0.,1.,0.],offset=[0,2,0]) | ||
266 | s0=t([1,0,0]) | ||
267 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
268 | self.failUnless(self.__distance(s0,numpy.array([1.,4,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
269 | gross | 907 | s1=t([0,1,0]) |
270 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
271 | self.failUnless(self.__distance(s1,numpy.array([0,3,0]))<self.ABS_TOL,"s1 is wrong.") | ||
272 | gross | 907 | s2=t([0,0,1]) |
273 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
274 | self.failUnless(self.__distance(s2,numpy.array([0,4,1]))<self.ABS_TOL,"s2 is wrong.") | ||
275 | gross | 907 | s=t([1,2,3]) |
276 | jfenwick | 2455 | self.failUnless(isinstance(s,numpy.ndarray),"s is not an ndarray object.") |
277 | self.failUnless(self.__distance(s,numpy.array([1.,2,3]))<self.ABS_TOL,"s is wrong.") | ||
278 | gross | 907 | def test_Reflection_z_offset0(self): |
279 | t=Reflection([0.,0.,1.]) | ||
280 | s0=t([1,0,0]) | ||
281 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
282 | self.failUnless(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
283 | gross | 907 | s1=t([0,1,0]) |
284 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
285 | self.failUnless(self.__distance(s1,numpy.array([0,1,0]))<self.ABS_TOL,"s1 is wrong.") | ||
286 | gross | 907 | s2=t([0,0,1]) |
287 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
288 | self.failUnless(self.__distance(s2,numpy.array([0,0,-1]))<self.ABS_TOL,"s2 is wrong.") | ||
289 | gross | 907 | s=t([1,2,3]) |
290 | jfenwick | 2455 | self.failUnless(isinstance(s,numpy.ndarray),"s is not an ndarray object.") |
291 | self.failUnless(self.__distance(s,numpy.array([1.,2,-3]))<self.ABS_TOL,"s is wrong.") | ||
292 | gross | 907 | def test_Reflection_z_offset2(self): |
293 | t=Reflection([0.,0.,-2.],offset=-4) | ||
294 | s0=t([1,0,0]) | ||
295 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
296 | self.failUnless(self.__distance(s0,numpy.array([1.,0,4.]))<self.ABS_TOL,"s0 is wrong.") | ||
297 | gross | 907 | s1=t([0,1,0]) |
298 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
299 | self.failUnless(self.__distance(s1,numpy.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.") | ||
300 | gross | 907 | s2=t([0,0,1]) |
301 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
302 | self.failUnless(self.__distance(s2,numpy.array([0,0,3]))<self.ABS_TOL,"s2 is wrong.") | ||
303 | gross | 907 | s=t([1,2,3]) |
304 | jfenwick | 2455 | self.failUnless(isinstance(s,numpy.ndarray),"s is not an ndarray object.") |
305 | self.failUnless(self.__distance(s,numpy.array([1.,2,1]))<self.ABS_TOL,"s is wrong.") | ||
306 | gross | 907 | def test_Reflection_z_offset2_vector(self): |
307 | t=Reflection([0.,0.,1.],offset=[0,0,2]) | ||
308 | s0=t([1,0,0]) | ||
309 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
310 | self.failUnless(self.__distance(s0,numpy.array([1.,0,4.]))<self.ABS_TOL,"s0 is wrong.") | ||
311 | gross | 907 | s1=t([0,1,0]) |
312 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
313 | self.failUnless(self.__distance(s1,numpy.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.") | ||
314 | gross | 907 | s2=t([0,0,1]) |
315 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
316 | self.failUnless(self.__distance(s2,numpy.array([0,0,3]))<self.ABS_TOL,"s2 is wrong.") | ||
317 | gross | 907 | s=t([1,2,3]) |
318 | jfenwick | 2455 | self.failUnless(isinstance(s,numpy.ndarray),"s is not an ndarray object.") |
319 | self.failUnless(self.__distance(s,numpy.array([1.,2,1]))<self.ABS_TOL,"s is wrong.") | ||
320 | gross | 907 | 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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
324 | self.failUnless(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
325 | gross | 907 | s1=t([0,1,0]) |
326 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
327 | self.failUnless(self.__distance(s1,numpy.array([0.,0,1.]))<self.ABS_TOL,"s1 is wrong.") | ||
328 | gross | 907 | s2=t([0,0,1]) |
329 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
330 | self.failUnless(self.__distance(s2,numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
335 | self.failUnless(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
336 | gross | 907 | s1=t([0,1,0]) |
337 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
338 | self.failUnless(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") | ||
339 | gross | 907 | self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.") |
340 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s1,[0,1,0]),numpy.array([1.,0.,0.]))<0.,"s1 has wrong orientation.") |
341 | gross | 907 | s2=t([0,0,1]) |
342 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
343 | self.failUnless(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") | ||
344 | gross | 907 | self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
345 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s2,[0,0,1]),numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
350 | self.failUnless(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
351 | gross | 907 | s1=t([0,1,0]) |
352 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
353 | self.failUnless(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") | ||
354 | gross | 907 | self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.") |
355 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s1,[0,1,0]),numpy.array([1.,0.,0.]))>0.,"s1 has wrong orientation.") |
356 | gross | 907 | s2=t([0,0,1]) |
357 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
358 | self.failUnless(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") | ||
359 | gross | 907 | self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
360 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s2,[0,0,1]),numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
365 | self.failUnless(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
366 | gross | 907 | s1=t([0,1,0]) |
367 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
368 | self.failUnless(self.__distance(s1,numpy.array([0.,0,-1.]))<self.ABS_TOL,"s1 is wrong.") | ||
369 | gross | 907 | s2=t([0,0,1]) |
370 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
371 | self.failUnless(self.__distance(s2,numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
376 | self.failUnless(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
377 | gross | 907 | s1=t([0,1,0]) |
378 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
379 | self.failUnless(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") | ||
380 | gross | 907 | self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.") |
381 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s1,[0,1,0]),numpy.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.") |
382 | gross | 907 | s2=t([0,0,1]) |
383 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
384 | self.failUnless(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") | ||
385 | gross | 907 | self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
386 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s2,[0,0,1]),numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
391 | self.failUnless(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
392 | gross | 907 | s1=t([0,1,0]) |
393 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
394 | self.failUnless(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") | ||
395 | gross | 907 | self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.") |
396 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s1,[0,1,0]),numpy.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.") |
397 | gross | 907 | s2=t([0,0,1]) |
398 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
399 | self.failUnless(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") | ||
400 | gross | 907 | self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
401 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s2,[0,0,1]),numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
406 | self.failUnless(self.__distance(s0,numpy.array([0.,0,-1.]))<self.ABS_TOL,"s0 is wrong.") | ||
407 | gross | 907 | s1=t([0,5,0]) |
408 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
409 | self.failUnless(self.__distance(s1,numpy.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.") | ||
410 | gross | 907 | s2=t([0,0,1]) |
411 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
412 | self.failUnless(self.__distance(s2,numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
417 | self.failUnless(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") | ||
418 | gross | 907 | self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.") |
419 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,1.,0.]))<0.,"s0 has wrong orientation.") |
420 | gross | 907 | s1=t([0,5,0]) |
421 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
422 | self.failUnless(self.__distance(s1,numpy.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.") | ||
423 | gross | 907 | s2=t([0,0,1]) |
424 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
425 | self.failUnless(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") | ||
426 | gross | 907 | self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
427 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s2,[0,0,1]),numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
432 | self.failUnless(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") | ||
433 | gross | 907 | self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.") |
434 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,1.,0.]))>0.,"s0 has wrong orientation.") |
435 | gross | 907 | s1=t([0,1,0]) |
436 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
437 | self.failUnless(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.") | ||
438 | gross | 907 | s2=t([0,0,1]) |
439 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
440 | self.failUnless(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") | ||
441 | gross | 907 | self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
442 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s2,[0,0,1]),numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
447 | self.failUnless(self.__distance(s0,numpy.array([0.,0,1.]))<self.ABS_TOL,"s0 is wrong.") | ||
448 | gross | 910 | s1=t([0,5,0]) |
449 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
450 | self.failUnless(self.__distance(s1,numpy.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.") | ||
451 | gross | 907 | s2=t([0,0,1]) |
452 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
453 | self.failUnless(self.__distance(s2,numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
458 | self.failUnless(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") | ||
459 | gross | 907 | self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.") |
460 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.") |
461 | gross | 907 | s1=t([0,1,0]) |
462 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
463 | self.failUnless(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.") | ||
464 | gross | 907 | s2=t([0,0,1]) |
465 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
466 | self.failUnless(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") | ||
467 | gross | 907 | self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
468 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s2,[0,0,1]),numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
473 | self.failUnless(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") | ||
474 | gross | 907 | self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.") |
475 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.") |
476 | gross | 907 | s1=t([0,1,0]) |
477 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
478 | self.failUnless(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.") | ||
479 | gross | 907 | s2=t([0,0,1]) |
480 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
481 | self.failUnless(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") | ||
482 | gross | 907 | self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
483 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s2,[0,0,1]),numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
488 | self.failUnless(self.__distance(s0,numpy.array([0.,1,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
489 | gross | 907 | s1=t([0,5,0]) |
490 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
491 | self.failUnless(self.__distance(s1,numpy.array([-5.,0,0.]))<self.ABS_TOL,"s1 is wrong.") | ||
492 | gross | 907 | s2=t([0,0,1]) |
493 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
494 | self.failUnless(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") | ||
495 | gross | 907 | 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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
499 | self.failUnless(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") | ||
500 | gross | 907 | self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.") |
501 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,1.]))<0.,"s0 has wrong orientation.") |
502 | gross | 907 | s1=t([0,5,0]) |
503 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
504 | self.failUnless(abs(numpy.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.") | ||
505 | gross | 907 | self.failUnless(abs(s1[1]/5.-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.") |
506 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s1,[0,5,0]),numpy.array([0.,0.,1.]))<0.,"s1 has wrong orientation.") |
507 | gross | 907 | s2=t([0,0,1]) |
508 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
509 | self.failUnless(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") | ||
510 | gross | 907 | 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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
514 | self.failUnless(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") | ||
515 | gross | 907 | self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.") |
516 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,1.]))>0.,"s0 has wrong orientation.") |
517 | gross | 907 | s1=t([0,5,0]) |
518 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
519 | self.failUnless(abs(numpy.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.") | ||
520 | gross | 907 | self.failUnless(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.") |
521 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s1,[0,1,0]),numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
526 | self.failUnless(self.__distance(s0,numpy.array([0.,-1,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
527 | gross | 910 | s1=t([0,5,0]) |
528 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
529 | self.failUnless(self.__distance(s1,numpy.array([5.,0,0.]))<self.ABS_TOL,"s1 is wrong.") | ||
530 | gross | 907 | s2=t([0,0,1]) |
531 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
532 | self.failUnless(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") | ||
533 | gross | 907 | 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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
537 | self.failUnless(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") | ||
538 | gross | 907 | self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.") |
539 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.") |
540 | gross | 907 | s1=t([0,1,0]) |
541 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
542 | self.failUnless(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") | ||
543 | gross | 907 | self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.") |
544 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s1,[0,1,0]),numpy.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.") |
545 | gross | 907 | s2=t([0,0,1]) |
546 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
547 | self.failUnless(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") | ||
548 | gross | 907 | 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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
552 | self.failUnless(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") | ||
553 | gross | 907 | self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.") |
554 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.") |
555 | gross | 907 | s1=t([0,1,0]) |
556 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
557 | self.failUnless(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") | ||
558 | gross | 907 | self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.") |
559 | jfenwick | 2455 | self.failUnless(numpy.dot(_cross(s1,[0,1,0]),numpy.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.") |
560 | gross | 907 | s2=t([0,0,1]) |
561 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
562 | self.failUnless(self.__distance(s2,numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
567 | self.failUnless(self.__distance(s0,numpy.array([1.,1,1.]))<self.ABS_TOL,"s0 is wrong.") | ||
568 | gross | 910 | s1=t([0,1,0]) |
569 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
570 | self.failUnless(self.__distance(s1,numpy.array([0.,1,2.]))<self.ABS_TOL,"s1 is wrong.") | ||
571 | gross | 910 | s2=t([0,0,1]) |
572 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
573 | self.failUnless(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") | ||
574 | gross | 910 | 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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
578 | self.failUnless(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
579 | gross | 910 | s1=t([0,1,0]) |
580 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
581 | self.failUnless(self.__distance(s1,numpy.array([1.,1,1.]))<self.ABS_TOL,"s1 is wrong.") | ||
582 | gross | 910 | s2=t([0,0,1]) |
583 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
584 | self.failUnless(self.__distance(s2,numpy.array([2.,0,1.]))<self.ABS_TOL,"s2 is wrong.") | ||
585 | gross | 910 | 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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
589 | self.failUnless(self.__distance(s0,numpy.array([1.,2,0.]))<self.ABS_TOL,"s0 is wrong.") | ||
590 | gross | 910 | s1=t([0,1,0]) |
591 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
592 | self.failUnless(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.") | ||
593 | gross | 910 | s2=t([0,0,1]) |
594 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
595 | self.failUnless(self.__distance(s2,numpy.array([1.,1,1.]))<self.ABS_TOL,"s2 is wrong.") | ||
596 | gross | 910 | 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 | jfenwick | 2455 | self.failUnless(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.") |
600 | self.failUnless(abs(numpy.dot(s0,s0)-2.)<self.ABS_TOL,"s0 length is wrong.") | ||
601 | self.failUnless(abs(numpy.dot(s0,numpy.array([1,-1,0])))<self.ABS_TOL,"s0 angle is wrong.") | ||
602 | self.failUnless(numpy.dot(_cross(s0,[1,-1,0]),numpy.array([1.,1.,1.]))<0.,"s0 has wrong orientation.") | ||
603 | gross | 910 | s1=t([0,1,-1]) |
604 | jfenwick | 2455 | self.failUnless(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.") |
605 | self.failUnless(abs(numpy.dot(s1,s1)-2.)<self.ABS_TOL,"s1 length is wrong.") | ||
606 | self.failUnless(abs(numpy.dot(s1,numpy.array([0,1,-1])))<self.ABS_TOL,"s1 angle is wrong.") | ||
607 | self.failUnless(numpy.dot(_cross(s1,[0,1,-1]),numpy.array([1.,1.,1.]))<0.,"s1 has wrong orientation.") | ||
608 | gross | 910 | s2=t([-1,0,1]) |
609 | jfenwick | 2455 | self.failUnless(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.") |
610 | self.failUnless(abs(numpy.dot(s2,s2)-2.)<self.ABS_TOL,"s2 length is wrong.") | ||
611 | self.failUnless(abs(numpy.dot(s2,numpy.array([-1,0,1])))<self.ABS_TOL,"s2 angle is wrong.") | ||
612 | self.failUnless(numpy.dot(_cross(s2,[-1,0,1]),numpy.array([1.,1.,1.]))<0.,"s2 has wrong orientation.") | ||
613 | gross | 910 | s3=t([1,1,1]) |
614 | jfenwick | 2455 | self.failUnless(isinstance(s3,numpy.ndarray),"s3 is not an ndarray object.") |
615 | self.failUnless(self.__distance(s3,numpy.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 | jfenwick | 2455 | self.failUnless(isinstance(c,numpy.ndarray),"coordinates are not an ndarray object.") |
661 | gross | 912 | 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 | jfenwick | 2455 | self.failUnless(isinstance(c,numpy.ndarray),"new coordinates are not an ndarray object.") |
669 | gross | 912 | 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 | jfenwick | 2455 | self.failUnless(not p.isColocated(numpy.array([-1.,-2.,-3.])),"colocation with ndarray representation not detected.") |
676 | gross | 916 | 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 | jfenwick | 2455 | shift_p=p+numpy.array([1,1,1]) |
716 | self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by ndarray failed") | ||
717 | self.failUnless(not shift_p.getID() == p.getID(),"shift by ndarray has same Id") | ||
718 | self.failUnless(shift_p.getLocalScale()==3.,"shift by ndarray has wrong local scale.") | ||
719 | gross | 915 | # 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 | jfenwick | 2455 | shift_p=p-numpy.array([1,1,1]) |
726 | self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -ndarray failed") | ||
727 | self.failUnless(not shift_p.getID() == p.getID(),"shift by -ndarray has same Id") | ||
728 | self.failUnless(shift_p.getLocalScale()==3.,"shift by -ndarray has wrong local scale.") | ||
729 | gross | 915 | # overloaded inplace add: |
730 | p+=[1,1,1] | ||
731 | self.failUnless(p.isColocated(Point(2,3.,4)),"modification by list shift failed") | ||
732 | |||
733 | jfenwick | 2455 | p+=numpy.array([1,1,1]) |
734 | self.failUnless(p.isColocated(Point(3,4,5)),"modification by ndarray shift failed") | ||
735 | gross | 915 | |
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 | jfenwick | 2455 | p-=numpy.array([1,1,1]) |
741 | self.failUnless(p.isColocated(Point(1,2.,3)),"modification by -ndarray shift failed") | ||
742 | gross | 915 | |
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 | 2429 | self.failUnless(dc.getElementDistribution() == None, "element distribution set.") |
1189 | dc.setElementDistribution(10,0.2,False) | ||
1190 | d=dc.getElementDistribution() | ||
1191 | self.failUnless(d[0] == 10, "number of element is wrong.") | ||
1192 | self.failUnless(d[1] == 0.2, "propagation factor is wrong.") | ||
1193 | self.failUnless(d[2] == False, "bump flag wrong") | ||
1194 | dc.resetElementDistribution() | ||
1195 | self.failUnless(dc.getElementDistribution() == None, "resetted element distribution set.") | ||
1196 | |||
1197 | |||
1198 | gross | 929 | def test_ReverseLineSegment(self): |
1199 | p0=Point(0,0,0,0.1) | ||
1200 | p1=Point(1,1,1,0.2) | ||
1201 | p4=Point(1,2,3) | ||
1202 | |||
1203 | self.failUnlessRaises(TypeError,Line,p0) | ||
1204 | self.failUnlessRaises(TypeError,Line,p0,p1,p4) | ||
1205 | |||
1206 | CC0=Line(p0,p1) | ||
1207 | c=-CC0 | ||
1208 | |||
1209 | gross | 930 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |
1210 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") | ||
1211 | |||
1212 | gross | 929 | self.failUnless(len(c) == 2, "wrong spline curve length") |
1213 | self.failUnless(c.getStartPoint()==p1, "wrong start point of spline curve") | ||
1214 | self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve") | ||
1215 | |||
1216 | self.failUnless(not c.isColocated(p1),"spline is colocated with point.") | ||
1217 | self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.") | ||
1218 | self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.") | ||
1219 | self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.") | ||
1220 | self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.") | ||
1221 | |||
1222 | co=c.getControlPoints() | ||
1223 | self.failUnless(co[0]==p1, "1st control point is wrong.") | ||
1224 | self.failUnless(co[1]==p0, "2nd control point is wrong.") | ||
1225 | |||
1226 | c.setLocalScale(3.) | ||
1227 | co=c.getControlPoints() | ||
1228 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") | ||
1229 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") | ||
1230 | |||
1231 | h=c.getPrimitives() | ||
1232 | self.failUnless(len(h) == 3, "number of primitives in history is wrong.") | ||
1233 | self.failUnless(p0 in h, "missing p0 in history.") | ||
1234 | self.failUnless(p1 in h, "missing p1 in history.") | ||
1235 | self.failUnless(CC0 in h, "missing spline curve in history.") | ||
1236 | |||
1237 | cp=c.copy() | ||
1238 | cpcp=cp.getControlPoints() | ||
1239 | self.failUnless(not cp == c, "copy returns same spline curve.") | ||
1240 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") | ||
1241 | self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.") | ||
1242 | self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.") | ||
1243 | |||
1244 | c.modifyBy(Dilation(-1.)) | ||
1245 | cp=c.getControlPoints() | ||
1246 | self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.") | ||
1247 | self.failUnless(p1 == cp[0],"1st new point after Dilation.") | ||
1248 | self.failUnless(p0 == cp[1],"2nd new point after Dilation.") | ||
1249 | |||
1250 | dc=c.apply(Dilation(-1.)) | ||
1251 | dccp=dc.getControlPoints() | ||
1252 | self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.") | ||
1253 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") | ||
1254 | self.failUnless(dccp[0].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.") | ||
1255 | self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") | ||
1256 | self.failUnless(dccp[1].isColocated(Point(0,0,0)),"2st point of Dilation is is wrongly located.") | ||
1257 | |||
1258 | gross | 2429 | self.failUnless(dc.getElementDistribution() == None, "element distribution set.") |
1259 | dc.setElementDistribution(10,0.2,False) | ||
1260 | d=dc.getElementDistribution() | ||
1261 | self.failUnless(d[0] == 10, "number of element is wrong.") | ||
1262 | self.failUnless(d[1] == 0.2, "propagation factor is wrong.") | ||
1263 | self.failUnless(d[2] == False, "bump flag wrong") | ||
1264 | dc.resetElementDistribution() | ||
1265 | self.failUnless(dc.getElementDistribution() == None, "resetted element distribution set.") | ||
1266 | |||
1267 | |||
1268 | gross | 929 | def test_Arc(self): |
1269 | gross | 917 | center=Point(0,0,0,0.1) |
1270 | p_start=Point(1,1,1,0.2) | ||
1271 | p_end=Point(1,2,3) | ||
1272 | gross | 919 | p4=Point(10,2,3) |
1273 | gross | 917 | |
1274 | self.failUnlessRaises(TypeError,Arc,Primitive()) | ||
1275 | gross | 916 | |
1276 | gross | 917 | c=Arc(center,p_start,p_end) |
1277 | |||
1278 | self.failUnless(c.getCenterPoint()==center, "wrong center point") | ||
1279 | self.failUnless(c.getStartPoint()==p_start, "wrong start point") | ||
1280 | self.failUnless(c.getEndPoint()==p_end, "wrong end point") | ||
1281 | |||
1282 | gross | 930 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |
1283 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") | ||
1284 | |||
1285 | gross | 919 | self.failUnless(not c.isColocated(p4),"spline is colocated with point.") |
1286 | self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.") | ||
1287 | self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.") | ||
1288 | self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.") | ||
1289 | self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.") | ||
1290 | self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.") | ||
1291 | self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.") | ||
1292 | |||
1293 | gross | 917 | h=c.getPrimitives() |
1294 | self.failUnless(len(h) == 4, "number of primitives in history is wrong.") | ||
1295 | self.failUnless(center in h, "missing center in history.") | ||
1296 | self.failUnless(p_start in h, "missing p_start in history.") | ||
1297 | self.failUnless(p_end in h, "missing p_end in history.") | ||
1298 | self.failUnless(c in h, "missing spline curve in history.") | ||
1299 | |||
1300 | |||
1301 | c.setLocalScale(3.) | ||
1302 | self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.") | ||
1303 | self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.") | ||
1304 | self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.") | ||
1305 | |||
1306 | cp=c.copy() | ||
1307 | self.failUnless(isinstance(cp,Arc), "copy returns is not an arc.") | ||
1308 | self.failUnless(not cp == c, "copy returns same arc.") | ||
1309 | gross | 919 | self.failUnless(cp.isColocated(Arc(center,p_start,p_end)),"arc is not colocated with its copy.") |
1310 | self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source") | ||
1311 | self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source") | ||
1312 | self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source") | ||
1313 | gross | 917 | |
1314 | c.modifyBy(Dilation(-1.)) | ||
1315 | gross | 919 | self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.") |
1316 | self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.") | ||
1317 | self.failUnless(c.getStartPoint() == p_start,"wrong start point after dilation.") | ||
1318 | self.failUnless(c.getEndPoint() == p_end,"wrong end point after dilation.") | ||
1319 | gross | 917 | |
1320 | dc=c.apply(Dilation(-1.)) | ||
1321 | gross | 919 | self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.") |
1322 | self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.") | ||
1323 | gross | 929 | self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.") |
1324 | gross | 919 | self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.") |
1325 | gross | 929 | self.failUnless(dc.getStartPoint().isColocated(Point(1,1,1)),"start point of dilation is wrong.") |
1326 | gross | 919 | self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.") |
1327 | gross | 929 | self.failUnless(dc.getEndPoint().isColocated(Point(1,2,3)),"end point of dilation is wrong.") |
1328 | gross | 917 | |
1329 | gross | 2429 | self.failUnless(dc.getElementDistribution() == None, "element distribution set.") |
1330 | dc.setElementDistribution(10,0.2,False) | ||
1331 | d=dc.getElementDistribution() | ||
1332 | self.failUnless(d[0] == 10, "number of element is wrong.") | ||
1333 | self.failUnless(d[1] == 0.2, "propagation factor is wrong.") | ||
1334 | self.failUnless(d[2] == False, "bump flag wrong") | ||
1335 | dc.resetElementDistribution() | ||
1336 | self.failUnless(dc.getElementDistribution() == None, "resetted element distribution set.") | ||
1337 | |||
1338 | |||
1339 | gross | 929 | def test_ReverseArc(self): |
1340 | center=Point(0,0,0,0.1) | ||
1341 | p_start=Point(1,1,1,0.2) | ||
1342 | p_end=Point(1,2,3) | ||
1343 | p4=Point(10,2,3) | ||
1344 | |||
1345 | self.failUnlessRaises(TypeError,Arc,Primitive()) | ||
1346 | |||
1347 | CC0=Arc(center,p_start,p_end) | ||
1348 | c=-CC0 | ||
1349 | |||
1350 | self.failUnless(c.getCenterPoint()==center, "wrong center point") | ||
1351 | self.failUnless(c.getStartPoint()==p_end, "wrong start point") | ||
1352 | self.failUnless(c.getEndPoint()==p_start, "wrong end point") | ||
1353 | |||
1354 | gross | 930 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |
1355 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") | ||
1356 | |||
1357 | gross | 929 | self.failUnless(not c.isColocated(p4),"spline is colocated with point.") |
1358 | self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.") | ||
1359 | self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.") | ||
1360 | self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.") | ||
1361 | self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.") | ||
1362 | self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.") | ||
1363 | self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.") | ||
1364 | |||
1365 | h=c.getPrimitives() | ||
1366 | self.failUnless(len(h) == 4, "number of primitives in history is wrong.") | ||
1367 | self.failUnless(center in h, "missing center in history.") | ||
1368 | self.failUnless(p_start in h, "missing p_start in history.") | ||
1369 | self.failUnless(p_end in h, "missing p_end in history.") | ||
1370 | self.failUnless(CC0 in h, "missing spline curve in history.") | ||
1371 | |||
1372 | |||
1373 | c.setLocalScale(3.) | ||
1374 | self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.") | ||
1375 | self.failUnless(c.getStartPoint().getLocalScale |