1 /* === S Y N F I G ========================================================= */ 2 /*! \file ducktransform_matrix.h 3 ** \brief Template Header 4 ** 5 ** $Id$ 6 ** 7 ** \legal 8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley 9 ** 10 ** This package is free software; you can redistribute it and/or 11 ** modify it under the terms of the GNU General Public License as 12 ** published by the Free Software Foundation; either version 2 of 13 ** the License, or (at your option) any later version. 14 ** 15 ** This package is distributed in the hope that it will be useful, 16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 ** General Public License for more details. 19 ** \endlegal 20 */ 21 /* ========================================================================= */ 22 23 /* === S T A R T =========================================================== */ 24 25 #ifndef __SYNFIG_STUDIO_DUCK_TRANSFORM_MATRIX_H 26 #define __SYNFIG_STUDIO_DUCK_TRANSFORM_MATRIX_H 27 28 /* === H E A D E R S ======================================================= */ 29 30 #include "duckmatic.h" 31 #include <synfig/matrix.h> 32 33 /* === M A C R O S ========================================================= */ 34 35 /* === T Y P E D E F S ===================================================== */ 36 37 /* === C L A S S E S & S T R U C T S ======================================= */ 38 39 namespace studio { 40 41 class Transform_Matrix : public synfig::Transform 42 { 43 private: 44 synfig::Matrix transform; 45 synfig::Matrix inverse_transform; 46 47 public: Transform_Matrix(const synfig::GUID & guid,const synfig::Matrix & matrix)48 Transform_Matrix(const synfig::GUID& guid, const synfig::Matrix& matrix): 49 Transform(guid), 50 transform(matrix) 51 { 52 if (transform.is_invertible()) 53 (inverse_transform = transform).invert(); 54 else 55 synfig::warning("%s:%d passed a non-invertible matrix", __FILE__, __LINE__); 56 } 57 perform(const synfig::Vector & x)58 synfig::Vector perform(const synfig::Vector& x)const 59 { 60 return transform.get_transformed(x); 61 } unperform(const synfig::Vector & x)62 synfig::Vector unperform(const synfig::Vector& x)const 63 { 64 return inverse_transform.get_transformed(x); 65 } 66 get_string()67 synfig::String get_string()const 68 { 69 return "duck matrix"; 70 } 71 }; 72 73 }; 74 75 /* === E N D =============================================================== */ 76 77 #endif 78