ML Reference
MeVis/Foundation/Sources/MLLinearAlgebra/mlVector5.h
Go to the documentation of this file.
00001 // **InsertLicense** code 
00002 //=====================================================================================
00004 
00009 //=====================================================================================
00010 
00011 #ifndef __mlVector5_H
00012 #define __mlVector5_H
00013 
00014 // Include system independency file and project settings.
00015 #ifndef __mlLinearAlgebraSystem_H
00016 #include "mlLinearAlgebraSystem.h"
00017 #endif
00018 #ifndef __mlLinearAlgebraDefs_H
00019 #include "mlLinearAlgebraDefs.h"
00020 #endif
00021 #ifndef __mlFloatingPointVector_H
00022 #include "mlFloatingPointVector.h"
00023 #endif
00024 #ifndef __mlVector2_H
00025 #include "mlVector2.h"
00026 #endif
00027 #ifndef __mlVector3_H
00028 #include "mlVector3.h"
00029 #endif
00030 #ifndef __mlVector4_H
00031 #include "mlVector4.h"
00032 #endif
00033 #ifndef __mlMatrix5_H
00034 #include "mlMatrix5.h"
00035 #endif
00036 
00037 // All declarations of this header will be in the ML_LINEAR_ALGEBRA namespace.
00038 ML_LA_START_NAMESPACE
00039 
00040 //--------------------------------------------------------------------
00042 // This is necessary because we do not known whether vector or 
00043 // matrix header is included first and we cannot move template
00044 // code into C++ file.
00045 //--------------------------------------------------------------------
00046 template <class DT> class Tvec2;
00047 template <class DT> class Tvec3;
00048 template <class DT> class Tvec4;
00049 template <class DT> class Tmat5;
00051 
00052 //--------------------------------------------------------------------
00054 //--------------------------------------------------------------------
00056 template <class DT>
00057 class Tvec5 : public FloatingPointVector<DT,5> {
00058 public:
00059   
00061   typedef FloatingPointVector<DT,5> Superclass;
00062 
00064   typedef DT ComponentType;
00065   
00066   //--------------------------------------------------------------------
00068 
00069   //--------------------------------------------------------------------
00072   inline explicit Tvec5(const DT value=0) : Superclass(value)
00073   {
00074     ML_TRACE_IN_TIME_CRITICAL("Tvec5::Tvec5(const DT value=0)");
00075   }
00076   
00080   inline Tvec5(const Tvec5<DT>& v) : Superclass(v)
00081   {
00082     ML_TRACE_IN_TIME_CRITICAL("Tvec5::Tvec5(const Tvec5<DT>& v)");
00083   }
00084   
00086   inline Tvec5(const Superclass &v) : Superclass(v)
00087   {
00088     ML_TRACE_IN_TIME_CRITICAL("Tvec5::Tvec5(const Superclass &v)");
00089   }
00090   
00093   inline Tvec5(const DT x, const DT y, const DT z, const DT c, const DT t)
00094   {
00095     ML_TRACE_IN_TIME_CRITICAL("Tvec5::Tvec5(const DT x, const DT y, const DT z, const DT c, const DT t)");
00096     
00097     Superclass::_buffer[0] = x; 
00098     Superclass::_buffer[1] = y; 
00099     Superclass::_buffer[2] = z; 
00100     Superclass::_buffer[3] = c; 
00101     Superclass::_buffer[4] = t;
00102   }
00103   
00105   inline Tvec5(const Tvec2<DT>& v, const DT z, const DT c, const DT t)
00106   {
00107     ML_TRACE_IN_TIME_CRITICAL("Tvec5::Tvec5(const Tvec2<DT>& v, const DT z, const DT c, const DT t)");
00108     
00109     Superclass::_buffer[0] = v[0]; 
00110     Superclass::_buffer[1] = v[1]; 
00111     Superclass::_buffer[2] = z; 
00112     Superclass::_buffer[3] = c; 
00113     Superclass::_buffer[4] = t;
00114   }
00115   
00117   inline Tvec5(const Tvec3<DT>& v, const DT c, const DT t)
00118   {
00119     ML_TRACE_IN_TIME_CRITICAL("Tvec5::Tvec5(const Tvec3<DT>& v, const DT c, const DT t)");
00120     
00121     Superclass::_buffer[0] = v[0]; 
00122     Superclass::_buffer[1] = v[1];  
00123     Superclass::_buffer[2] = v[2]; 
00124     Superclass::_buffer[3] = c; 
00125     Superclass::_buffer[4] = t;
00126   }
00127   
00129   inline Tvec5(const Tvec4<DT>& v, const DT t)
00130   {
00131     ML_TRACE_IN_TIME_CRITICAL("Tvec5::Tvec5(const Tvec4<DT>& v, const DT t)");
00132     
00133     Superclass::_buffer[0] = v[0]; 
00134     Superclass::_buffer[1] = v[1]; 
00135     Superclass::_buffer[2] = v[2]; 
00136     Superclass::_buffer[3] = v[3]; 
00137     Superclass::_buffer[4] = t; 
00138   }
00140   
00141   //--------------------------------------------------------------------
00143 
00144   //--------------------------------------------------------------------
00146   inline void assign(const DT x, const DT y, const DT z, const DT c, const DT t)
00147   {
00148     ML_TRACE_IN_TIME_CRITICAL("Tvec5::assign(const DT x, const DT y, const DT z, const DT c, const DT t)");
00149     
00150     Superclass::_buffer[0] = x;
00151     Superclass::_buffer[1] = y;
00152     Superclass::_buffer[2] = z;
00153     Superclass::_buffer[3] = c;
00154     Superclass::_buffer[4] = t;
00155   }
00156   
00158   inline Tvec5<DT>& operator+=(const Tvec2<DT>& v)
00159   {
00160     ML_TRACE_IN_TIME_CRITICAL("Tvec5::operator+=(const Tvec2<DT>& v)");
00161     
00162     Superclass::_buffer[0] += v[0]; 
00163     Superclass::_buffer[1] += v[1];
00164     return *this;
00165   }
00166   
00168   inline Tvec5<DT>& operator+=(const Tvec3<DT>& v)
00169   {
00170     ML_TRACE_IN_TIME_CRITICAL("Tvec5::operator+=(const Tvec3<DT>& v)");
00171     
00172     Superclass::_buffer[0] += v[0]; 
00173     Superclass::_buffer[1] += v[1]; 
00174     Superclass::_buffer[2] += v[2];
00175     return *this;
00176   }
00177   
00179   inline Tvec5<DT>& operator+=(const Tvec4<DT>& v)
00180   {
00181     ML_TRACE_IN_TIME_CRITICAL("Tvec5::operator+=(const Tvec4<DT>& v)");
00182     
00183     Superclass::_buffer[0] += v[0]; 
00184     Superclass::_buffer[1] += v[1]; 
00185     Superclass::_buffer[2] += v[2]; 
00186     Superclass::_buffer[3] += v[3];
00187     return *this;
00188   }
00189   
00191   inline const Tvec3<DT> getVec3() const
00192   {
00193     ML_TRACE_IN_TIME_CRITICAL("Tvec5::getVec3() const");
00194     
00195     return Tvec3<DT>(Superclass::_buffer[0], 
00196                      Superclass::_buffer[1], 
00197                      Superclass::_buffer[2]);
00198   }
00199   
00201   inline const Tvec4<DT> getVec4() const
00202   {
00203     ML_TRACE_IN_TIME_CRITICAL("Tvec5::getVec4() const");
00204     
00205     return Tvec4<DT>(Superclass::_buffer[0], 
00206                      Superclass::_buffer[1], 
00207                      Superclass::_buffer[2], 
00208                      Superclass::_buffer[3]);
00209   }
00211 };
00212 
00214 #define _ML_VEC5_RC(i) a[i][0]*v[0] + a[i][1]*v[1] + a[i][2]*v[2] + a[i][3]*v[3] + a[i][4]*v[4]
00215 //-----------------------------------------------------------------------------------
00217 //-----------------------------------------------------------------------------------
00218 template <class DT>
00219 inline Tvec5<DT> operator*(const Tmat5<DT>& a, const Tvec5<DT>& v)
00220 {
00221   ML_TRACE_IN_TIME_CRITICAL("mlVector5.h: operator*(const Tmat5<DT>& a, const Tvec5<DT>& v)");
00222   
00223   return Tvec5<DT>(_ML_VEC5_RC(0), _ML_VEC5_RC(1), _ML_VEC5_RC(2), _ML_VEC5_RC(3), _ML_VEC5_RC(4));
00224 }
00225 #undef _ML_VEC5_RC
00226 
00227 //-----------------------------------------------------------------------------------
00229 //-----------------------------------------------------------------------------------
00230 template <class DT>
00231 inline Tvec5<DT> operator*(const Tvec5<DT>& v, const Tmat5<DT>& a)
00232 {
00233   ML_TRACE_IN_TIME_CRITICAL("mlVector5.h: operator*(const Tvec5<DT>& v, const Tmat5<DT>& a)");
00234   
00235   return a.transpose() * v;
00236 }
00237 
00238 
00239 //-----------------------------------------------------------------------------------
00241 
00242 //-----------------------------------------------------------------------------------
00244 typedef Tvec5<MLfloat>   Vector5f;
00246 typedef Tvec5<MLdouble>  Vector5d;
00248 typedef Tvec5<MLldouble> Vector5ld;
00250 typedef Tvec5<MLdouble>  Vector5;
00252 
00253 
00254 #ifdef ML_DEPRECATED
00255 
00256 
00257 
00258 
00259 ML_DEPRECATED typedef Tvec5<MLfloat>   vecf5;
00262 ML_DEPRECATED typedef Tvec5<MLdouble>  vecd5;
00265 ML_DEPRECATED typedef Tvec5<MLldouble> vecld5;
00268 ML_DEPRECATED typedef Tvec5<MLdouble> vec5;
00270 
00271 #endif // ML_DEPRECATED
00272 
00273 
00274 ML_LA_END_NAMESPACE
00275 
00276 #endif //of __mlVector5_H
00277