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
00039 namespace sc {
00040
00041 class RefSCmatrix;
00042
00043 class SCMatrix3
00044 {
00045 private:
00046 double _m[9];
00047 public:
00048 SCMatrix3() {}
00049 SCMatrix3(const SCMatrix3&);
00050 #if 0
00051 SCMatrix3(const RefSCMatrix3&);
00052 #endif
00053 SCMatrix3(double x[9]);
00054 SCMatrix3(const SCVector3&p1, const SCVector3&p2, const SCVector3&p3);
00055 ~SCMatrix3() {}
00056 SCMatrix3& operator=(const SCMatrix3&);
00057 SCMatrix3 operator*(double) const;
00058 SCMatrix3 operator*(const SCMatrix3&) const;
00059 SCVector3 operator*(const SCVector3&v) const {
00060 SCVector3 result;
00061 result._v[0] = _m[0+3*0]*v._v[0]+_m[0+3*1]*v._v[1]+_m[0+3*2]*v._v[2];
00062 result._v[1] = _m[1+3*0]*v._v[0]+_m[1+3*1]*v._v[1]+_m[1+3*2]*v._v[2];
00063 result._v[2] = _m[2+3*0]*v._v[0]+_m[2+3*1]*v._v[1]+_m[2+3*2]*v._v[2];
00064 return result;
00065 }
00066 SCMatrix3 operator+(const SCMatrix3&) const;
00067 SCMatrix3 operator-(const SCMatrix3&) const;
00068 double& elem(int i, int j) { return _m[i+3*j]; }
00069 const double& elem(int i, int j) const { return _m[i+3*j]; }
00070 double& elem(int i) { return _m[i]; }
00071 const double& elem(int i) const { return _m[i]; }
00072 double& operator[] (int i) { return _m[i]; }
00073 const double& operator[] (int i) const { return _m[i]; }
00074 double& operator() (int i, int j) { return _m[i+3*j]; }
00075 const double& operator() (int i, int j) const { return _m[i+3*j]; }
00076 const double* data() const { return _m; }
00077 void print(std::ostream& =ExEnv::out0()) const;
00078 };
00079 SCMatrix3 operator*(double,const SCMatrix3&);
00080 SCMatrix3 rotation_mat(const SCVector3&, const SCVector3&, double theta);
00081 SCMatrix3 rotation_mat(const SCVector3&, const SCVector3&);
00082 SCMatrix3 rotation_mat(const SCVector3&, double theta);
00083 SCMatrix3 reflection_mat(const SCVector3&);
00084 inline int delta(int i, int j) { return i==j; }
00085
00086 }
00087
00088 #endif
00089
00090
00091
00092
00093