def test_inverse(self): x = torch.tensor([0.1]) y = torch.tensor([0.2, 2.0]) z = torch.tensor([0.3, 3.0]) t = Scale(x, y, z) im = t.inverse()._matrix im_2 = t._matrix.inverse() im_comp = t.get_matrix().inverse() self.assertTrue(torch.allclose(im, im_comp)) self.assertTrue(torch.allclose(im, im_2))
def test_stack(self): rotations = random_rotations(3) transform3 = Transform3d().rotate(rotations).translate( torch.full((3, 3), 0.3)) transform1 = Scale(37) transform4 = transform1.stack(transform3) self.assertEqual(len(transform1), 1) self.assertEqual(len(transform3), 3) self.assertEqual(len(transform4), 4) self.assertClose( transform4.get_matrix(), torch.cat([transform1.get_matrix(), transform3.get_matrix()]), ) points = torch.rand(4, 5, 3) new_points_expect = torch.cat([ transform1.transform_points(points[:1]), transform3.transform_points(points[1:]), ]) new_points = transform4.transform_points(points) self.assertClose(new_points, new_points_expect)