00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _nurbs_matrixRT_h_
00026 #define _nurbs_matrixRT_h_
00027
00028 #include "nurbs_global.h"
00029 #include "matrix.h"
00030
00031
00032
00035 namespace PLib {
00036 template <class T> class MatrixRT ;
00037
00038 template <class T> MatrixRT<T> operator*(const MatrixRT<T>&,const MatrixRT<T>&) ;
00039
00040
00051 template <class T>
00052 class MatrixRT : public Matrix<T> {
00053 public:
00054 MatrixRT(T ax, T ay, T az, T x, T y, T z) ;
00055 MatrixRT() ;
00056 MatrixRT(T* p) ;
00057 MatrixRT(const Matrix<T>& plM ) ;
00058
00059 MatrixRT<T>& rotate(T ax,T ay, T az);
00060 MatrixRT<T>& rotateXYZ(T ax,T ay, T az);
00061 MatrixRT<T>& translate(T x, T y, T z) ;
00062 MatrixRT<T>& scale(T x, T y, T z) ;
00063
00065 MatrixRT<T>& rotateDeg(T ax, T ay, T az) { return rotate(T(ax*M_PI/180.0),T(ay*M_PI/180.0),T(az*M_PI/180.0)) ; }
00066
00068 MatrixRT<T>& rotateDegXYZ(T ax, T ay, T az) { return rotateXYZ(T(ax*M_PI/180.0),T(ay*M_PI/180.0),T(az*M_PI/180.0)) ; }
00069
00070 MatrixRT<T>& operator=(const Matrix<T>& M) ;
00071 MatrixRT<T>& operator=(const MatrixRT<T>& M) ;
00072
00073 #ifdef HAVE_ISO_FRIEND_DECL
00074 friend MatrixRT<T> operator* <>(const MatrixRT<T>&,const MatrixRT<T>&) ;
00075 #else
00076 friend MatrixRT<T> operator* (const MatrixRT<T>&,const MatrixRT<T>&) ;
00077 #endif
00078
00079 protected:
00081 int created ;
00082 };
00083
00084
00085 #ifdef HAVE_TEMPLATE_OF_TEMPLATE
00086 template <int N>
00087 inline HPoint_nD<float,N> operator*(const MatrixRT<double>& M, const HPoint_nD<float,N>& P){
00088 HPoint_nD<float,N> P2 ;
00089
00090 P2.x() = float(M(0,0)*(double)P.x() + M(0,1)*(double)P.y() + M(0,2)*(double)P.z() + M(0,3)*(double)P.w()) ;
00091 P2.y() = float(M(1,0)*(double)P.x() + M(1,1)*(double)P.y() + M(1,2)*(double)P.z() + M(1,3)*(double)P.w()) ;
00092 P2.z() = float(M(2,0)*(double)P.x() + M(2,1)*(double)P.y() + M(2,2)*(double)P.z() + M(2,3)*(double)P.w()) ;
00093 P2.w() = float(M(3,0)*(double)P.x() + M(3,1)*(double)P.y() + M(3,2)*(double)P.z() + M(3,3)*(double)P.w()) ;
00094
00095 return P2 ;
00096 }
00097 #else
00098
00099 inline HPoint_nD<float,2> operator*(const MatrixRT<double>& M, const HPoint_nD<float,2>& P){
00100 HPoint_nD<float,2> P2 ;
00101
00102 P2.x() = float(M(0,0)*(double)P.x() + M(0,1)*(double)P.y() + M(0,2)*(double)P.z() + M(0,3)*(double)P.w()) ;
00103 P2.y() = float(M(1,0)*(double)P.x() + M(1,1)*(double)P.y() + M(1,2)*(double)P.z() + M(1,3)*(double)P.w()) ;
00104 P2.z() = float(M(2,0)*(double)P.x() + M(2,1)*(double)P.y() + M(2,2)*(double)P.z() + M(2,3)*(double)P.w()) ;
00105 P2.w() = float(M(3,0)*(double)P.x() + M(3,1)*(double)P.y() + M(3,2)*(double)P.z() + M(3,3)*(double)P.w()) ;
00106
00107 return P2 ;
00108 }
00109
00110
00111 inline HPoint_nD<float,3> operator*(const MatrixRT<double>& M, const HPoint_nD<float,3>& P){
00112 HPoint_nD<float,3> P2 ;
00113
00114 P2.x() = float(M(0,0)*(double)P.x() + M(0,1)*(double)P.y() + M(0,2)*(double)P.z() + M(0,3)*(double)P.w()) ;
00115 P2.y() = float(M(1,0)*(double)P.x() + M(1,1)*(double)P.y() + M(1,2)*(double)P.z() + M(1,3)*(double)P.w()) ;
00116 P2.z() = float(M(2,0)*(double)P.x() + M(2,1)*(double)P.y() + M(2,2)*(double)P.z() + M(2,3)*(double)P.w()) ;
00117 P2.w() = float(M(3,0)*(double)P.x() + M(3,1)*(double)P.y() + M(3,2)*(double)P.z() + M(3,3)*(double)P.w()) ;
00118
00119 return P2 ;
00120 }
00121 #endif
00122
00123 template <class T, int N> HPoint_nD<T,N> operator*(const MatrixRT<T>&,const HPoint_nD<T,N>&);
00124 template <class T, int N> Point_nD<T,N> operator*(const MatrixRT<T>&,const Point_nD<T,N>&);
00125
00126
00127
00128 }
00129
00130 typedef PLib::MatrixRT<float> MatrixRT_FLOAT ;
00131 typedef PLib::MatrixRT<double> MatrixRT_DOUBLE ;
00132 typedef PLib::MatrixRT<float> MatrixRTf ;
00133 typedef PLib::MatrixRT<double> MatrixRTd ;
00134
00135 #ifdef INCLUDE_TEMPLATE_SOURCE
00136 #include "matrixRT.cpp"
00137 #endif
00138
00139
00140 #endif