Ejemplo n.º 1
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)
Ejemplo n.º 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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
def test_translation_from_matrix():
    # doesn't seem to have a Cython backend
    v0 = np.random.random(3) - 0.5
    v1 = t.translation_from_matrix(t.translation_matrix(v0))
    assert_allclose(v0, v1)
Ejemplo n.º 6
0
 def test_decompose_matrix_1(self):
     T0 = t.translation_matrix((1, 2, 3))
     scale, shear, angles, trans, persp = t.decompose_matrix(T0)
     T1 = t.translation_matrix(trans)
     assert_allclose(T0, T1)
Ejemplo n.º 7
0
def test_translation_from_matrix():
    # doesn't seem to have a Cython backend
    v0 = np.random.random(3) - 0.5
    v1 = t.translation_from_matrix(t.translation_matrix(v0))
    assert_allclose(v0, v1)
Ejemplo n.º 8
0
 def test_decompose_matrix_1(self):
     T0 = t.translation_matrix((1, 2, 3))
     scale, shear, angles, trans, persp = t.decompose_matrix(T0)
     T1 = t.translation_matrix(trans)
     assert_allclose(T0, T1)
Ejemplo n.º 9
0
def test_translation_from_matrix():
    # doesn't seem to have a Cython backend
    v0 = np.array([0.2, 0.2, 0.2])
    v1 = t.translation_from_matrix(t.translation_matrix(v0))
    assert_allclose(v0, v1)
Ejemplo n.º 10
0
def test_translation_from_matrix():
    # doesn't seem to have a Cython backend
    v0 = np.array([0.2, 0.2, 0.2])
    v1 = t.translation_from_matrix(t.translation_matrix(v0))
    assert_allclose(v0, v1)