Test 90deg rotation for similarity transform

This commit is contained in:
Johannes Schönberger
2014-05-10 10:22:55 -04:00
parent c3e13a9754
commit 02e6ad6b71
2 changed files with 13 additions and 2 deletions
+2 -2
View File
@@ -620,9 +620,9 @@ class SimilarityTransform(ProjectiveTransform):
@property
def scale(self):
if math.cos(self.rotation) == 0:
if abs(math.cos(self.rotation)) < np.spacing(1):
# sin(self.rotation) == 1
scale = self.params[0, 1]
scale = self.params[1, 0]
else:
scale = self.params[0, 0] / math.cos(self.rotation)
return scale
+11
View File
@@ -99,6 +99,17 @@ def test_similarity_init():
assert_array_almost_equal(tform.translation, translation)
# test special case for scale if rotation=90deg
scale = 0.1
rotation = np.pi / 2
translation = (1, 1)
tform = SimilarityTransform(scale=scale, rotation=rotation,
translation=translation)
assert_array_almost_equal(tform.scale, scale)
assert_array_almost_equal(tform.rotation, rotation)
assert_array_almost_equal(tform.translation, translation)
def test_affine_estimation():
# exact solution
tform = estimate_transform('affine', SRC[:3, :], DST[:3, :])