def test_align_2d_translation(): t_vec = np.array([1, 2]) translation = Translation(t_vec) source = PointCloud(np.array([[0, 1], [1, 1], [-1, -5], [3, -5]])) target = translation.apply(source) # estimate the transform from source and target estimate = Translation.align(source, target) # check the estimates is correct assert_allclose(translation.h_matrix, estimate.h_matrix)
def chain_compose_before_tps_test(): a = PointCloud(np.random.random([10, 2])) b = PointCloud(np.random.random([10, 2])) tps = TPS(a, b) t = Translation([3, 4]) s = Scale([4, 2]) chain = TransformChain([t, s]) chain_mod = chain.compose_before(tps) points = PointCloud(np.random.random([10, 2])) manual_res = tps.apply(s.apply(t.apply(points))) chain_res = chain_mod.apply(points) assert(np.all(manual_res.points == chain_res.points))
def test_translation(): t_vec = np.array([1, 2, 3]) starting_vector = np.random.rand(10, 3) transform = Translation(t_vec) transformed = transform.apply(starting_vector) assert_allclose(starting_vector + t_vec, transformed)