Ejemplo n.º 1
0
    def test_coordinate_conversion(self):
        x = rd.random((self.n, 3))
        r1, alpha1, gamma1 = math.cart2inter(x)
        y = math.inter2cart(r1, alpha1, gamma1)
        r2, alpha2, gamma2 = math.cart2inter(y)
        z = math.inter2cart(r2, alpha2, gamma2)

        self.assertTrue(np.allclose(r1, r2))
        self.assertTrue(np.allclose(alpha1, alpha2))
        self.assertTrue(np.allclose(gamma1, gamma2))
        self.assertTrue(np.allclose(x, math.kabsch(x, z)[0]))
Ejemplo n.º 2
0
 def test_random_transformation(self):
     x = rd.random((self.n, 3))
     theta = rd.random(1)
     random_rotation = np.array([[1, 0, 0],
                                [0, np.cos(theta), -np.sin(theta)],
                                [0, np.sin(theta), np.cos(theta)]])
     random_traslation = rd.random(3)
     y = np.dot(x, random_rotation.T) + np.tile(
         random_traslation, (self.n, 1))
     z, restored_rotation = math.kabsch(x, y)
     self.assertTrue(np.allclose(x, z))
     self.assertTrue(np.allclose(restored_rotation,
                                 random_rotation))
Ejemplo n.º 3
0
 def test_different_dimentions(self):
     x = np.ones((3, 2))
     y = np.ones((3, 4))
     with self.assertRaises(exception.MathError):
         math.kabsch(x, y)
Ejemplo n.º 4
0
 def test_reflected_matrix(self):
     x = rd.random((self.n, 3))
     y = np.vstack((x[:, 1], x[:, 0], x[:, 2])).T
     math.kabsch(x, y)
Ejemplo n.º 5
0
 def test_same_matrix(self):
     x = rd.random((self.n, 3))
     z, q = math.kabsch(x, x)
     self.assertTrue(np.allclose(x, z))
     self.assertTrue(np.allclose(q, np.eye(3)))