]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGColumnVector3.h
Initial revision.
[flightgear.git] / src / FDM / JSBSim / FGColumnVector3.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 FGCOLUMNVECTOR3_H
17 #define FGCOLUMNVECTOR3_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 #  if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
32      SG_USING_STD(ostream);
33      SG_USING_STD(istream);
34      SG_USING_STD(cerr);
35      SG_USING_STD(cout);
36      SG_USING_STD(endl);
37 #  endif
38 #else
39 #  include <string>
40 #  if defined(sgi) && !defined(__GNUC__)
41 #    include <fstream.h>
42 #    include <math.h>
43 #    include <iostream.h>
44 #  else
45 #    include <fstream>
46 #    include <cmath>
47 #    include <iostream>
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 "FGMatrix33.h"
58 #include "FGJSBBase.h"
59
60 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 DEFINITIONS
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
63
64 #define ID_COLUMNVECTOR3 "$Id$"
65
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 FORWARD DECLARATIONS
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69
70 class FGMatrix33;
71
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 DECLARATION: FGColumnVector3
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
76 class FGColumnVector3 : public FGJSBBase
77 {
78 public:
79   FGColumnVector3(void);
80   FGColumnVector3(int m);
81   FGColumnVector3(const FGColumnVector3& b);
82   ~FGColumnVector3(void);
83   
84   FGColumnVector3 operator=(const FGColumnVector3& b);
85   
86   FGColumnVector3 operator*(const double scalar);
87   FGColumnVector3 operator*(const FGColumnVector3& V);   // Cross product operator
88   FGColumnVector3 operator/(const double scalar);
89   FGColumnVector3 operator+(const FGColumnVector3& B); // must not return reference
90   FGColumnVector3 operator-(const FGColumnVector3& B);
91   
92   void operator-=(const FGColumnVector3 &B);
93   void operator+=(const FGColumnVector3 &B);
94   void operator*=(const FGColumnVector3 &B);
95   void operator*=(const double scalar);
96   void operator/=(const double scalar);
97
98   FGColumnVector3& operator<<(const float ff);
99
100   inline void InitMatrix(void) { data[1]=0; data[2]=0; data[3]=0; }
101   inline void InitMatrix(float ff) { data[1]=ff; data[2]=ff; data[3]=ff; }
102
103   float Magnitude(void);
104   FGColumnVector3 Normalize(void);
105
106   friend FGColumnVector3 operator*(const double scalar, const FGColumnVector3& A);
107   //friend FGColumnVector3 operator*(const FGMatrix33& M, FGColumnVector3& V);
108
109   friend ostream& operator<<(ostream& os, const FGColumnVector3& col);
110
111   inline double& operator()(int m) const { return data[m]; }
112
113   FGColumnVector3 multElementWise(const FGColumnVector3& V);
114
115 private:
116   double *data;
117   int rowCtr;
118   void Debug(void);
119 };
120
121 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 #endif