Main Page   Class Hierarchy   Compound List   File List   Compound Members  

matrixRT.h

00001 /*============================================================================
00002         File: matrixRT.h
00003      Purpose: Describes a rotation-translation matrix 
00004     Revision: $Id: matrixRT.h,v 1.2 2002/05/13 21:07:46 philosophil Exp $
00005   Created by: Philippe Lavoie          (3 Oct, 1996)
00006  Modified by: 
00007 
00008  Copyright notice:
00009           Copyright (C) 1996-1997 Philippe Lavoie
00010  
00011           This library is free software; you can redistribute it and/or
00012           modify it under the terms of the GNU Library General Public
00013           License as published by the Free Software Foundation; either
00014           version 2 of the License, or (at your option) any later version.
00015  
00016           This library is distributed in the hope that it will be useful,
00017           but WITHOUT ANY WARRANTY; without even the implied warranty of
00018           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019           Library General Public License for more details.
00020  
00021           You should have received a copy of the GNU Library General Public
00022           License along with this library; if not, write to the Free
00023           Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024 =============================================================================*/
00025 #ifndef _nurbs_matrixRT_h_
00026 #define _nurbs_matrixRT_h_
00027 
00028 #include "nurbs_global.h"
00029 #include "matrix.h"
00030 // Predefining every friend functions
00031 // This is required by latest ISO C++ draft
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 } // end namespace 
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

Generated on Tue Jun 24 13:26:56 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002