00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000,2001 by the OpenSG Forum & TU Darmstadt * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: alexa@gris.informatik.tu-darmstadt.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * This library is free software; you can redistribute it and/or modify it * 00016 * under the terms of the GNU Library General Public License as published * 00017 * by the Free Software Foundation, version 2. * 00018 * * 00019 * This library is distributed in the hope that it will be useful, but * 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00022 * Library General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU Library General Public * 00025 * License along with this library; if not, write to the Free Software * 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00027 * * 00028 \*---------------------------------------------------------------------------*/ 00029 /*---------------------------------------------------------------------------*\ 00030 * Changes * 00031 * * 00032 * Initial Version by Tobias Klug * 00033 * * 00034 * * 00035 * * 00036 * * 00037 \*---------------------------------------------------------------------------*/ 00038 00039 #ifndef _OSGLINEARTRANSFORM_H_ 00040 #define _OSGLINEARTRANSFORM_H_ 00041 #ifdef __sgi 00042 #pragma once 00043 #endif 00044 00045 //--------------------------------------------------------------------------- 00046 // Includes 00047 //--------------------------------------------------------------------------- 00048 00049 #include <OSGBase.h> 00050 #include <OSGMatrix.h> 00051 00052 #include <string> 00053 00054 OSG_BEGIN_NAMESPACE 00055 00056 //--------------------------------------------------------------------------- 00057 // Types 00058 //--------------------------------------------------------------------------- 00059 00060 //--------------------------------------------------------------------------- 00061 // Forward References 00062 //--------------------------------------------------------------------------- 00063 00064 //--------------------------------------------------------------------------- 00065 // Class 00066 //--------------------------------------------------------------------------- 00067 00073 template<class ValueTypeT> 00074 class LinearTransform 00075 { 00076 public: 00077 00078 //----------------------------------------------------------------------- 00079 // enums 00080 //----------------------------------------------------------------------- 00081 00082 //----------------------------------------------------------------------- 00083 // types 00084 //----------------------------------------------------------------------- 00085 00086 typedef ValueTypeT ValueType; 00087 typedef TransformationMatrix<ValueTypeT> MatrixType; 00088 00089 //----------------------------------------------------------------------- 00090 // class functions 00091 //----------------------------------------------------------------------- 00092 00093 static const char *getClassname(void) { return "LinearTransform";}; 00094 00095 //----------------------------------------------------------------------- 00096 // instance functions 00097 //----------------------------------------------------------------------- 00098 00099 LinearTransform(void); 00100 LinearTransform(const LinearTransform &source); 00101 LinearTransform(const MatrixType &mat); 00102 00103 ~LinearTransform(void); 00104 00105 /*------------------------- set functions -------------------------------*/ 00106 00107 void setIdentity(void); 00108 00109 void setValue(const MatrixType &mat); 00110 void setValue(const LinearTransform &mat); 00111 void setLogMatrix( MatrixType &mat ); 00112 00113 /*------------------------- get functions -------------------------------*/ 00114 00115 MatrixType getLogMatrix(); 00116 const MatrixType getLogMatrixConst() const; 00117 /*---------------------- create transformation --------------------------*/ 00118 00119 MatrixType getTransform(); 00120 operator MatrixType(); 00121 00122 /*------------------------- assignment ----------------------------------*/ 00123 00124 LinearTransform<ValueTypeT> & operator =( 00125 const LinearTransform &source); 00126 00127 /*------------------------- comparison ----------------------------------*/ 00128 00129 bool operator == (const LinearTransform &other) const; 00130 bool operator != (const LinearTransform &other) const; 00131 00132 /*------------------------- operators -----------------------------------*/ 00133 00134 00135 LinearTransform<ValueTypeT> 00136 operator + (const LinearTransform <) const; 00137 LinearTransform<ValueTypeT> 00138 operator * (const ValueTypeT s) const; 00139 00140 LinearTransform<ValueTypeT> & 00141 operator += (const LinearTransform <); 00142 LinearTransform<ValueTypeT> & 00143 operator *= (const ValueTypeT s); 00144 00145 00146 protected: 00147 00148 //----------------------------------------------------------------------- 00149 // enums 00150 //----------------------------------------------------------------------- 00151 00152 //----------------------------------------------------------------------- 00153 // types 00154 //----------------------------------------------------------------------- 00155 00156 //----------------------------------------------------------------------- 00157 // class variables 00158 //----------------------------------------------------------------------- 00159 00160 //----------------------------------------------------------------------- 00161 // class functions 00162 //----------------------------------------------------------------------- 00163 00164 //----------------------------------------------------------------------- 00165 // instance variables 00166 //----------------------------------------------------------------------- 00167 00168 MatrixType _logMatrix; 00169 00170 //----------------------------------------------------------------------- 00171 // instance functions 00172 //----------------------------------------------------------------------- 00173 00174 private: 00175 //----------------------------------------------------------------------- 00176 // enums 00177 //----------------------------------------------------------------------- 00178 00179 //----------------------------------------------------------------------- 00180 // types 00181 //----------------------------------------------------------------------- 00182 00183 //----------------------------------------------------------------------- 00184 // friend classes 00185 //----------------------------------------------------------------------- 00186 00187 //----------------------------------------------------------------------- 00188 // friend functions 00189 //----------------------------------------------------------------------- 00190 00191 //----------------------------------------------------------------------- 00192 // class variables 00193 //----------------------------------------------------------------------- 00194 00195 // static char cvsid[]; 00196 00197 //----------------------------------------------------------------------- 00198 // class functions 00199 //----------------------------------------------------------------------- 00200 00201 //----------------------------------------------------------------------- 00202 // instance variables 00203 //----------------------------------------------------------------------- 00204 00205 //----------------------------------------------------------------------- 00206 // instance functions 00207 //----------------------------------------------------------------------- 00208 }; 00209 00210 //--------------------------------------------------------------------------- 00211 // Exported Types 00212 //--------------------------------------------------------------------------- 00213 00214 template<class ValueTypeT> 00215 LinearTransform<ValueTypeT> 00216 operator * (const ValueTypeT s, const LinearTransform<ValueTypeT> <); 00217 00223 typedef LinearTransform<Real32> LinearTransform4f; 00224 00225 OSG_END_NAMESPACE 00226 00227 #include "OSGLinearTransform.inl" 00228 00229 #define OSGLINEARTRANSFORM_HEADER_CVSID "@(#)$Id: $" 00230 00231 #endif /* _OSGLINEARTRANSFORM_H_ */ 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241
1.5.5