コード例 #1
0
    def test_inverse_matrix(self):
        M0 = t.random_rotation_matrix()
        M1 = self.f(M0.T)
        assert_allclose(M1, np.linalg.inv(M0.T))

        for size in range(1, 7):
            yield self._check_inverse, size
コード例 #2
0
    def test_superimposition_matrix(self):
        v0 = np.random.rand(3, 10)
        M = self.f(v0, v0)
        assert_allclose(M, np.identity(4), atol=_ATOL)

        R = t.random_rotation_matrix(np.random.random(3))
        v0 = ((1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 1))
        v1 = np.dot(R, v0)
        M = self.f(v0, v1)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        v0 = (np.random.rand(4, 100) - 0.5) * 20.0
        v0[3] = 1.0
        v1 = np.dot(R, v0)
        M = self.f(v0, v1)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        S = t.scale_matrix(random.random())
        T = t.translation_matrix(np.random.random(3) - 0.5)
        M = t.concatenate_matrices(T, R, S)
        v1 = np.dot(M, v0)
        v0[:3] += np.random.normal(0.0, 1e-9, 300).reshape(3, -1)
        M = self.f(v0, v1, scaling=True)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        M = self.f(v0, v1, scaling=True, usesvd=False)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        v = np.empty((4, 100, 3), dtype=np.float64)
        v[:, :, 0] = v0
        M = self.f(v0, v1, scaling=True, usesvd=False)
        assert_allclose(v1, np.dot(M, v[:, :, 0]), atol=_ATOL)
コード例 #3
0
    def test_superimposition_matrix(self):
        v0 = np.random.rand(3, 10)
        M = self.f(v0, v0)
        assert_allclose(M, np.identity(4), atol=_ATOL)

        R = t.random_rotation_matrix(np.random.random(3))
        v0 = ((1,0,0), (0,1,0), (0,0,1), (1,1,1))
        v1 = np.dot(R, v0)
        M = self.f(v0, v1)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        v0 = (np.random.rand(4, 100) - 0.5) * 20.0
        v0[3] = 1.0
        v1 = np.dot(R, v0)
        M = self.f(v0, v1)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        S = t.scale_matrix(random.random())
        T = t.translation_matrix(np.random.random(3)-0.5)
        M = t.concatenate_matrices(T, R, S)
        v1 = np.dot(M, v0)
        v0[:3] += np.random.normal(0.0, 1e-9, 300).reshape(3, -1)
        M = self.f(v0, v1, scaling=True)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        M = self.f(v0, v1, scaling=True, usesvd=False)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        v = np.empty((4, 100, 3), dtype=np.float64)
        v[:, :, 0] = v0
        M = self.f(v0, v1, scaling=True, usesvd=False)
        assert_allclose(v1, np.dot(M, v[:, :, 0]), atol=_ATOL)
コード例 #4
0
    def test_superimposition_matrix(self):
        v0 = np.sin(np.linspace(0, 0.99, 30)).reshape(3,
                                                      10)  # arbitrary values
        M = self.f(v0, v0)
        assert_allclose(M, np.identity(4), atol=_ATOL)

        R = t.random_rotation_matrix(np.array([0.3, 0.4, 0.5]))
        v0 = ((1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 1))
        v1 = np.dot(R, v0)
        M = self.f(v0, v1)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        v0 = np.sin(np.linspace(-1, 1, 400)).reshape(4, 100)
        v0[3] = 1.0
        v1 = np.dot(R, v0)
        M = self.f(v0, v1)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        S = t.scale_matrix(0.45)
        T = t.translation_matrix(np.array([0.2, 0.2, 0.2]) - 0.5)
        M = t.concatenate_matrices(T, R, S)
        v1 = np.dot(M, v0)
        v0[:3] += np.sin(np.linspace(0.0, 1e-9, 300)).reshape(3, -1)
        M = self.f(v0, v1, scaling=True)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        M = self.f(v0, v1, scaling=True, usesvd=False)
        assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

        v = np.empty((4, 100, 3), dtype=np.float64)
        v[:, :, 0] = v0
        M = self.f(v0, v1, scaling=True, usesvd=False)
        assert_allclose(v1, np.dot(M, v[:, :, 0]), atol=_ATOL)
