change interface of transformation merging

This commit is contained in:
Johannes Schönberger
2012-07-14 09:30:52 +02:00
parent b2ca833509
commit 4dcf8528bf
2 changed files with 2 additions and 15 deletions
+2 -14
View File
@@ -105,18 +105,15 @@ class GeometricTransformation(object):
self.inverse_matrix = np.linalg.inv(self.matrix)
return geometric_transform(coords, self.inverse_matrix)
def union(self, other):
def __mul__(self, other):
if type(self) == type(other):
transformation = self.__class__
else:
transformation = GeometricTransformation
return transformation(self.matrix.dot(other.matrix))
def __mul__(self, other):
return self.union(other)
def __add__(self, other):
return self.union(other)
return self.__mul__(other)
class SimilarityTransformation(GeometricTransformation):
@@ -424,15 +421,6 @@ class PolynomialTransformation(GeometricTransformation):
'parameters by exchanging source and destination coordinates.'
'Then apply the forward transformation.')
def union(self, other):
raise Exception('Cannot unite polynomial transformations.')
def __mul__(self, other):
return self.union(self, other)
def __add__(self, other):
return self.union(self, other)
TRANSFORMATIONS = {
'similarity': SimilarityTransformation,
@@ -135,7 +135,6 @@ def test_union():
translation2 = (0, 0)
tform2.from_params(scale2, rotation2, translation2)
tform = tform1.union(tform2)
tform = tform1 + tform2
tform = tform1 * tform2