00001 /**************************************************************************** 00002 * VCGLib o o * 00003 * Visual and Computer Graphics Library o o * 00004 * _ O _ * 00005 * Copyright(C) 2004 \/)\/ * 00006 * Visual Computing Lab /\/| * 00007 * ISTI - Italian National Research Council | * 00008 * \ * 00009 * All rights reserved. * 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 * This program is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 00020 * for more details. * 00021 * * 00022 ****************************************************************************/ 00023 #ifndef __VCG_SIMILARITY2_H 00024 #define __VCG_SIMILARITY2_H 00025 namespace vcg 00026 { 00027 00028 /* 00029 This class codify a similarity transformation in 2D 00030 00031 The applied transformation is exactly the same of the Similarity class 00032 Tra(Sca(Rot(P))) 00033 */ 00034 00035 template <class SCALAR_TYPE> 00036 class Similarity2 00037 { 00038 public: 00039 Similarity2():rotRad(0),tra(0,0),sca(1) {} 00040 00041 SCALAR_TYPE rotRad; 00042 Point2<SCALAR_TYPE> tra; 00043 SCALAR_TYPE sca; 00044 }; 00045 00046 template <class SCALAR_TYPE> 00047 Point2<SCALAR_TYPE> operator*(const Similarity2<SCALAR_TYPE> &m, const Point2<SCALAR_TYPE> &p) { 00048 Point2<SCALAR_TYPE> r = p; 00049 // Apply Rotation to point 00050 r.Rotate(m.rotRad); 00051 r *= m.sca; 00052 r += m.tra; 00053 return r; 00054 } 00055 00056 typedef Similarity2<float> Similarity2f; 00057 typedef Similarity2<double> Similarity2d; 00058 00059 } // end namespace vcg 00060 #endif // __VCG_SIMILARITY2_H