Exemplo n.º 1
0
 def test_rotate(self,default,update,reference_dir,Eulers):
     modified = default.rotate(Rotation.from_Eulers(Eulers,degrees=True))
     tag = f'Eulers_{util.srepr(Eulers,"-")}'
     reference = reference_dir/f'rotate_{tag}.vtr'
     if update: modified.save(reference)
     assert geom_equal(Geom.load(reference),
                       modified)
Exemplo n.º 2
0
 def test_rotate(self,default,update,reference_dir,Eulers):
     modified = copy.deepcopy(default)
     modified.rotate(Rotation.from_Eulers(Eulers,degrees=True))
     tag = 'Eulers={}-{}-{}'.format(*Eulers)
     reference = os.path.join(reference_dir,'rotate_{}.geom'.format(tag))
     if update: modified.to_file(reference)
     assert geom_equal(modified,Geom.from_file(reference))
Exemplo n.º 3
0
 def test_add_primitive_rotation(self,center,inverse,periodic):
     """Rotation should not change result for sphere (except for discretization errors)."""
     g = np.array([32,32,32])
     fill = np.random.randint(10)+2
     eu=np.array([np.random.randint(4),np.random.randint(2),np.random.randint(4)])*.5*np.pi
     G_1 = Geom(np.ones(g,'i'),[1.,1.,1.]).add_primitive(.3,center,1,fill,inverse=inverse,periodic=periodic)
     G_2 = Geom(np.ones(g,'i'),[1.,1.,1.]).add_primitive(.3,center,1,fill,Rotation.from_Eulers(eu),inverse,periodic=periodic)
     assert geom_equal(G_1,G_2)
Exemplo n.º 4
0
 def test_Eulers(self, set_of_rotations, degrees):
     for rot in set_of_rotations:
         m = rot.as_quaternion()
         o = Rotation.from_Eulers(rot.as_Eulers(degrees),
                                  degrees).as_quaternion()
         ok = np.allclose(m, o, atol=atol)
         if np.isclose(rot.as_quaternion()[0], 0.0, atol=atol):
             ok |= np.allclose(m * -1., o, atol=atol)
         assert ok and np.isclose(np.linalg.norm(o),
                                  1.0), f'{m},{o},{rot.as_quaternion()}'
Exemplo n.º 5
0
 def test_Eulers(self, default, degrees):
     for rot in default:
         m = rot.as_quaternion()
         o = Rotation.from_Eulers(rot.as_Eulers(degrees),
                                  degrees).as_quaternion()
         ok = np.allclose(m, o, atol=atol)
         if np.isclose(rot.as_quaternion()[0], 0.0, atol=atol):
             ok = ok or np.allclose(m * -1., o, atol=atol)
         print(m, o, rot.as_quaternion())
         assert ok and np.isclose(np.linalg.norm(o), 1.0)
Exemplo n.º 6
0
 def test_misorientation360(self):
     R_1 = Rotation()
     R_2 = Rotation.from_Eulers([360, 0, 0], degrees=True)
     assert np.allclose(R_1.misorientation(R_2).as_matrix(), np.eye(3))
Exemplo n.º 7
0
 def test_rotate_360deg(self, data):
     phi_1 = np.random.random() * np.pi
     phi_2 = 2 * np.pi - phi_1
     R_1 = Rotation.from_Eulers(np.array([phi_1, 0., 0.]))
     R_2 = Rotation.from_Eulers(np.array([0., 0., phi_2]))
     assert np.allclose(data, R_2 @ (R_1 @ data))
Exemplo n.º 8
0
 def test_disorientation360(self, lattice):
     R_1 = Orientation(Rotation(), lattice)
     R_2 = Orientation(Rotation.from_Eulers([360, 0, 0], degrees=True),
                       lattice)
     assert np.allclose(R_1.disorientation(R_2).as_matrix(), np.eye(3))