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)
Esempio n. 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)
Esempio n. 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)
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)
 def test_rotation_matrix(self):
     R = self.f(np.pi/2.0, [0, 0, 1], [1, 0, 0])
     assert_allclose(np.dot(R, [0, 0, 0, 1]), [ 1., -1.,  0.,  1.])
     angle = (random.random() - 0.5) * (2*np.pi)
     direc = np.random.random(3) - 0.5
     point = np.random.random(3) - 0.5
     R0 = self.f(angle, direc, point)
     R1 = self.f(angle-2*np.pi, direc, point)
     assert_equal(t.is_same_transform(R0, R1), True)
     R0 = self.f(angle, direc, point)
     R1 = self.f(-angle, -direc, point)
     assert_equal(t.is_same_transform(R0, R1), True)
     I = np.identity(4, np.float64)
     assert_allclose(I, self.f(np.pi*2, direc), atol=_ATOL)
     assert_allclose(2., np.trace(self.f(np.pi/2, direc, point)))
def test_rotation_matrix(f):
    R = f(np.pi / 2.0, [0, 0, 1], [1, 0, 0])
    assert_allclose(np.dot(R, [0, 0, 0, 1]), [1., -1., 0., 1.])
    angle = 0.2 * 2 * np.pi  # arbitrary value
    direc = np.array([0.2, 0.2, 0.2])
    point = np.array([0.4, 0.4, 0.4])
    R0 = f(angle, direc, point)
    R1 = f(angle - 2 * np.pi, direc, point)
    assert_equal(t.is_same_transform(R0, R1), True)
    R0 = f(angle, direc, point)
    R1 = f(-angle, -direc, point)
    assert_equal(t.is_same_transform(R0, R1), True)
    I = np.identity(4, np.float64)
    assert_allclose(I, f(np.pi * 2, direc), atol=_ATOL)
    assert_allclose(2., np.trace(f(np.pi / 2, direc, point)))
Esempio n. 7
0
 def test_rotation_matrix(self):
     R = self.f(np.pi / 2.0, [0, 0, 1], [1, 0, 0])
     assert_allclose(np.dot(R, [0, 0, 0, 1]), [1., -1., 0., 1.])
     angle = 0.2 * 2 * np.pi  # arbitrary value
     direc = np.array([0.2, 0.2, 0.2])
     point = np.array([0.4, 0.4, 0.4])
     R0 = self.f(angle, direc, point)
     R1 = self.f(angle - 2 * np.pi, direc, point)
     assert_equal(t.is_same_transform(R0, R1), True)
     R0 = self.f(angle, direc, point)
     R1 = self.f(-angle, -direc, point)
     assert_equal(t.is_same_transform(R0, R1), True)
     I = np.identity(4, np.float64)
     assert_allclose(I, self.f(np.pi * 2, direc), atol=_ATOL)
     assert_allclose(2., np.trace(self.f(np.pi / 2, direc, point)))
Esempio n. 8
0
 def test_rotation_matrix(self):
     R = self.f(np.pi / 2.0, [0, 0, 1], [1, 0, 0])
     assert_allclose(np.dot(R, [0, 0, 0, 1]), [1., -1., 0., 1.])
     angle = (random.random() - 0.5) * (2 * np.pi)
     direc = np.random.random(3) - 0.5
     point = np.random.random(3) - 0.5
     R0 = self.f(angle, direc, point)
     R1 = self.f(angle - 2 * np.pi, direc, point)
     assert_equal(t.is_same_transform(R0, R1), True)
     R0 = self.f(angle, direc, point)
     R1 = self.f(-angle, -direc, point)
     assert_equal(t.is_same_transform(R0, R1), True)
     I = np.identity(4, np.float64)
     assert_allclose(I, self.f(np.pi * 2, direc), atol=_ATOL)
     assert_allclose(2., np.trace(self.f(np.pi / 2, direc, point)))
Esempio n. 9
0
def test_reflection_from_matrix():
    v0 = np.array([0.2, 0.2, 0.2])  # arbitrary values
    v1 = np.array([0.4, 0.4, 0.4])
    M0 = t.reflection_matrix(v0, v1)
    point, normal = t.reflection_from_matrix(M0)
    M1 = t.reflection_matrix(point, normal)
    assert_equal(t.is_same_transform(M0, M1), True)
def test_reflection_from_matrix():
    v0 = np.array([0.2, 0.2, 0.2])  # arbitrary values
    v1 = np.array([0.4, 0.4, 0.4])
    M0 = t.reflection_matrix(v0, v1)
    point, normal = t.reflection_from_matrix(M0)
    M1 = t.reflection_matrix(point, normal)
    assert_equal(t.is_same_transform(M0, M1), True)
