]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGColumnVector4.h
Removed FGMatrix.* because it is no longer used by JSBSim.
[flightgear.git] / src / FDM / JSBSim / FGColumnVector4.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGColumnVector4.h
4 Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
5 Date started: Unknown
6
7 HISTORY
8 --------------------------------------------------------------------------------
9
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 SENTRY
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
13
14 #ifndef FGCOLUMNVECTOR4_H
15 #define FGCOLUMNVECTOR4_H
16
17 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18 INCLUDES
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
20
21 #include <stdlib.h>
22 #ifdef FGFS
23 #  include <math.h>
24 #  include <simgear/compiler.h>
25 #  include STL_STRING
26 #  include STL_FSTREAM
27 #  include STL_IOSTREAM
28    SG_USING_STD(string);
29 #  if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
30      SG_USING_STD(ostream);
31      SG_USING_STD(istream);
32      SG_USING_STD(cerr);
33      SG_USING_STD(cout);
34      SG_USING_STD(endl);
35 #  endif
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 "FGJSBBase.h"
56
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 DEFINITIONS
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60
61 #define ID_COLUMNVECTOR4 "$Id$"
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 FORWARD DECLARATIONS
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 DECLARATION: FGColumnVector4
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
70
71 class FGColumnVector4 : public FGJSBBase
72 {
73 public:
74   FGColumnVector4(void);
75   FGColumnVector4(double A, double B, double C, double D);
76   FGColumnVector4(const FGColumnVector4& b);
77   ~FGColumnVector4(void);
78   
79   FGColumnVector4 operator=(const FGColumnVector4& b);
80   
81   FGColumnVector4 operator*(const double scalar);
82   FGColumnVector4 operator/(const double scalar);
83   FGColumnVector4 operator+(const FGColumnVector4& B); // must not return reference
84   FGColumnVector4 operator-(const FGColumnVector4& B);
85   
86   void operator-=(const FGColumnVector4 &B);
87   void operator+=(const FGColumnVector4 &B);
88   void operator*=(const double scalar);
89   void operator/=(const double scalar);
90   
91   inline double operator()(int m) const { return data[m]; }
92   inline double& operator()(int m) { return data[m]; }
93   
94   FGColumnVector4& operator<<(const double ff);
95
96   inline void InitMatrix(void) { data[1]=0; data[2]=0; data[3]=0; data[4]=0; }
97   inline void InitMatrix(double ff) { data[1]=ff; data[2]=ff; data[3]=ff; data[4]=ff;}
98
99   double Magnitude(void);
100   FGColumnVector4 Normalize(void);
101
102   friend FGColumnVector4 operator*(const double scalar, const FGColumnVector4& A);
103
104   friend ostream& operator<<(ostream& os, FGColumnVector4& col);
105
106
107   FGColumnVector4 multElementWise(const FGColumnVector4& V);
108
109 private:
110   double data[5];
111   int rowCtr;
112   void Debug(int from);
113 };
114
115 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 #endif
117