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)
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)
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)
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)