Esempio n. 11
0
def test_reflection_from_matrix():
    v0 = np.random.random(3) - 0.5
    v1 = np.random.random(3) - 0.5
    M0 = t.reflection_matrix(v0, v1)
    point, normal = t.reflection_from_matrix(M0)
    M1 = t.reflection_matrix(point, normal)
    assert_equal(t.is_same_transform(M0, M1), True)
 def test_projection_from_matrix_4(self, data):
     point, normal, direct, persp = data
     P0 = t.projection_matrix(
         point, normal, perspective=persp, pseudo=True)
     result = t.projection_from_matrix(P0, pseudo=True)
     P1 = t.projection_matrix(*result)
     assert_equal(t.is_same_transform(P0, P1), True)
Esempio n. 13
0
def test_reflection_from_matrix():
    v0 = np.random.random(3) - 0.5
    v1 = np.random.random(3) - 0.5
    M0 = t.reflection_matrix(v0, v1)
    point, normal = t.reflection_from_matrix(M0)
    M1 = t.reflection_matrix(point, normal)
    assert_equal(t.is_same_transform(M0, M1), True)
Esempio n. 14
0
 def test_projection_from_matrix_4(self, data):
     point, normal, direct, persp = data
     P0 = t.projection_matrix(
         point, normal, perspective=persp, pseudo=True)
     result = t.projection_from_matrix(P0, pseudo=True)
     P1 = t.projection_matrix(*result)
     assert_equal(t.is_same_transform(P0, P1), True)
Esempio n. 15
0
def test_rotation_from_matrix():
    angle = 0.2 * 2 * np.pi  # arbitrary values
    direc = np.array([0.2, 0.2, 0.2])
    point = np.array([0.4, 0.4, 0.4])
    R0 = t.rotation_matrix(angle, direc, point)
    angle, direc, point = t.rotation_from_matrix(R0)
    R1 = t.rotation_matrix(angle, direc, point)
    assert_equal(t.is_same_transform(R0, R1), True)
def test_rotation_from_matrix():
    angle = 0.2 * 2 * np.pi  # arbitrary values
    direc = np.array([0.2, 0.2, 0.2])
    point = np.array([0.4, 0.4, 0.4])
    R0 = t.rotation_matrix(angle, direc, point)
    angle, direc, point = t.rotation_from_matrix(R0)
    R1 = t.rotation_matrix(angle, direc, point)
    assert_equal(t.is_same_transform(R0, R1), True)
Esempio n. 17
0
def test_rotation_from_matrix():
    angle = (random.random() - 0.5) * (2*np.pi)
    direc = np.random.random(3) - 0.5
    point = np.random.random(3) - 0.5
    R0 = t.rotation_matrix(angle, direc, point)
    angle, direc, point = t.rotation_from_matrix(R0)
    R1 = t.rotation_matrix(angle, direc, point)
    assert_equal(t.is_same_transform(R0, R1), True)
Esempio n. 18
0
 def test_projection_from_matrix_4(self):
     P0 = t.projection_matrix(self.point,
                              self.normal,
                              perspective=self.persp,
                              pseudo=True)
     result = t.projection_from_matrix(P0, pseudo=True)
     P1 = t.projection_matrix(*result)
     assert_equal(t.is_same_transform(P0, P1), True)
Esempio n. 19
0
def test_rotation_from_matrix():
    angle = (random.random() - 0.5) * (2 * np.pi)
    direc = np.random.random(3) - 0.5
    point = np.random.random(3) - 0.5
    R0 = t.rotation_matrix(angle, direc, point)
    angle, direc, point = t.rotation_from_matrix(R0)
    R1 = t.rotation_matrix(angle, direc, point)
    assert_equal(t.is_same_transform(R0, R1), True)
Esempio n. 20
0
 def test_projection_matrix_2(self):
     point = np.random.random(3) - 0.5
     normal = np.random.random(3) - 0.5
     direct = np.random.random(3) - 0.5
     persp = np.random.random(3) - 0.5
     P0 = self.f(point, normal)
     P1 = self.f(point, normal, direction=direct)
     P2 = self.f(point, normal, perspective=persp)
     P3 = self.f(point, normal, perspective=persp, pseudo=True)
     assert_equal(t.is_same_transform(P2, np.dot(P0, P3)), True)
