rtcSMat4.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009
00003  * Robert Bosch LLC
00004  * Research and Technology Center North America
00005  * Palo Alto, California
00006  *
00007  * All rights reserved.
00008  *
00009  *------------------------------------------------------------------------------
00010  * project ....: Autonomous Technologies
00011  * file .......: SMat4.h
00012  * authors ....: Benjamin Pitzer
00013  * organization: Robert Bosch LLC
00014  * creation ...: 08/16/2006
00015  * modified ...: $Date: 2009-01-21 18:19:16 -0800 (Wed, 21 Jan 2009) $
00016  * changed by .: $Author: benjaminpitzer $
00017  * revision ...: $Revision: 14 $
00018  */
00019 #ifndef RTC_SMAT4_H
00020 #define RTC_SMAT4_H
00021 
00022 //== INCLUDES ==================================================================
00023 #include "rtc/rtcMath.h"
00024 #include "rtc/rtcVec4.h"
00025 #include "rtc/rtcSMat.h"
00026 
00027 //== NAMESPACES ================================================================
00028 namespace rtc {
00029 
00030 // Forward declarations
00031 template <class T, int M> class SMat; // MxM Square Matrix
00032 template <class T> class Vec4; // 4d Vector
00033 template <class T> class SMat4; // 4x4 Matrix
00034 
00039 template <class T>
00040 class SMat4: public SMat<T,4> {
00041 public:
00042   // Constructors
00043   SMat4();
00044   SMat4(const T* d);
00045   SMat4(const T diagVal);
00046   SMat4(const Vec4<T>& diagVec);
00047   SMat4(const Mat<T,4,4>& m);
00048   SMat4(const T x11, const T x12, const T x13, const T x14,
00049         const T x21, const T x22, const T x23, const T x24,
00050         const T x31, const T x32, const T x33, const T x34,
00051         const T x41, const T x42, const T x43, const T x44);
00052   SMat4(const Vec4<T>& q0,const Vec4<T>& q1,
00053   const Vec4<T>& q2,const Vec4<T>& q3);
00054 
00055 
00056   // Casting Operation
00057   template <class U> SMat4(const Mat<U,4,4>& m);
00058 
00059   // Named Constructors
00060   static SMat4<T> fromRows(const Vec4<T>& q0, const Vec4<T>& q1, const Vec4<T>& q2, const Vec4<T>& q3);
00061   static SMat4<T> fromCols(const Vec4<T>& q0, const Vec4<T>& q1, const Vec4<T>& q2, const Vec4<T>& q3);
00062 
00063   // Mutators
00064   void set(const T x11, const T x12, const T x13, const T x14,
00065            const T x21, const T x22, const T x23, const T x24,
00066            const T x31, const T x32, const T x33, const T x34,
00067            const T x41, const T x42, const T x43, const T x44);
00068   void setRows(const Vec4<T>& q0, const Vec4<T>& q1, const Vec4<T>& q2, const Vec4<T>& q3);
00069   void setCols(const Vec4<T>& q0, const Vec4<T>& q1, const Vec4<T>& q2, const Vec4<T>& q3);
00070 
00071   // Data
00072   using SMat<T,4>::x;
00073   using SMat<T,4>::set;
00074 };
00075 
00076 // Declare a few common typdefs
00077 typedef SMat4<bool> SMat4b;
00078 typedef SMat4<char> SMat4c;
00079 typedef SMat4<unsigned char> SMat4uc;
00080 typedef SMat4<int> SMat4i;
00081 typedef SMat4<float> SMat4f;
00082 typedef SMat4<double> SMat4d;
00083 
00084 //==============================================================================
00085 // SMat4<T>
00086 //==============================================================================
00087 
00088 // Constructors
00089 
00092 template <class T>
00093 inline SMat4<T>::SMat4() {}
00094 
00098 template <class T>
00099 inline SMat4<T>::SMat4(const T* d) : SMat<T,4>(d) {}
00100 
00104 template <class T>
00105 inline SMat4<T>::SMat4(const T diagVal) : SMat<T,4>(diagVal) {}
00106 
00110 template <class T>
00111 inline SMat4<T>::SMat4(const Vec4<T>& diagVec) : SMat<T,4>(diagVec) {}
00112 
00115 template <class T>
00116 inline SMat4<T>::SMat4(const Mat<T,4,4>& m) : SMat<T,4>(m) {}
00117 
00120 template <class T>
00121 inline SMat4<T>::SMat4(const T x11, const T x12, const T x13, const T x14,
00122      const T x21, const T x22, const T x23, const T x24,
00123      const T x31, const T x32, const T x33, const T x34,
00124      const T x41, const T x42, const T x43, const T x44) {
00125   set(x11, x12, x13, x14,
00126       x21, x22, x23, x24,
00127       x31, x32, x33, x34,
00128       x41, x42, x43, x44);
00129 }
00130 
00133 template <class T>
00134 inline SMat4<T>::SMat4(const Vec4<T>& q0,const Vec4<T>& q1,
00135      const Vec4<T>& q2, const Vec4<T>& q3) {
00136   setCols(q0,q1,q2,q3);
00137 }
00138 
00139 // Casting Operation
00140 
00143 template <class T> template <class U>
00144 inline SMat4<T>::SMat4(const Mat<U,4,4>& m) : SMat<T,4>(m) {}
00145 
00146 // Named Constructors
00147 
00150 template <class T>
00151 inline SMat4<T> SMat4<T>::fromRows(const Vec4<T>& q0, const Vec4<T>& q1,
00152            const Vec4<T>& q2, const Vec4<T>& q3) {
00153   SMat4<T> m;
00154   m.setRows(q0,q1,q2,q3);
00155   return m;
00156 }
00157 
00160 template <class T>
00161 inline SMat4<T> SMat4<T>::fromCols(const Vec4<T>& q0, const Vec4<T>& q1,
00162            const Vec4<T>& q2, const Vec4<T>& q3) {
00163   SMat4<T> m;
00164   m.setCols(q0,q1,q2,q3);
00165   return m;
00166 }
00167 
00168 // Mutators
00169 
00172 template <class T>
00173 inline void SMat4<T>::set(const T x11,const T x12,const T x13,const T x14,
00174         const T x21,const T x22,const T x23,const T x24,
00175         const T x31,const T x32,const T x33,const T x34,
00176         const T x41,const T x42,const T x43,const T x44){
00177   x[0] = x11; x[1] = x12; x[2] = x13; x[3] = x14;
00178   x[4] = x21; x[5] = x22; x[6] = x23; x[7] = x24;
00179   x[8] = x31; x[9] = x32; x[10] = x33; x[11] = x34;
00180   x[12] = x41; x[13] = x42; x[14] = x43; x[15] = x44;
00181 }
00182 
00185 template <class T>
00186 inline void SMat4<T>::setRows(const Vec4<T>& q0, const Vec4<T>& q1,
00187       const Vec4<T>& q2, const Vec4<T>& q3) {
00188   setRow(0,q0); setRow(1,q1); setRow(2,q2); setRow(3,q3);
00189 }
00190 
00193 template <class T>
00194 inline void SMat4<T>::setCols(const Vec4<T>& q0, const Vec4<T>& q1,
00195       const Vec4<T>& q2, const Vec4<T>& q3) {
00196   setCol(0,q0); setCol(1,q1); setCol(2,q2); setCol(3,q3);
00197 }
00198 
00199 //==============================================================================
00200 } // namespace rtc
00201 //==============================================================================
00202 #endif // RTC_SMAT4_H defined
00203 //==============================================================================
00204 


rtc
Author(s): Benjamin Pitzer
autogenerated on Thu Jan 2 2014 11:04:53