298 |
self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |
self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |
299 |
self.failUnless(self.__distance(s,numarray.array([1.,2,1]))<self.ABS_TOL,"s is wrong.") |
self.failUnless(self.__distance(s,numarray.array([1.,2,1]))<self.ABS_TOL,"s is wrong.") |
300 |
def test_Rotatation_x_90_0(self): |
def test_Rotatation_x_90_0(self): |
301 |
t=Rotatation(point1=[1.,0.,0.],angle=90*DEG) |
t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=90*DEG) |
302 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
303 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
304 |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
309 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
310 |
self.failUnless(self.__distance(s2,numarray.array([0.,-1.,0.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([0.,-1.,0.]))<self.ABS_TOL,"s2 is wrong.") |
311 |
def test_Rotatation_x_30_0(self): |
def test_Rotatation_x_30_0(self): |
312 |
t=Rotatation(point1=[1.,0.,0.],angle=30*DEG) |
t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=30*DEG) |
313 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
314 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
315 |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
324 |
self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
325 |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))<0.,"s2 has wrong orientation.") |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))<0.,"s2 has wrong orientation.") |
326 |
def test_Rotatation_x_330_0(self): |
def test_Rotatation_x_330_0(self): |
327 |
t=Rotatation(point1=[1.,0.,0.],angle=330*DEG) |
t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=330*DEG) |
328 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
329 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
330 |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
339 |
self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
340 |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.") |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.") |
341 |
def test_Rotatation_x_90(self): |
def test_Rotatation_x_90(self): |
342 |
t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=90*DEG) |
t=Rotatation(axis=[-1.,0.,0.],point=[2.,0.,0.],angle=90*DEG) |
343 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
344 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
345 |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
350 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
351 |
self.failUnless(self.__distance(s2,numarray.array([0.,1.,0.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([0.,1.,0.]))<self.ABS_TOL,"s2 is wrong.") |
352 |
def test_Rotatation_x_30(self): |
def test_Rotatation_x_30(self): |
353 |
t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=30*DEG) |
t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=30*DEG) |
354 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
355 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
356 |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
365 |
self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
366 |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.") |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.") |
367 |
def test_Rotatation_x_330(self): |
def test_Rotatation_x_330(self): |
368 |
t=Rotatation(point1=[1.,0.,0.],point0=[2.,0.,0.],angle=330*DEG) |
t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=330*DEG) |
369 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
370 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
371 |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
380 |
self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
381 |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.") |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.") |
382 |
def test_Rotatation_y_90_0(self): |
def test_Rotatation_y_90_0(self): |
383 |
t=Rotatation(point1=[0.,1.,0.],angle=90*DEG) |
t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=90*DEG) |
384 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
385 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
386 |
self.failUnless(self.__distance(s0,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s0 is wrong.") |
391 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
392 |
self.failUnless(self.__distance(s2,numarray.array([1,0.,0.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([1,0.,0.]))<self.ABS_TOL,"s2 is wrong.") |
393 |
def test_Rotatation_y_30_0(self): |
def test_Rotatation_y_30_0(self): |
394 |
t=Rotatation(point1=[0.,1.,0.],angle=30*DEG) |
t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=30*DEG) |
395 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
396 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
397 |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
406 |
self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
407 |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))<0.,"s2 has wrong orientation.") |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))<0.,"s2 has wrong orientation.") |
408 |
def test_Rotatation_y_330_0(self): |
def test_Rotatation_y_330_0(self): |
409 |
t=Rotatation(point1=[0.,1.,0.],angle=330*DEG) |
t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=330*DEG) |
410 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
411 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
412 |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
421 |
self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
422 |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.") |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.") |
423 |
def test_Rotatation_y_90(self): |
def test_Rotatation_y_90(self): |
424 |
t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=90*DEG) |
t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=90*DEG) |
425 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
426 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
427 |
self.failUnless(self.__distance(s0,numarray.array([0.,0,1.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([0.,0,1.]))<self.ABS_TOL,"s0 is wrong.") |
432 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
433 |
self.failUnless(self.__distance(s2,numarray.array([-1,0.,0.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([-1,0.,0.]))<self.ABS_TOL,"s2 is wrong.") |
434 |
def test_Rotatation_y_30(self): |
def test_Rotatation_y_30(self): |
435 |
t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=30*DEG) |
t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=30*DEG) |
436 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
437 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
438 |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
447 |
self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
448 |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.") |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.") |
449 |
def test_Rotatation_y_330(self): |
def test_Rotatation_y_330(self): |
450 |
t=Rotatation(point1=[0.,1.,0.],point0=[0.,2.,0.],angle=330*DEG) |
t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=330*DEG) |
451 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
452 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
453 |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
462 |
self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |
463 |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.") |
self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.") |
464 |
def test_Rotatation_z_90_0(self): |
def test_Rotatation_z_90_0(self): |
465 |
t=Rotatation(point1=[0.,0.,1.],angle=90*DEG) |
t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=90*DEG) |
466 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
467 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
468 |
self.failUnless(self.__distance(s0,numarray.array([0.,1,0.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([0.,1,0.]))<self.ABS_TOL,"s0 is wrong.") |
473 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
474 |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
475 |
def test_Rotatation_z_30_0(self): |
def test_Rotatation_z_30_0(self): |
476 |
t=Rotatation(point1=[0.,0.,1.],angle=30*DEG) |
t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=30*DEG) |
477 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
478 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
479 |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
488 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
489 |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
490 |
def test_Rotatation_z_330_0(self): |
def test_Rotatation_z_330_0(self): |
491 |
t=Rotatation(point1=[0.,0.,1.],angle=330*DEG) |
t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=330*DEG) |
492 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
493 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
494 |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
500 |
self.failUnless(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.") |
self.failUnless(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.") |
501 |
self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.") |
self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.") |
502 |
def test_Rotatation_z_90(self): |
def test_Rotatation_z_90(self): |
503 |
t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=90*DEG) |
t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=90*DEG) |
504 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
505 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
506 |
self.failUnless(self.__distance(s0,numarray.array([0.,-1,0.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([0.,-1,0.]))<self.ABS_TOL,"s0 is wrong.") |
511 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
512 |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
513 |
def test_Rotatation_z_30(self): |
def test_Rotatation_z_30(self): |
514 |
t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=30*DEG) |
t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=30*DEG) |
515 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
516 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
517 |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
526 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
527 |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
528 |
def test_Rotatation_z_330(self): |
def test_Rotatation_z_330(self): |
529 |
t=Rotatation(point1=[0.,0.,1.],point0=[0.,0.,2.],angle=330*DEG) |
t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=330*DEG) |
530 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
531 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
532 |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |
541 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
542 |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
543 |
def test_Rotatation_x_90_1(self): |
def test_Rotatation_x_90_1(self): |
544 |
t=Rotatation(point0=[0.,0.,1.],point1=[1.,0.,1.],angle=90*DEG) |
t=Rotatation(point=[0.,0.,1.],axis=[1.,0.,0.],angle=90*DEG) |
545 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
546 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
547 |
self.failUnless(self.__distance(s0,numarray.array([1.,1,1.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([1.,1,1.]))<self.ABS_TOL,"s0 is wrong.") |
552 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
553 |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
554 |
def test_Rotatation_y_90_1(self): |
def test_Rotatation_y_90_1(self): |
555 |
t=Rotatation(point0=[1.,0.,0.],point1=[1.,1.,0.],angle=90*DEG) |
t=Rotatation(point=[1.,0.,0.],axis=[0.,1.,0.],angle=90*DEG) |
556 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
557 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
558 |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.") |
563 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
564 |
self.failUnless(self.__distance(s2,numarray.array([2.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([2.,0,1.]))<self.ABS_TOL,"s2 is wrong.") |
565 |
def test_Rotatation_z_90_1(self): |
def test_Rotatation_z_90_1(self): |
566 |
t=Rotatation(point0=[0.,1.,0.],point1=[0.,1.,1.],angle=90*DEG) |
t=Rotatation(point=[0.,1.,0.],axis=[0.,0.,1.],angle=90*DEG) |
567 |
s0=t([1,0,0]) |
s0=t([1,0,0]) |
568 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
569 |
self.failUnless(self.__distance(s0,numarray.array([1.,2,0.]))<self.ABS_TOL,"s0 is wrong.") |
self.failUnless(self.__distance(s0,numarray.array([1.,2,0.]))<self.ABS_TOL,"s0 is wrong.") |
574 |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |
575 |
self.failUnless(self.__distance(s2,numarray.array([1.,1,1.]))<self.ABS_TOL,"s2 is wrong.") |
self.failUnless(self.__distance(s2,numarray.array([1.,1,1.]))<self.ABS_TOL,"s2 is wrong.") |
576 |
def test_Rotatation_diag_90_0(self): |
def test_Rotatation_diag_90_0(self): |
577 |
t=Rotatation(point1=[1.,1.,1.],angle=90*DEG) |
t=Rotatation(axis=[1.,1.,1.],angle=90*DEG) |
578 |
s0=t([1,-1,0]) |
s0=t([1,-1,0]) |
579 |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |
580 |
self.failUnless(abs(numarray.dot(s0,s0)-2.)<self.ABS_TOL,"s0 length is wrong.") |
self.failUnless(abs(numarray.dot(s0,s0)-2.)<self.ABS_TOL,"s0 length is wrong.") |
605 |
self.failUnless(isinstance(id,int),"id number is not an integer") |
self.failUnless(isinstance(id,int),"id number is not an integer") |
606 |
self.failUnless(not id==Primitive().getID(),"id number is not unique") |
self.failUnless(not id==Primitive().getID(),"id number is not unique") |
607 |
|
|
608 |
self.failUnless(not p.isPoint(),"generic primitive is not a point.") |
hs=p.getPrimitives() |
|
self.failUnless(not p.isCurve(),"generic primitive is not a curve.") |
|
|
self.failUnless(not p.isCurveLoop(),"generic primitive is not a curve loop.") |
|
|
self.failUnless(not p.isSurface(),"generic primitive is not a surface.") |
|
|
self.failUnless(not p.isSurfaceLoop(),"generic primitive is not a surface loop.") |
|
|
|
|
|
hs=p.getHistory() |
|
|
self.failUnless(isinstance(hs,set),"history must be a set") |
|
609 |
self.failUnless(len(hs)==0,"history should be empty.") |
self.failUnless(len(hs)==0,"history should be empty.") |
610 |
|
|
611 |
ps=p.getPoints() |
ps=p.getConstructionPoints() |
|
self.failUnless(isinstance(ps,set),"point set must be a set") |
|
612 |
self.failUnless(len(ps)==0,"point set should be empty.") |
self.failUnless(len(ps)==0,"point set should be empty.") |
613 |
|
|
|
p.setLocalScale(1.23) |
|
|
|
|
614 |
def test_point(self): |
def test_point(self): |
615 |
p=Point(1.,2.,3.,local_scale=9.) |
p=Point(1.,2.,3.,local_scale=9.) |
616 |
|
|
619 |
self.failUnless(not id==Primitive().getID(),"id number is not unique") |
self.failUnless(not id==Primitive().getID(),"id number is not unique") |
620 |
|
|
621 |
# check history: |
# check history: |
622 |
hs=p.getHistory() |
hs=p.getPrimitives() |
|
self.failUnless(isinstance(hs,set),"history must be a set") |
|
623 |
self.failUnless(len(hs)==1,"history must have length 1.") |
self.failUnless(len(hs)==1,"history must have length 1.") |
624 |
self.failUnless(p in hs,"history must contain point p") |
self.failUnless(p in hs,"history must contain point p") |
625 |
|
|
626 |
# check incolved points: |
# check incolved points: |
627 |
ps=p.getPoints() |
ps=p.getConstructionPoints() |
|
self.failUnless(isinstance(ps,set),"point set must be a set") |
|
628 |
self.failUnless(len(ps)==1,"point set must have length 1.") |
self.failUnless(len(ps)==1,"point set must have length 1.") |
629 |
self.failUnless(p in ps,"point set must contain point p") |
self.failUnless(p in ps,"point set must contain point p") |
630 |
|
|
645 |
|
|
646 |
# check for a colocated point: |
# check for a colocated point: |
647 |
self.failUnless(p.isColocated(Point(-1.,-2.,-3.)),"colocation not detected.") |
self.failUnless(p.isColocated(Point(-1.,-2.,-3.)),"colocation not detected.") |
648 |
self.failUnless(p.isColocated(numarray.array([-1.,-2.,-3.])),"colocation with numarray representation not detected.") |
self.failUnless(not p.isColocated(numarray.array([-1.,-2.,-3.])),"colocation with numarray representation not detected.") |
649 |
self.failUnless(not p.isColocated(numarray.array([1.,-2.,-3.])),"false colocation detected.") |
self.failUnless(not p.isColocated(Point(1.,-2.,-3.)),"false colocation detected.") |
650 |
self.failUnless(not p.isColocated(numarray.array([0.,0.,0.])),"false colocation with origin detected.") |
self.failUnless(not p.isColocated(Point(0.,0.,0.)),"false colocation with origin detected.") |
651 |
|
|
652 |
# check for local length scale |
# check for local length scale |
653 |
l=p.getLocalScale() |
l=p.getLocalScale() |
743 |
code=p.getGmshCommand(2.) |
code=p.getGmshCommand(2.) |
744 |
self.failUnless("Point(1) = {8.0 , 16.0, 24.0 , 6.0 };"== code, "wrong gmsh code") |
self.failUnless("Point(1) = {8.0 , 16.0, 24.0 , 6.0 };"== code, "wrong gmsh code") |
745 |
|
|
746 |
|
def test_spline(self): |
747 |
|
p0=Point(0,0,0,0.1) |
748 |
|
p1=Point(1,1,1,0.2) |
749 |
|
p2=Point(2,2,2,0.3) |
750 |
|
p3=Point(3,3,3,0.4) |
751 |
|
p4=Point(1,2,3) |
752 |
|
|
753 |
|
self.failUnlessRaises(TypeError,Spline,p0) |
754 |
|
c=Spline(p0,p1,p2,p3) |
755 |
|
|
756 |
|
self.failUnless(len(c) == 4, "wrong spline curve length") |
757 |
|
self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") |
758 |
|
self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve") |
759 |
|
|
760 |
|
co=c.getControlPoints() |
761 |
|
self.failUnless(co[0]==p0, "1st control point is wrong.") |
762 |
|
self.failUnless(co[1]==p1, "2nd control point is wrong.") |
763 |
|
self.failUnless(co[2]==p2, "3rd control point is wrong.") |
764 |
|
self.failUnless(co[3]==p3, "4th control point is wrong.") |
765 |
|
|
766 |
|
c.setLocalScale(3.) |
767 |
|
co=c.getControlPoints() |
768 |
|
self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |
769 |
|
self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |
770 |
|
self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") |
771 |
|
self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") |
772 |
|
|
773 |
|
code=c.getGmshCommand() |
774 |
|
self.failUnless(code == "Spline(6) = {1, 2, 3, 4};", "gmsh command wrong.") |
775 |
|
|
776 |
|
h=c.getPrimitives() |
777 |
|
self.failUnless(len(h) == 5, "number of primitives in history is wrong.") |
778 |
|
self.failUnless(p0 in h, "missing p0 in history.") |
779 |
|
self.failUnless(p1 in h, "missing p1 in history.") |
780 |
|
self.failUnless(p2 in h, "missing p2 in history.") |
781 |
|
self.failUnless(p3 in h, "missing p3 in history.") |
782 |
|
self.failUnless(c in h, "missing spline curve in history.") |
783 |
|
|
784 |
|
cp=c.copy() |
785 |
|
self.failUnless(not cp == c, "copy returns same spline curve.") |
786 |
|
cpcp=cp.getControlPoints() |
787 |
|
self.failUnless(p0.isColocated(cpcp[0]),"1st point of copy and source are not collocated.") |
788 |
|
self.failUnless(p1.isColocated(cpcp[1]),"2nd point of copy and source are not collocated.") |
789 |
|
self.failUnless(p2.isColocated(cpcp[2]),"3rd point of copy and source are not collocated.") |
790 |
|
self.failUnless(p3.isColocated(cpcp[3]),"4th point of copy and source are not collocated.") |
791 |
|
self.failUnless(c.isColocated(cp),"spline curve is not collocated with its copy.") |
792 |
|
self.failUnless(not c.isColocated(p0),"spline curve is collocated with point.") |
793 |
|
self.failUnless(not c.isColocated(Spline(p0,p1)),"spline curve is collocated with shorter spline curve.") |
794 |
|
self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") |
795 |
|
self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"spline curve is collocated with defomed spline curve.") |
796 |
|
|
797 |
|
c.modifyBy(Dilation(-1.)) |
798 |
|
self.failUnless(c.isColocated(Spline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.") |
799 |
|
self.failUnless(p0.isColocated(Point(0,0,0)),"1st point has not been modified through Dilation.") |
800 |
|
self.failUnless(p1.isColocated(Point(-1,-1,-1)),"2nd point has not been modified through Dilation.") |
801 |
|
self.failUnless(p2.isColocated(Point(-2,-2,-2)),"3rd point has not been modified through Dilation.") |
802 |
|
self.failUnless(p3.isColocated(Point(-3,-3,-3)),"4th point has not been modified through Dilation.") |
803 |
|
cp=c.getControlPoints() |
804 |
|
self.failUnless(p0 == cp[0],"1st new point after Dilation.") |
805 |
|
self.failUnless(p1 == cp[1],"2nd new point after Dilation.") |
806 |
|
self.failUnless(p2 == cp[2],"3rd new point after Dilation.") |
807 |
|
self.failUnless(p3 == cp[3],"4th new point after Dilation.") |
808 |
|
|
809 |
|
dc=c.apply(Dilation(-1.)) |
810 |
|
self.failUnless(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") |
811 |
|
dccp=dc.getControlPoints() |
812 |
|
self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |
813 |
|
self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |
814 |
|
self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.") |
815 |
|
self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.") |
816 |
|
|
817 |
|
|
818 |
|
def test_BezierCurve(self): |
819 |
|
p0=Point(0,0,0,0.1) |
820 |
|
p1=Point(1,1,1,0.2) |
821 |
|
p2=Point(2,2,2,0.3) |
822 |
|
p3=Point(3,3,3,0.4) |
823 |
|
p4=Point(1,2,3) |
824 |
|
|
825 |
|
self.failUnlessRaises(TypeError,BezierCurve,p0) |
826 |
|
c=BezierCurve(p0,p1,p2,p3) |
827 |
|
|
828 |
|
self.failUnless(len(c) == 4, "wrong spline curve length") |
829 |
|
self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") |
830 |
|
self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve") |
831 |
|
|
832 |
|
co=c.getControlPoints() |
833 |
|
self.failUnless(co[0]==p0, "1st control point is wrong.") |
834 |
|
self.failUnless(co[1]==p1, "2nd control point is wrong.") |
835 |
|
self.failUnless(co[2]==p2, "3rd control point is wrong.") |
836 |
|
self.failUnless(co[3]==p3, "4th control point is wrong.") |
837 |
|
|
838 |
|
c.setLocalScale(3.) |
839 |
|
co=c.getControlPoints() |
840 |
|
self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |
841 |
|
self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |
842 |
|
self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") |
843 |
|
self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") |
844 |
|
|
845 |
|
code=c.getGmshCommand() |
846 |
|
self.failUnless(code == "Bezier(6) = {1, 2, 3, 4};", "gmsh command wrong.") |
847 |
|
|
848 |
|
h=c.getPrimitives() |
849 |
|
self.failUnless(len(h) == 5, "number of primitives in history is wrong.") |
850 |
|
self.failUnless(p0 in h, "missing p0 in history.") |
851 |
|
self.failUnless(p1 in h, "missing p1 in history.") |
852 |
|
self.failUnless(p2 in h, "missing p2 in history.") |
853 |
|
self.failUnless(p3 in h, "missing p3 in history.") |
854 |
|
self.failUnless(c in h, "missing spline curve in history.") |
855 |
|
|
856 |
|
cp=c.copy() |
857 |
|
self.failUnless(not cp == c, "copy returns same spline curve.") |
858 |
|
cpcp=cp.getControlPoints() |
859 |
|
self.failUnless(p0.isColocated(cpcp[0]),"1st point of copy and source are not collocated.") |
860 |
|
self.failUnless(p1.isColocated(cpcp[1]),"2nd point of copy and source are not collocated.") |
861 |
|
self.failUnless(p2.isColocated(cpcp[2]),"3rd point of copy and source are not collocated.") |
862 |
|
self.failUnless(p3.isColocated(cpcp[3]),"4th point of copy and source are not collocated.") |
863 |
|
self.failUnless(c.isColocated(cp),"spline curve is not collocated with its copy.") |
864 |
|
self.failUnless(not c.isColocated(p0),"spline curve is collocated with point.") |
865 |
|
self.failUnless(not c.isColocated(BezierCurve(p0,p1)),"spline curve is collocated with shorter spline curve.") |
866 |
|
self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") |
867 |
|
self.failUnless(not c.isColocated(BezierCurve(p0,p1,p4,p3)),"spline curve is collocated with defomed spline curve.") |
868 |
|
|
869 |
|
c.modifyBy(Dilation(-1.)) |
870 |
|
self.failUnless(c.isColocated(BezierCurve(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.") |
871 |
|
self.failUnless(p0.isColocated(Point(0,0,0)),"1st point has not been modified through Dilation.") |
872 |
|
self.failUnless(p1.isColocated(Point(-1,-1,-1)),"2nd point has not been modified through Dilation.") |
873 |
|
self.failUnless(p2.isColocated(Point(-2,-2,-2)),"3rd point has not been modified through Dilation.") |
874 |
|
self.failUnless(p3.isColocated(Point(-3,-3,-3)),"4th point has not been modified through Dilation.") |
875 |
|
cp=c.getControlPoints() |
876 |
|
self.failUnless(p0 == cp[0],"1st new point after Dilation.") |
877 |
|
self.failUnless(p1 == cp[1],"2nd new point after Dilation.") |
878 |
|
self.failUnless(p2 == cp[2],"3rd new point after Dilation.") |
879 |
|
self.failUnless(p3 == cp[3],"4th new point after Dilation.") |
880 |
|
|
881 |
|
dc=c.apply(Dilation(-1.)) |
882 |
|
self.failUnless(dc.isColocated(BezierCurve(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") |
883 |
|
dccp=dc.getControlPoints() |
884 |
|
self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |
885 |
|
self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |
886 |
|
self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.") |
887 |
|
self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.") |
888 |
|
|
889 |
|
def test_BSpline(self): |
890 |
|
p0=Point(0,0,0,0.1) |
891 |
|
p1=Point(1,1,1,0.2) |
892 |
|
p2=Point(2,2,2,0.3) |
893 |
|
p3=Point(3,3,3,0.4) |
894 |
|
p4=Point(1,2,3) |
895 |
|
|
896 |
|
self.failUnlessRaises(TypeError,BSpline,p0) |
897 |
|
c=BSpline(p0,p1,p2,p3) |
898 |
|
|
899 |
|
self.failUnless(len(c) == 4, "wrong spline curve length") |
900 |
|
self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") |
901 |
|
self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve") |
902 |
|
|
903 |
|
co=c.getControlPoints() |
904 |
|
self.failUnless(co[0]==p0, "1st control point is wrong.") |
905 |
|
self.failUnless(co[1]==p1, "2nd control point is wrong.") |
906 |
|
self.failUnless(co[2]==p2, "3rd control point is wrong.") |
907 |
|
self.failUnless(co[3]==p3, "4th control point is wrong.") |
908 |
|
|
909 |
|
c.setLocalScale(3.) |
910 |
|
co=c.getControlPoints() |
911 |
|
self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |
912 |
|
self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |
913 |
|
self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") |
914 |
|
self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") |
915 |
|
|
916 |
|
code=c.getGmshCommand() |
917 |
|
self.failUnless(code == "BSpline(6) = {1, 2, 3, 4};", "gmsh command wrong.") |
918 |
|
|
919 |
|
h=c.getPrimitives() |
920 |
|
self.failUnless(len(h) == 5, "number of primitives in history is wrong.") |
921 |
|
self.failUnless(p0 in h, "missing p0 in history.") |
922 |
|
self.failUnless(p1 in h, "missing p1 in history.") |
923 |
|
self.failUnless(p2 in h, "missing p2 in history.") |
924 |
|
self.failUnless(p3 in h, "missing p3 in history.") |
925 |
|
self.failUnless(c in h, "missing spline curve in history.") |
926 |
|
|
927 |
|
cp=c.copy() |
928 |
|
self.failUnless(not cp == c, "copy returns same spline curve.") |
929 |
|
cpcp=cp.getControlPoints() |
930 |
|
self.failUnless(p0.isColocated(cpcp[0]),"1st point of copy and source are not collocated.") |
931 |
|
self.failUnless(p1.isColocated(cpcp[1]),"2nd point of copy and source are not collocated.") |
932 |
|
self.failUnless(p2.isColocated(cpcp[2]),"3rd point of copy and source are not collocated.") |
933 |
|
self.failUnless(p3.isColocated(cpcp[3]),"4th point of copy and source are not collocated.") |
934 |
|
self.failUnless(c.isColocated(cp),"spline curve is not collocated with its copy.") |
935 |
|
self.failUnless(not c.isColocated(p0),"spline curve is collocated with point.") |
936 |
|
self.failUnless(not c.isColocated(BSpline(p0,p1)),"spline curve is collocated with shorter spline curve.") |
937 |
|
self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") |
938 |
|
self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline curve is collocated with defomed spline curve.") |
939 |
|
|
940 |
|
c.modifyBy(Dilation(-1.)) |
941 |
|
self.failUnless(c.isColocated(BSpline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.") |
942 |
|
self.failUnless(p0.isColocated(Point(0,0,0)),"1st point has not been modified through Dilation.") |
943 |
|
self.failUnless(p1.isColocated(Point(-1,-1,-1)),"2nd point has not been modified through Dilation.") |
944 |
|
self.failUnless(p2.isColocated(Point(-2,-2,-2)),"3rd point has not been modified through Dilation.") |
945 |
|
self.failUnless(p3.isColocated(Point(-3,-3,-3)),"4th point has not been modified through Dilation.") |
946 |
|
cp=c.getControlPoints() |
947 |
|
self.failUnless(p0 == cp[0],"1st new point after Dilation.") |
948 |
|
self.failUnless(p1 == cp[1],"2nd new point after Dilation.") |
949 |
|
self.failUnless(p2 == cp[2],"3rd new point after Dilation.") |
950 |
|
self.failUnless(p3 == cp[3],"4th new point after Dilation.") |
951 |
|
|
952 |
|
dc=c.apply(Dilation(-1.)) |
953 |
|
self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") |
954 |
|
dccp=dc.getControlPoints() |
955 |
|
self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |
956 |
|
self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |
957 |
|
self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.") |
958 |
|
self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.") |
959 |
|
|
960 |
|
def test_LineSegment(self): |
961 |
|
p0=Point(0,0,0,0.1) |
962 |
|
p1=Point(1,1,1,0.2) |
963 |
|
p4=Point(1,2,3) |
964 |
|
|
965 |
|
self.failUnlessRaises(TypeError,Line,p0) |
966 |
|
self.failUnlessRaises(TypeError,Line,p0,p1,p4) |
967 |
|
|
968 |
|
c=Line(p0,p1) |
969 |
|
|
970 |
|
self.failUnless(len(c) == 2, "wrong spline curve length") |
971 |
|
self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") |
972 |
|
self.failUnless(c.getEndPoint()==p1, "wrong end point of spline curve") |
973 |
|
|
974 |
|
co=c.getControlPoints() |
975 |
|
self.failUnless(co[0]==p0, "1st control point is wrong.") |
976 |
|
self.failUnless(co[1]==p1, "2nd control point is wrong.") |
977 |
|
|
978 |
|
c.setLocalScale(3.) |
979 |
|
co=c.getControlPoints() |
980 |
|
self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |
981 |
|
self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |
982 |
|
|
983 |
|
code=c.getGmshCommand() |
984 |
|
self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.") |
985 |
|
|
986 |
|
h=c.getPrimitives() |
987 |
|
self.failUnless(len(h) == 3, "number of primitives in history is wrong.") |
988 |
|
self.failUnless(p0 in h, "missing p0 in history.") |
989 |
|
self.failUnless(p1 in h, "missing p1 in history.") |
990 |
|
self.failUnless(c in h, "missing spline curve in history.") |
991 |
|
|
992 |
|
cp=c.copy() |
993 |
|
self.failUnless(not cp == c, "copy returns same spline curve.") |
994 |
|
cpcp=cp.getControlPoints() |
995 |
|
self.failUnless(p0.isColocated(cpcp[0]),"1st point of copy and source are not collocated.") |
996 |
|
self.failUnless(p1.isColocated(cpcp[1]),"2nd point of copy and source are not collocated.") |
997 |
|
self.failUnless(c.isColocated(cp),"spline curve is not collocated with its copy.") |
998 |
|
self.failUnless(not c.isColocated(p0),"spline curve is collocated with point.") |
999 |
|
self.failUnless(not c.isColocated(Curve(p0,p1)),"spline curve is identified with curve.") |
1000 |
|
self.failUnless(not c.isColocated(Line(p0,p4)),"spline curve is collocated with defomed spline curve.") |
1001 |
|
|
1002 |
|
c.modifyBy(Dilation(-1.)) |
1003 |
|
self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.") |
1004 |
|
self.failUnless(p0.isColocated(Point(0,0,0)),"1st point has not been modified through Dilation.") |
1005 |
|
self.failUnless(p1.isColocated(Point(-1,-1,-1)),"2nd point has not been modified through Dilation.") |
1006 |
|
cp=c.getControlPoints() |
1007 |
|
self.failUnless(p0 == cp[0],"1st new point after Dilation.") |
1008 |
|
self.failUnless(p1 == cp[1],"2nd new point after Dilation.") |
1009 |
|
|
1010 |
|
dc=c.apply(Dilation(-1.)) |
1011 |
|
self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.") |
1012 |
|
dccp=dc.getControlPoints() |
1013 |
|
self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |
1014 |
|
self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |
1015 |
|
|
1016 |
|
|
1017 |
if __name__ == '__main__': |
if __name__ == '__main__': |
1018 |
suite = unittest.TestSuite() |
suite = unittest.TestSuite() |