def test_scaling_transform_inverse_known_values(self): """ ScalingTransform.inverse should return known result with known input for scaling transformations. """ src = SCALING_KNOWN_VALUES[0][-1] for rotation, scale, _, translation, dst in SCALING_KNOWN_VALUES: tform = ScalingTransform(rotation=rotation, scale=scale, translation=translation).inverse() numpy.testing.assert_array_almost_equal(src, tform.apply(dst))
def test_scaling_transform_matrix_known_values(self): for rotation, scale, shear, _, _ in SCALING_KNOWN_VALUES: tform = ScalingTransform(rotation=rotation, scale=scale) R = _rotation_matrix_from_angle(rotation) S = scale * numpy.eye(2) matrix = numpy.dot(R, S) numpy.testing.assert_array_almost_equal(matrix, tform.transformation_matrix)
def test_scaling_transform_from_pointset_non_negative_scaling(self): """ ScalingTransform.from_pointset should not return a negative value for the scaling when there is a reflection in the point set for scaling transformations. """ src = numpy.array([(0., 0.), (1., 0.), (0., 2.)]) dst = numpy.array([(0., 0.), (-1., 0.), (0., 2.)]) tform = ScalingTransform.from_pointset(src, dst) self.assertTrue(numpy.all(tform.scale > 0.))
def test_scaling_transform_from_pointset_known_values(self): """ ScalingTransform.from_pointset should return known result with known input for scaling transformations. """ src = SCALING_KNOWN_VALUES[0][-1] for rotation, scale, _, translation, dst in SCALING_KNOWN_VALUES: tform = ScalingTransform.from_pointset(src, dst) self.assertAlmostEqual(0., _angle_diff(rotation, tform.rotation)) numpy.testing.assert_array_almost_equal(scale, tform.scale) numpy.testing.assert_array_almost_equal(translation, tform.translation)