- Main Page
- Classes
- Files
- Related Pages

# matrix3.h

    00001 //
    00002 // matrix3.h
    00003 //
    00004 // Copyright (C) 1996 Limit Point Systems, Inc.
    00005 //
    00006 // Author: Curtis Janssen <cljanss@limitpt.com>
    00007 // Maintainer: LPS
    00008 //
    00009 // This file is part of the SC Toolkit.
    00010 //
    00011 // The SC Toolkit is free software; you can redistribute it and/or modify
    00012 // it under the terms of the GNU Library General Public License as published by
    00013 // the Free Software Foundation; either version 2, or (at your option)
    00014 // any later version.
    00015 //
    00016 // The SC Toolkit 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
    00019 // GNU Library General Public License for more details.
    00020 //
    00021 // You should have received a copy of the GNU Library General Public License
    00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
    00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00024 //
    00025 // The U.S. Government is granted a limited license as per AL 91-7.
    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 // Local Variables:
    00091 // mode: c++
    00092 // c-file-style: "CLJ"
    00093 // End: