]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGMatrix33.h
JSBSim updates. This update changes the file format, so an update of the base
[flightgear.git] / src / FDM / JSBSim / FGMatrix33.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGMatrix33.h
4 Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
5 Date started: Unknown
6
7 HISTORY
8 --------------------------------------------------------------------------------
9 ??/??/??   TP   Created
10 03/16/2000 JSB  Added exception throwing
11
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 SENTRY
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
15
16 #ifndef FGMATRIX33_H
17 #define FGMATRIX33_H
18
19 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 INCLUDES
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
22
23 #include <stdlib.h>
24 #ifdef FGFS
25 #  include <math.h>
26 #  include <simgear/compiler.h>
27 #  include STL_STRING
28 #  include STL_FSTREAM
29 #  include STL_IOSTREAM
30    SG_USING_STD(string);
31 #  if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
32      SG_USING_STD(ostream);
33      SG_USING_STD(istream);
34      SG_USING_STD(cerr);
35      SG_USING_STD(cout);
36      SG_USING_STD(endl);
37 #  endif
38 #else
39 #  include <string>
40 #  if defined(sgi) && !defined(__GNUC__)
41 #    include <fstream.h>
42 #    include <math.h>
43 #    include <iostream.h>
44 #  else
45 #    include <fstream>
46 #    include <cmath>
47 #    include <iostream>
48      using std::ostream;
49      using std::istream;
50      using std::cerr;
51      using std::cout;
52      using std::endl;
53 #  endif
54    using std::string;
55 #endif
56
57 #include "FGColumnVector3.h"
58 #include "FGJSBBase.h"
59
60 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 DEFINITIONS
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
63
64 #define ID_MATRIX33 "$Id$"
65
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 FORWARD DECLARATIONS
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69
70 class FGColumnVector3;
71
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 DECLARATION: MatrixException
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
76 class MatrixException : public FGJSBBase
77 {
78 public:
79   string Message;
80 };
81
82 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 DECLARATION: FGMatrix33
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
85
86 class FGMatrix33 : public FGJSBBase
87 {
88 public:
89   FGMatrix33(void);
90   FGMatrix33(int r, int c);
91   FGMatrix33(const FGMatrix33& A);
92   ~FGMatrix33(void);
93
94   FGMatrix33& operator=(const FGMatrix33& A);
95   inline double operator()(unsigned int row, unsigned int col) const {return data[row][col];}
96   inline double& operator()(unsigned int row, unsigned int col) {return data[row][col];}
97
98   FGColumnVector3 operator*(const FGColumnVector3& Col);
99
100   inline unsigned int Rows(void) const { return 3; }
101   inline unsigned int Cols(void) const { return 3; }
102
103   void T(void);
104   void InitMatrix(void);
105   void InitMatrix(double value);
106   
107   //friend FGMatrix33 operator*(double scalar,FGMatrix33& A);
108
109   FGMatrix33 operator-(const FGMatrix33& B);
110   FGMatrix33 operator+(const FGMatrix33& B);
111   FGMatrix33 operator*(const FGMatrix33& B);
112   FGMatrix33 operator*(const double scalar);
113   FGMatrix33 operator/(const double scalar);
114   FGMatrix33& operator<<(const double ff);
115
116   friend ostream& operator<<(ostream& os, const FGMatrix33& M);
117   friend istream& operator>>(istream& is, FGMatrix33& M);
118
119   void operator-=(const FGMatrix33 &B);
120   void operator+=(const FGMatrix33 &B);
121   void operator*=(const FGMatrix33 &B);
122   void operator*=(const double scalar);
123   void operator/=(const double scalar);
124
125 protected:
126   double data[4][4];
127
128 private:
129   void TransposeSquare(void);
130   unsigned int rowCtr, colCtr;
131   void Debug(int from);
132 };
133
134 #endif