Next / Previous / Contents / Shipman's homepage

8.5. Xform.inverse(): Return the inverse transform

The first time this method is called, the .__mInverse attribute will be None, as it was initialized in the constructor. At that point we compute the matrix inverse of self.__m and store it there for future reuse.

In NumPy, matrix inversion is the function inv() in the linear algebra submodule num.linalg.

homcoord.py
# - - -   X f o r m . i n v e r s e

    def inverse ( self ):
        '''Return the inverse transform as an Xform.
        '''
        #-- 1 --
        # [ if self.__mInverse is None ->
        #     self.__mInverse  :=  matrix inverse of self.__m
        #   else -> I ]
        if self.__mInverse is None:
            self.__mInverse = num.linalg.inv ( self.__m )

        #-- 2 --
        return Xform(self.__mInverse)