]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGMatrix33.h
Adds a basic FDM model for LaRCsim debugging purposes.
[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    SG_USING_STD(ostream);
32    SG_USING_STD(istream);
33    SG_USING_STD(cerr);
34    SG_USING_STD(cout);
35    SG_USING_STD(endl);
36 #else
37 #  include <string>
38 #  if defined(sgi) && !defined(__GNUC__)
39 #    include <fstream.h>
40 #    include <math.h>
41 #    include <iostream.h>
42 #  else
43 #    include <fstream>
44 #    include <cmath>
45 #    include <iostream>
46      using std::ostream;
47      using std::istream;
48      using std::cerr;
49      using std::cout;
50      using std::endl;
51 #  endif
52    using std::string;
53 #endif
54
55 #include "FGColumnVector3.h"
56 #include "FGJSBBase.h"
57
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 DEFINITIONS
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62 #define ID_MATRIX33 "$Id$"
63
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 FORWARD DECLARATIONS
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67
68 namespace JSBSim {
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