Esempio n. 21
0
 def test_projection_matrix_2(self):
     point = np.random.random(3) - 0.5
     normal = np.random.random(3) - 0.5
     direct = np.random.random(3) - 0.5
     persp = np.random.random(3) - 0.5
     P0 = self.f(point, normal)
     P1 = self.f(point, normal, direction=direct)
     P2 = self.f(point, normal, perspective=persp)
     P3 = self.f(point, normal, perspective=persp, pseudo=True)
     assert_equal(t.is_same_transform(P2, np.dot(P0, P3)), True)
Esempio n. 22
0
def test_compose_matrix():
    scale = np.random.random(3) - 0.5
    shear = np.random.random(3) - 0.5
    angles = (np.random.random(3) - 0.5) * (2 * math.pi)
    trans = np.random.random(3) - 0.5
    persp = np.random.random(4) - 0.5
    M0 = t.compose_matrix(scale, shear, angles, trans, persp)
    result = t.decompose_matrix(M0)
    M1 = t.compose_matrix(*result)
    assert_equal(t.is_same_transform(M0, M1), True)
Esempio n. 23
0
def test_compose_matrix():
    scale = np.random.random(3) - 0.5
    shear = np.random.random(3) - 0.5
    angles = (np.random.random(3) - 0.5) * (2*math.pi)
    trans = np.random.random(3) - 0.5
    persp = np.random.random(4) - 0.5
    M0 = t.compose_matrix(scale, shear, angles, trans, persp)
    result = t.decompose_matrix(M0)
    M1 = t.compose_matrix(*result)
    assert_equal(t.is_same_transform(M0, M1), True)
def test_compose_matrix():
    scale = np.array([0.2, 0.2, 0.2])  # arbitrary values
    shear = np.array([0.4, 0.4, 0.4])
    angles = np.array([0.6, 0.6, 0.6]) * 2 * np.pi
    trans = np.array([0.8, 0.8, 0.8])
    persp = np.array([0.9, 0.9, 0.9, 0.9])

    M0 = t.compose_matrix(scale, shear, angles, trans, persp)
    result = t.decompose_matrix(M0)
    M1 = t.compose_matrix(*result)
    assert_equal(t.is_same_transform(M0, M1), True)
Esempio n. 25
0
def test_compose_matrix():
    scale = np.array([0.2, 0.2, 0.2])  # arbitrary values
    shear = np.array([0.4, 0.4, 0.4])
    angles = np.array([0.6, 0.6, 0.6]) * 2 * np.pi
    trans = np.array([0.8, 0.8, 0.8])
    persp = np.array([0.9, 0.9, 0.9, 0.9])

    M0 = t.compose_matrix(scale, shear, angles, trans, persp)
    result = t.decompose_matrix(M0)
    M1 = t.compose_matrix(*result)
    assert_equal(t.is_same_transform(M0, M1), True)
Esempio n. 26
0
    def test_projection_matrix_2(self):
        point = np.array([0.2, 0.2, 0.2])  # arbitrary values
        normal = np.array([0.4, 0.4, 0.4])
        direct = np.array([0.6, 0.6, 0.6])
        persp = np.array([0.8, 0.8, 0.8])

        P0 = self.f(point, normal)
        # TODO: why isn't this used anymore?
        P1 = self.f(point, normal, direction=direct)
        P2 = self.f(point, normal, perspective=persp)
        P3 = self.f(point, normal, perspective=persp, pseudo=True)
        assert_equal(t.is_same_transform(P2, np.dot(P0, P3)), True)
    def test_projection_matrix_2(self, f):
        point = np.array([0.2, 0.2, 0.2])  # arbitrary values
        normal = np.array([0.4, 0.4, 0.4])
        direct = np.array([0.6, 0.6, 0.6])
        persp = np.array([0.8, 0.8, 0.8])

        P0 = f(point, normal)
        # TODO: why isn't this used anymore?
        P1 = f(point, normal, direction=direct)
        P2 = f(point, normal, perspective=persp)
        P3 = f(point, normal, perspective=persp, pseudo=True)
        assert_equal(t.is_same_transform(P2, np.dot(P0, P3)), True)
Esempio n. 28
0
def test_shear_from_matrix():
    # This seems to fail sometimes if the random numbers
    # roll certain values....
    # angle = (random.random() - 0.5) * 4*math.pi
    # direct = np.random.random(3) - 0.5
    # point = np.random.random(3) - 0.5
    # normal = np.cross(direct, np.random.random(3))
    # So here are some of my random numbers
    angle = 2.8965075413405783
    direct = np.array([-0.31117458, -0.41769518, -0.01188556])
    point = np.array([-0.0035982, -0.40997482, 0.42241425])
    normal = np.cross(direct, np.array([0.08122421, 0.4747914, 0.19851859]))

    S0 = t.shear_matrix(angle, direct, point, normal)
    angle, direct, point, normal = t.shear_from_matrix(S0)
    S1 = t.shear_matrix(angle, direct, point, normal)
    assert_equal(t.is_same_transform(S0, S1), True)
