#ifndef math_LinearTransformation_H__ #define math_LinearTransformation_H__ #include "Transformation.h" #include "Matrix.h" #include namespace meow { /*! * @brief A base class for implementing kinds of linear transformations. * * Because all linear transformations belong to transformations, * this class inherit to Transformation. * * @author cat_leopard */ template class LinearTransformation: public Transformation { private: Matrix matrix_; protected: /*! * Constructor with input/output size gived */ LinearTransformation(size_t inputRows, size_t outputRows, size_t psize): Transformation(inputRows, 1u, outputRows, 1u, psize), matrix_(outputRows, inputRows, Scalar(0.0)) { } /*! * Constructor with input/output size gived and a inital matrix */ LinearTransformation(size_t inputRows, size_t outputRows, size_t psize, Matrix const& m): Transformation(inputRows, 1u, outputRows, 1u, psize), matrix_(m) { } /*! * Constructor with another LinearTransformation * * @param [in] b another LinearTransformation */ LinearTransformation(LinearTransformation const& b): Transformation(b), matrix_(b.matrix_) { } /*! * @brief Copy settings, matrix from another LinearTransformation * * @param [in] b another LinearTransformation */ LinearTransformation& copyFrom(LinearTransformation const& b) { Transformation::copyFrom(b); matrix_.copyFrom(b.matrix_); return *this; } /*! * @brief Reference settings, matrix from another LinearTransformation * * @param [in] b another LinearTransformation */ LinearTransformation& referenceFrom(LinearTransformation const& b) { Transformation::referenceFrom(b); matrix_.referenceFrom(b.matrix_); return *this; } /*! * @brief setup the matrix */ virtual Matrix const& matrix(Matrix const& m) { matrix_.copyFrom(m); return matrix(); } public: /*! * Destructor */ virtual ~LinearTransformation() { } /*! * @brief Return the matrix form of this transformation * * @return A matrix */ virtual Matrix const& matrix() const { return matrix_; } /*! * @brief Return the inverse of the matrix form of this transformate * * @return A matrix (may be invalid) */ virtual Matrix matrixInv() const { return matrix_.inverse(); } }; } // meow #endif // math_LinearTransformation_H__