]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGMatrix33.h
Curt Olson:
[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__) && (_COMPILER_VERSION < 740)
39      include <fstream.h>
40      include <iostream.h>
41 #    include <math.h>
42 #  else
43 #    include <fstream>
44 #    include <iostream>
45 #    if defined(sgi) && !defined(__GNUC__)
46 #      include <math.h>
47 #    else
48 #      include <cmath>
49 #    endif
50 #    include <iostream>
51      using std::ostream;
52      using std::istream;
53      using std::cerr;
54      using std::cout;
55      using std::endl;
56 #  endif
57    using std::string;
58 #endif
59
60 #include "FGColumnVector3.h"
61 #include "FGJSBBase.h"
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 DEFINITIONS
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67 #define ID_MATRIX33 "$Id$"
68
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 FORWARD DECLARATIONS
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72
73 namespace JSBSim {
74
75 class FGColumnVector3;
76
77 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 CLASS DOCUMENTATION
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
80
81 /** Exception convenience class.
82   */
83
84 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 DECLARATION: MatrixException
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
87
88 class MatrixException : public FGJSBBase
89 {
90 public:
91   string Message;
92 };
93
94 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 CLASS DOCUMENTATION
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
97
98 /** Handles matrix math operations.
99   */
100
101 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102 DECLARATION: FGMatrix33
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
104
105 class FGMatrix33 : public FGJSBBase
106 {
107 public:
108   FGMatrix33(void);
109   FGMatrix33(int r, int c);
110   FGMatrix33(const FGMatrix33& A);
111   ~FGMatrix33(void);
112
113   FGMatrix33& operator=(const FGMatrix33& A);
114   inline double operator()(unsigned int row, unsigned int col) const {return data[row][col];}
115   inline double& operator()(unsigned int row, unsigned int col) {return data[row][col];}
116
117   FGColumnVector3 operator*(const FGColumnVector3& Col);
118
119   inline unsigned int Rows(void) const { return 3; }
120   inline unsigned int Cols(void) const { return 3; }
121
122   void T(void);
123   void InitMatrix(void);
124   void InitMatrix(double value);
125   
126   //friend FGMatrix33 operator*(double scalar,FGMatrix33& A);
127
128   FGMatrix33 operator-(const FGMatrix33& B);
129   FGMatrix33 operator+(const FGMatrix33& B);
130   FGMatrix33 operator*(const FGMatrix33& B);
131   FGMatrix33 operator*(const double scalar);
132   FGMatrix33 operator/(const double scalar);
133   FGMatrix33& operator<<(const double ff);
134
135   friend ostream& operator<<(ostream& os, const FGMatrix33& M);
136   friend istream& operator>>(istream& is, FGMatrix33& M);
137
138   void operator-=(const FGMatrix33 &B);
139   void operator+=(const FGMatrix33 &B);
140   void operator*=(const FGMatrix33 &B);
141   void operator*=(const double scalar);
142   void operator/=(const double scalar);
143
144 protected:
145   double data[4][4];
146
147 private:
148   void TransposeSquare(void);
149   unsigned int rowCtr, colCtr;
150   void Debug(int from);
151 };
152 }
153 #endif