Esempio n. 1
0
 def test_rotation_matrix_from_angle_known_values(self):
     """
     _rotation_matrix_from_angle should give known result with known input.
     """
     for angle, matrix in self.known_values:
         result = _rotation_matrix_from_angle(angle)
         numpy.testing.assert_array_almost_equal(matrix, result)
Esempio n. 2
0
 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)
Esempio n. 3
0
 def test_roundtrip(self):
     """
     _rotation_matrix_to_angle(_rotation_matrix_from_angle(angle)) == angle
     for all angles.
     """
     for angle in numpy.pi * numpy.linspace(-1, 1, 1000):
         matrix = _rotation_matrix_from_angle(angle)
         result = _rotation_matrix_to_angle(matrix)
         self.assertAlmostEqual(angle, result)
Esempio n. 4
0
 def test_affine_transform_matrix_known_values(self):
     for rotation, scale, shear, _, _ in AFFINE_KNOWN_VALUES:
         tform = AffineTransform(rotation=rotation, scale=scale,
                                 shear=shear)
         R = _rotation_matrix_from_angle(rotation)
         S = scale * numpy.eye(2)
         L = numpy.array([(1., shear), (0., 1.)])
         matrix = numpy.dot(numpy.dot(R, S), L)
         numpy.testing.assert_array_almost_equal(matrix, tform.transformation_matrix)
Esempio n. 5
0
 def test_rotation_matrix_properties(self):
     """
     Test that the rotation matrix is a 2x2 square orthogonal matrix, with
     determinant equal to 1.
     """
     for angle in numpy.pi * numpy.linspace(-1., 1., 1000):
         matrix = _rotation_matrix_from_angle(angle)
         self.assertEqual(matrix.shape, (2, 2))
         numpy.testing.assert_array_almost_equal(numpy.dot(matrix.T, matrix), numpy.eye(2))
         self.assertAlmostEqual(numpy.linalg.det(matrix), 1.)
Esempio n. 6
0
 def test_similarity_transform_from_pointset_umeyama(self):
     """
     SimilarityTransform.from_pointset should return the known results for
     the specific known input as described in the paper by Umeyama.
     """
     src = numpy.array([(0, 0), (1, 0), (0, 2)])
     dst = numpy.array([(0, 0), (-1, 0), (0, 2)])
     tform = SimilarityTransform.from_pointset(src, dst)
     numpy.testing.assert_array_almost_equal(
         _rotation_matrix_from_angle(tform.rotation),
         numpy.array([(0.832, 0.555), (-0.555, 0.832)]),
         decimal=3,
     )
     self.assertAlmostEqual(tform.scale, 0.721, places=3)
     numpy.testing.assert_array_almost_equal(tform.translation,
                                             numpy.array([-0.800, 0.400]))
     self.assertAlmostEqual(tform.fre(src, dst), 0.516, places=3)
Esempio n. 7
0
 def test_similarity_transform_matrix_known_values(self):
     for rotation, scale, _, _, _ in SIMILARITY_KNOWN_VALUES:
         tform = SimilarityTransform(rotation=rotation, scale=scale)
         R = _rotation_matrix_from_angle(rotation)
         matrix = scale * R
         numpy.testing.assert_array_almost_equal(matrix, tform.transformation_matrix)
Esempio n. 8
0
 def test_rigid_transform_matrix_known_values(self):
     for rotation, _, _, _, _ in RIGID_KNOWN_VALUES:
         tform = RigidTransform(rotation=rotation)
         matrix = _rotation_matrix_from_angle(rotation)
         numpy.testing.assert_array_almost_equal(matrix, tform.transformation_matrix)