예제 #1
0
def test_scale_from_matrix():
    factor = random.random() * 10 - 5
    origin = np.random.random(3) - 0.5
    direct = np.random.random(3) - 0.5
    S0 = t.scale_matrix(factor, origin)
    factor, origin, direction = t.scale_from_matrix(S0)
    S1 = t.scale_matrix(factor, origin, direction)
    assert_equal(t.is_same_transform(S0, S1), True)
    S0 = t.scale_matrix(factor, origin, direct)
    factor, origin, direction = t.scale_from_matrix(S0)
    S1 = t.scale_matrix(factor, origin, direction)
    assert_equal(t.is_same_transform(S0, S1), True)
예제 #2
0
def test_scale_from_matrix():
    factor = random.random() * 10 - 5
    origin = np.random.random(3) - 0.5
    direct = np.random.random(3) - 0.5
    S0 = t.scale_matrix(factor, origin)
    factor, origin, direction = t.scale_from_matrix(S0)
    S1 = t.scale_matrix(factor, origin, direction)
    assert_equal(t.is_same_transform(S0, S1), True)
    S0 = t.scale_matrix(factor, origin, direct)
    factor, origin, direction = t.scale_from_matrix(S0)
    S1 = t.scale_matrix(factor, origin, direction)
    assert_equal(t.is_same_transform(S0, S1), True)
예제 #3
0
def test_scale_from_matrix():
    factor = 7
    origin = np.array([0.2, 0.2, 0.2])  # arbitrary values
    direct = np.array([0.4, 0.4, 0.4])
    S0 = t.scale_matrix(factor, origin)
    factor, origin, direction = t.scale_from_matrix(S0)
    S1 = t.scale_matrix(factor, origin, direction)
    assert_equal(t.is_same_transform(S0, S1), True)
    S0 = t.scale_matrix(factor, origin, direct)
    factor, origin, direction = t.scale_from_matrix(S0)
    S1 = t.scale_matrix(factor, origin, direction)
    assert_equal(t.is_same_transform(S0, S1), True)
예제 #4
0
def test_scale_from_matrix():
    factor = 7
    origin = np.array([0.2, 0.2, 0.2])  # arbitrary values
    direct = np.array([0.4, 0.4, 0.4])
    S0 = t.scale_matrix(factor, origin)
    factor, origin, direction = t.scale_from_matrix(S0)
    S1 = t.scale_matrix(factor, origin, direction)
    assert_equal(t.is_same_transform(S0, S1), True)
    S0 = t.scale_matrix(factor, origin, direct)
    factor, origin, direction = t.scale_from_matrix(S0)
    S1 = t.scale_matrix(factor, origin, direction)
    assert_equal(t.is_same_transform(S0, S1), True)
예제 #5
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)
예제 #6
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)
예제 #7
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)
예제 #8
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)
예제 #9
0
 def test_decompose_matrix_2(self):
     S = t.scale_matrix(0.123)
     scale, shear, angles, trans, persp = t.decompose_matrix(S)
     assert_equal(scale[0], 0.123)
예제 #10
0
 def test_decompose_matrix_2(self):
     S = t.scale_matrix(0.123)
     scale, shear, angles, trans, persp = t.decompose_matrix(S)
     assert_equal(scale[0], 0.123)