00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _THREE_MATRIX_H_
00019 #define _THREE_MATRIX_H_
00020
00021 #include "Three_Vector.h"
00022
00023 namespace Vamos_Geometry
00024 {
00025
00026 class Singular_Matrix {};
00027
00028 class Three_Matrix
00029 {
00030 public:
00031 double m_mat [3][3];
00032 double m_e_vec [3][3];
00033 double m_e_val [3];
00034
00035
00036 void diagonalize ();
00037
00038
00039 void set_diagonal (double diag);
00040
00041
00042 void copy_in (const Three_Matrix& mat);
00043
00044
00045
00046 Three_Matrix (double diag = 0.0);
00047
00048 Three_Matrix (const double [3][3]);
00049
00050 Three_Matrix (const Three_Matrix& mat);
00051
00052 Three_Matrix& operator = (const Three_Matrix& mat);
00053
00054 double* operator [] (int index) { return m_mat [index]; }
00055 const double* operator [] (int index) const { return m_mat [index]; }
00056
00057
00058 Three_Vector unit (int index) const;
00059
00060
00061 void identity ();
00062
00063 void zero ();
00064
00065
00066 void rotate (const Three_Vector& delta_theta);
00067
00068
00069 Three_Matrix transpose () const;
00070
00071
00072 Three_Matrix invert () const;
00073
00074
00075
00076 Three_Matrix eigen (Three_Vector* e_val = 0);
00077
00078
00079 Three_Matrix& operator *= (const Three_Matrix& mat);
00080 Three_Matrix& operator *= (double);
00081 };
00082
00083
00084 const Three_Matrix operator * (const Three_Matrix&, const Three_Matrix&);
00085
00086 const inline Three_Vector operator * (const Three_Matrix& mat,
00087 const Three_Vector& vec)
00088 {
00089 return Three_Vector
00090 (vec [0] * mat [0][0] + vec [1] * mat [0][1] + vec [2] * mat [0][2],
00091 vec [0] * mat [1][0] + vec [1] * mat [1][1] + vec [2] * mat [1][2],
00092 vec [0] * mat [2][0] + vec [1] * mat [2][1] + vec [2] * mat [2][2]);
00093 }
00094 const Three_Vector operator * (const Three_Vector&, const Three_Matrix&);
00095
00096 const Three_Matrix operator * (double, const Three_Matrix&);
00097 const Three_Matrix operator * (const Three_Matrix&, double);
00098
00099
00100 std::ostream& operator << (std::ostream& os, Three_Matrix mat);
00101
00102
00103
00104 void euler_angles (const Three_Matrix& mat,
00105 double* phi, double* theta, double* psi);
00106 }
00107
00108 #endif