Beispiel #1
0
    def inverse(self):
        """
        Return the inverse transformation.

        Returns
        -------
        tform : Transform
            The inverse transformation.

        Examples
        --------
        >>> t = Transform(rotation=(numpy.pi / 4.), scaling=0.5)
        >>> tinv = t.inverse()
        >>> numpy.dot(t.transformation_matrix, tinv.transformation_matrix)
        array([[ 1., -0.],
               [ 0.,  1.]])

        """
        S = self.scaling * numpy.eye(2)
        L = numpy.array([(1., self.shear), (0., 1.)])
        SL = numpy.dot(S, L)
        Ainv = numpy.dot(tri_inv(SL), numpy.transpose(self.rotation_matrix))
        tinv = -numpy.dot(Ainv, self.translation)
        tform = self.__class__(translation=tinv)
        tform.transformation_matrix = Ainv
        return tform
Beispiel #2
0
    def inverse(self):
        """
        Return the inverse transformation.

        Returns
        -------
        tform : Transform
            The inverse transformation.

        Examples
        --------
        >>> t = Transform(rotation=(numpy.pi / 4.), scaling=0.5)
        >>> tinv = t.inverse()
        >>> numpy.dot(t.transformation_matrix, tinv.transformation_matrix)
        array([[ 1., -0.],
               [ 0.,  1.]])

        """
        S = self.scaling * numpy.eye(2)
        L = numpy.array([(1., self.shear), (0., 1.)])
        SL = numpy.dot(S, L)
        Ainv = numpy.dot(tri_inv(SL), numpy.transpose(self.rotation_matrix))
        tinv = -numpy.dot(Ainv, self.translation)
        tform = self.__class__(translation=tinv)
        tform.transformation_matrix = Ainv
        return tform
Beispiel #3
0
 def testUnity(self):
     """
     tri_inv(I) == I
     """
     for i in range(1, 10):
         c = numpy.eye(i)
         self.assertTrue(numpy.allclose(tri_inv(c), c))
Beispiel #4
0
 def testUnity(self):
     """
     tri_inv(I) == I
     """
     for i in range(1, 10):
         c = numpy.eye(i)
         self.assertTrue(numpy.allclose(tri_inv(c), c))
Beispiel #5
0
 def testInverseUpper(self):
     """
     c * tri_inv(c) == I, with c an upper triangular matrix
     """
     for i in range(1, 10):
         matrix = numpy.arange(float(i * i)).reshape(i, i) + 1.
         c = numpy.triu(matrix)
         self.assertTrue(numpy.allclose(numpy.dot(c, tri_inv(c)), numpy.eye(i)))
Beispiel #6
0
 def testInverseUpper(self):
     """
     c * tri_inv(c) == I, with c an upper triangular matrix
     """
     for i in range(1, 10):
         matrix = numpy.arange(float(i * i)).reshape(i, i) + 1.
         c = numpy.triu(matrix)
         self.assertTrue(numpy.allclose(numpy.dot(c, tri_inv(c)), numpy.eye(i)))
Beispiel #7
0
    def inverse(self):
        """
        Return the inverse transformation.

        Returns
        -------
        tform : AffineTransform
            The inverse transformation.

        """
        S = self.scale * numpy.eye(2)
        L = numpy.array([(1., self.shear), (0., 1.)])
        SL = numpy.dot(S, L)
        Ainv = numpy.dot(tri_inv(SL), numpy.transpose(self.rotation_matrix))
        tinv = -numpy.dot(Ainv, self.translation)
        return self.__class__(matrix=Ainv, translation=tinv)