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
00026
00027
00028 #ifndef _math_scmat_matrix3_h
00029 #define _math_scmat_matrix3_h
00030 #ifdef __GNUC__
00031 #pragma interface
00032 #endif
00033
00034 #include <iostream>
00035 #include <math.h>
00036
00037 #include <math/scmat/vector3.h>
00038 class RefSCmatrix;
00039
00040 class SCMatrix3
00041 {
00042 private:
00043 double _m[9];
00044 public:
00045 SCMatrix3() {}
00046 SCMatrix3(const SCMatrix3&);
00047 #if 0
00048 SCMatrix3(const RefSCMatrix3&);
00049 #endif
00050 SCMatrix3(double x[9]);
00051 SCMatrix3(const SCVector3&p1, const SCVector3&p2, const SCVector3&p3);
00052 ~SCMatrix3() {}
00053 SCMatrix3& operator=(const SCMatrix3&);
00054 SCMatrix3 operator*(double) const;
00055 SCMatrix3 operator*(const SCMatrix3&) const;
00056 SCVector3 operator*(const SCVector3&v) const {
00057 SCVector3 result;
00058 result._v[0] = _m[0+3*0]*v._v[0]+_m[0+3*1]*v._v[1]+_m[0+3*2]*v._v[2];
00059 result._v[1] = _m[1+3*0]*v._v[0]+_m[1+3*1]*v._v[1]+_m[1+3*2]*v._v[2];
00060 result._v[2] = _m[2+3*0]*v._v[0]+_m[2+3*1]*v._v[1]+_m[2+3*2]*v._v[2];
00061 return result;
00062 }
00063 SCMatrix3 operator+(const SCMatrix3&) const;
00064 SCMatrix3 operator-(const SCMatrix3&) const;
00065 double& elem(int i, int j) { return _m[i+3*j]; }
00066 const double& elem(int i, int j) const { return _m[i+3*j]; }
00067 double& elem(int i) { return _m[i]; }
00068 const double& elem(int i) const { return _m[i]; }
00069 double& operator[] (int i) { return _m[i]; }
00070 const double& operator[] (int i) const { return _m[i]; }
00071 double& operator() (int i, int j) { return _m[i+3*j]; }
00072 const double& operator() (int i, int j) const { return _m[i+3*j]; }
00073 const double* data() const { return _m; }
00074 void print(std::ostream& =ExEnv::out()) const;
00075 };
00076 SCMatrix3 operator*(double,const SCMatrix3&);
00077 SCMatrix3 rotation_mat(const SCVector3&, const SCVector3&, double theta);
00078 SCMatrix3 rotation_mat(const SCVector3&, const SCVector3&);
00079 SCMatrix3 rotation_mat(const SCVector3&, double theta);
00080 SCMatrix3 reflection_mat(const SCVector3&);
00081 inline int delta(int i, int j) { return i==j; }
00082
00083 #endif
00084
00085
00086
00087
00088