コード例 #5
0
def test_superimposition_matrix(f):
    v0 = np.sin(np.linspace(0, 0.99, 30)).reshape(3, 10)  # arbitrary values
    M = f(v0, v0)
    assert_allclose(M, np.identity(4), atol=_ATOL)

    R = t.random_rotation_matrix(np.array([0.3, 0.4, 0.5]))
    v0 = ((1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 1))
    v1 = np.dot(R, v0)
    M = f(v0, v1)
    assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

    v0 = np.sin(np.linspace(-1, 1, 400)).reshape(4, 100)
    v0[3] = 1.0
    v1 = np.dot(R, v0)
    M = f(v0, v1)
    assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

    S = t.scale_matrix(0.45)
    T = t.translation_matrix(np.array([0.2, 0.2, 0.2]) - 0.5)
    M = t.concatenate_matrices(T, R, S)
    v1 = np.dot(M, v0)
    v0[:3] += np.sin(np.linspace(0.0, 1e-9, 300)).reshape(3, -1)
    M = f(v0, v1, scaling=True)
    assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

    M = f(v0, v1, scaling=True, usesvd=False)
    assert_allclose(v1, np.dot(M, v0), atol=_ATOL)

    v = np.empty((4, 100, 3), dtype=np.float64)
    v[:, :, 0] = v0
    M = f(v0, v1, scaling=True, usesvd=False)
    assert_allclose(v1, np.dot(M, v[:, :, 0]), atol=_ATOL)
コード例 #6
0
    def test_inverse_matrix(self):
        M0 = t.random_rotation_matrix()
        M1 = self.f(M0.T)
        assert_allclose(M1, np.linalg.inv(M0.T))

        for size in range(1, 7):
            yield self._check_inverse, size
コード例 #7
0
    def test_inverse_matrix(self):
        M0 = t.random_rotation_matrix()
        M1 = self.f(M0.T)
        assert_allclose(M1, np.linalg.inv(M0.T))

        for size in range(1, 7):
            M0 = np.random.rand(size, size)
            M1 = self.f(M0)
            assert_allclose(M1, np.linalg.inv(M0), err_msg=str(size))
コード例 #8
0
    def test_inverse_matrix(self):
        M0 = t.random_rotation_matrix()
        M1 = self.f(M0.T)
        assert_allclose(M1, np.linalg.inv(M0.T))

        for size in range(1, 7):
            M0 = np.random.rand(size, size)
            M1 = self.f(M0)
            assert_allclose(M1, np.linalg.inv(M0), err_msg=str(size))
コード例 #9
0
 def test_is_same_transform_2(self):
     assert_equal(self.f(t.random_rotation_matrix(), np.identity(4)), False)
コード例 #10
0
 def test_quaternion_from_matrix_6(self):
     R = t.random_rotation_matrix()
     q = self.f(R)
     assert_equal(t.is_same_transform(R, t.quaternion_matrix(q)), True)
コード例 #11
0
 def test_is_same_transform_2(self):
     assert_equal(self.f(t.random_rotation_matrix(), np.identity(4)), False)
コード例 #12
0
 def test_quaternion_from_matrix_6(self):
     R = t.random_rotation_matrix()
     q = self.f(R)
     assert_equal(t.is_same_transform(R, t.quaternion_matrix(q)), True)
コード例 #13
0
 def test_inverse_matrix(self, f):
     M0 = t.random_rotation_matrix()
     M1 = f(M0.T)
     assert_allclose(M1, np.linalg.inv(M0.T))
コード例 #14
0
 def test_inverse_matrix(self, f):
     M0 = t.random_rotation_matrix()
     M1 = f(M0.T)
     assert_allclose(M1, np.linalg.inv(M0.T))