]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGColumnVector4.h
Rob Deters: UIUC updates from March 1, 2004.
[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    SG_USING_STD(ostream);
30    SG_USING_STD(istream);
31    SG_USING_STD(cerr);
32    SG_USING_STD(cout);
33    SG_USING_STD(endl);
34 //   SG_USING_STD(sqrt);
35 #else
36 #  include <string>
37 #  if defined (sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
38 #    include <fstream.h>
39 #    include <iostream.h>
40 #    include <math.h>
41 #  else
42 #    include <fstream>
43 #  if defined (sgi) && !defined(__GNUC__)
44 #    include <math.h>
45 #  else
46 #    include <cmath>
47 #  endif
48 #    include <iostream>
49      using std::ostream;
50      using std::istream;
51      using std::cerr;
52      using std::cout;
53      using std::endl;
54      using std::sqrt;
55 #  endif
56    using std::string;
57 #endif
58
59 #include "FGJSBBase.h"
60
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 DEFINITIONS
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
65 #define ID_COLUMNVECTOR4 "$Id$"
66
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 FORWARD DECLARATIONS
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
70
71 namespace JSBSim {
72
73 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 CLASS DOCUMENTATION
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
76
77 /** This class implements a 4 dimensional vector.
78     @author Jon S. Berndt, Tony Peden, et. al.
79     @version $Id$
80 */
81
82 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 CLASS DECLARATION
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
85
86 class FGColumnVector4 : public FGJSBBase
87 {
88 public:
89   FGColumnVector4(void);
90   FGColumnVector4(double A, double B, double C, double D);
91   FGColumnVector4(const FGColumnVector4& b);
92   ~FGColumnVector4(void);
93
94   FGColumnVector4 operator=(const FGColumnVector4& b);
95
96   FGColumnVector4 operator*(const double scalar);
97   FGColumnVector4 operator/(const double scalar);
98   FGColumnVector4 operator+(const FGColumnVector4& B); // must not return reference
99   FGColumnVector4 operator-(const FGColumnVector4& B);
100
101   void operator-=(const FGColumnVector4 &B);
102   void operator+=(const FGColumnVector4 &B);
103   void operator*=(const double scalar);
104   void operator/=(const double scalar);
105
106   inline double operator()(int m) const { return data[m]; }
107   inline double& operator()(int m) { return data[m]; }
108
109   FGColumnVector4& operator<<(const double ff);
110
111   inline void InitMatrix(void) { data[1]=0; data[2]=0; data[3]=0; data[4]=0; }
112   inline void InitMatrix(double ff) { data[1]=ff; data[2]=ff; data[3]=ff; data[4]=ff;}
113
114   double Magnitude(void);
115   FGColumnVector4 Normalize(void);
116
117   friend FGColumnVector4 operator*(const double scalar, const FGColumnVector4& A);
118
119   friend ostream& operator<<(ostream& os, FGColumnVector4& col);
120
121
122   FGColumnVector4 multElementWise(const FGColumnVector4& V);
123
124 private:
125   double data[5];
126   int rowCtr;
127   void Debug(int from);
128 };
129 }
130 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131 #endif
132