]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGColumnVector3.h
Encapsulate the interpolstion version of FGEnvironment and fix some bugs
[flightgear.git] / src / FDM / JSBSim / FGColumnVector3.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGColumnVector3.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 FGCOLUMNVECTOR3_H
15 #define FGCOLUMNVECTOR3_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 #else
35 #  include <string>
36 #  if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
37 #    include <fstream.h>
38 #    include <iostream.h>
39 #    include <math.h>
40 #  else
41 #    include <fstream>
42 #    include <iostream>
43 #    if defined(sgi) && !defined(__GNUC__)
44 #      include <math.h>
45 #    else
46 #      include <cmath>
47 #    endif
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 "FGJSBBase.h"
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 DEFINITIONS
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 #define ID_COLUMNVECTOR3 "$Id$"
64
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 FORWARD DECLARATIONS
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68
69 namespace JSBSim {
70
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 CLASS DOCUMENTATION
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74
75 /** This class implements a 3 dimensional vector.
76     @author Jon S. Berndt, Tony Peden, et. al.
77     @version $Id$
78 */
79
80 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 CLASS DECLARATION
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
83
84 class FGColumnVector3 : public FGJSBBase
85 {
86 public:
87   FGColumnVector3(void);
88   FGColumnVector3(double X, double Y, double Z);
89   FGColumnVector3(const FGColumnVector3& b);
90   ~FGColumnVector3(void);
91   
92   FGColumnVector3 operator=(const FGColumnVector3& b);
93   
94   FGColumnVector3 operator*(const double scalar);
95   FGColumnVector3 operator*(const FGColumnVector3& V);   // Cross product operator
96   FGColumnVector3 operator/(const double scalar);
97   FGColumnVector3 operator+(const FGColumnVector3& B); // must not return reference
98   FGColumnVector3 operator-(const FGColumnVector3& B);
99   
100   void operator-=(const FGColumnVector3 &B);
101   void operator+=(const FGColumnVector3 &B);
102   void operator*=(const FGColumnVector3 &B);
103   void operator*=(const double scalar);
104   void operator/=(const double scalar);
105
106   FGColumnVector3& operator<<(const double ff);
107
108   inline void InitMatrix(void) { data[1]=0; data[2]=0; data[3]=0; }
109   inline void InitMatrix(double ff) { data[1]=ff; data[2]=ff; data[3]=ff; }
110
111   double Magnitude(void);
112   FGColumnVector3 Normalize(void);
113
114   friend FGColumnVector3 operator*(const double scalar, const FGColumnVector3& A);
115
116   friend ostream& operator<<(ostream& os, const FGColumnVector3& col);
117
118   inline double operator()(int m) const { return data[m]; }
119   inline double& operator()(int m) { return data[m]; }
120
121   FGColumnVector3 multElementWise(const FGColumnVector3& V);
122
123 private:
124   double data[4];
125   int rowCtr;
126   void Debug(int from);
127 };
128 }
129 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 #endif