Esempio n. 29
0
def test_shear_from_matrix():
    # This seems to fail sometimes if the random numbers
    # roll certain values....
    # angle = (random.random() - 0.5) * 4*math.pi
    # direct = np.random.random(3) - 0.5
    # point = np.random.random(3) - 0.5
    # normal = np.cross(direct, np.random.random(3))
    # So here are some of my random numbers
    angle = 2.8965075413405783
    direct = np.array([-0.31117458, -0.41769518, -0.01188556])
    point = np.array([-0.0035982, -0.40997482,  0.42241425])
    normal = np.cross(direct, np.array([ 0.08122421,  0.4747914 ,  0.19851859]))

    S0 = t.shear_matrix(angle, direct, point, normal)
    angle, direct, point, normal = t.shear_from_matrix(S0)
    S1 = t.shear_matrix(angle, direct, point, normal)
    assert_equal(t.is_same_transform(S0, S1), True)
def test_shear_from_matrix():
    # This seems to fail sometimes if the random numbers
    # roll certain values....
    # angle = (random.random() - 0.5) * 4*np.pi
    # direct = np.random.random(3) - 0.5
    # point = np.random.random(3) - 0.5
    # normal = np.cross(direct, np.random.random(3))
    # In this random configuration the test will fail about 0.05% of all times.
    # Then we hit some edge-cases of the algorithm. The edge cases for these
    # values are slightly different for the linalg library used (MKL/LAPACK).
    # So here are some of my random numbers
    angle = 2.8969075413405783  # arbitrary values
    direct = np.array([-0.31117458, -0.41769518, -0.01188556])
    point = np.array([-0.0035982, -0.40997482, 0.42241425])
    normal = np.cross(direct, np.array([0.08122421, 0.4747914, 0.19851859]))

    S0 = t.shear_matrix(angle, direct, point, normal)
    angle, direct, point, normal = t.shear_from_matrix(S0)
    S1 = t.shear_matrix(angle, direct, point, normal)
    assert_equal(t.is_same_transform(S0, S1), True)
Esempio n. 31
0
def test_shear_from_matrix():
    # This seems to fail sometimes if the random numbers
    # roll certain values....
    # angle = (random.random() - 0.5) * 4*np.pi
    # direct = np.random.random(3) - 0.5
    # point = np.random.random(3) - 0.5
    # normal = np.cross(direct, np.random.random(3))
    # In this random configuration the test will fail about 0.05% of all times.
    # Then we hit some edge-cases of the algorithm. The edge cases for these
    # values are slightly different for the linalg library used (MKL/LAPACK).
    # So here are some of my random numbers
    angle = 2.8969075413405783  # arbitrary values
    direct = np.array([-0.31117458, -0.41769518, -0.01188556])
    point = np.array([-0.0035982, -0.40997482, 0.42241425])
    normal = np.cross(direct, np.array([0.08122421, 0.4747914, 0.19851859]))

    S0 = t.shear_matrix(angle, direct, point, normal)
    angle, direct, point, normal = t.shear_from_matrix(S0)
    S1 = t.shear_matrix(angle, direct, point, normal)
    assert_equal(t.is_same_transform(S0, S1), True)
Esempio n. 32
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)
Esempio n. 33
0
 def test_projection_from_matrix_2(self):
     P0 = t.projection_matrix(self.point, self.normal, self.direct)
     result = t.projection_from_matrix(P0)
     P1 = t.projection_matrix(*result)
     assert_equal(t.is_same_transform(P0, P1), True)
Esempio n. 34
0
 def test_projection_from_matrix_2(self):
     P0 = t.projection_matrix(self.point, self.normal, self.direct)
     result = t.projection_from_matrix(P0)
     P1 = t.projection_matrix(*result)
     assert_equal(t.is_same_transform(P0, P1), True)
Esempio n. 35
0
 def test_projection_from_matrix_4(self):
     P0 = t.projection_matrix(self.point, self.normal,
                              perspective=self.persp, pseudo=True)
     result = t.projection_from_matrix(P0, pseudo=True)
     P1 = t.projection_matrix(*result)
     assert_equal(t.is_same_transform(P0, P1), True)
Esempio n. 36
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)