//=========================================================================== // GoTools Core - SINTEF Geometry Tools Core library, version 2.0.1 // // Copyright (C) 2000-2007, 2010 SINTEF ICT, Applied Mathematics, Norway. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //=========================================================================== 00015 #ifndef _COORDINATESYSTEM_H 00016 #define _COORDINATESYSTEM_H 00017 00018 #include "GoTools/utils/Array.h" 00019 #include "GoTools/utils/MatrixXD.h" 00020 00021 namespace Go 00022 { 00023 00025 00026 template <int Dim> 00027 class CoordinateSystem 00028 { 00029 public: 00030 typedef MatrixXD<double, Dim> Matrix; 00031 typedef Array<double, Dim> Vector; 00032 00035 CoordinateSystem() 00036 { 00037 rotation_.identity(); 00038 translation_.zero(); 00039 } 00040 00043 CoordinateSystem(const Matrix& rot, const Vector& trans) 00044 : rotation_(rot), translation_(trans) 00045 {} 00046 00049 Vector operator* (const Vector& v) 00050 { 00051 return rotation_*v + translation_; 00052 } 00053 00056 CoordinateSystem operator* (const CoordinateSystem& c) 00057 { 00058 Matrix newrot = rotation_*c.rotation_; 00059 Vector newtrans = translation_ + rotation_*c.translation_; 00060 return CoordinateSystem(newrot, newtrans); 00061 } 00062 00064 Matrix& rot() { return rotation_; } 00065 00067 const Matrix& rot() const { return rotation_; } 00068 00070 Vector& tr() { return translation_; } 00071 00073 const Vector& tr() const { return translation_; } 00074 00075 private: 00076 Matrix rotation_; 00077 Vector translation_; 00078 }; 00079 00080 00081 } // namespace Go 00082 00083 00084 00085 #endif // _COORDINATESYSTEM_H 00086