]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_flapdata.h
Provide a better(?) solution to the windows GDI problem
[flightgear.git] / src / FDM / UIUCModel / uiuc_flapdata.h
1 /*flapdata.h
2 This is the interface definition file for the structure that
3 holds the flapping data.
4 Written by Theresa Robinson
5 robinst@ecf.toronto.edu
6 */
7
8 #ifndef _FLAPDATA_H
9 #define _FLAPDATA_H
10 #include <cstdio>
11 #include <fstream>
12 #include <simgear/compiler.h>
13 #include "uiuc_warnings_errors.h"
14 using namespace std;
15 //#include "uiuc_aircraft.h"
16
17 class flapStruct {
18 private:
19         double Lift,Thrust,Inertia,Moment;
20 public:
21         flapStruct();
22         flapStruct(const flapStruct &rhs);
23         flapStruct(double newLift, double newThrust, double newMoment, double newInertia);
24         double getLift() const;
25         double getThrust() const;
26         double getInertia() const;
27         double getMoment() const;
28 };
29
30
31 class FlapData {
32
33         //class variables
34         private:
35
36                 //the following are the arrays of increasing
37                 //data values that were used to generate the lift, thrust
38                 //pitch and inertial values
39                 double* alphaArray;        //angle of attack
40                 double* speedArray;                      //airspeed at the wing
41                 double* freqArray;         //flapping frequency
42                 double* phiArray;
43                 //the following four tables are generated (e.g. by FullWing)
44                 //using the data in the previous three arrays
45                 double**** liftTable;            //4D array: holds the lift data
46                 double**** thrustTable;          //4D array: holds the thrust data
47                 double**** momentTable;      //4D array: holds the pitching moment data
48                 double**** inertiaTable;    //4D array: holds the inertia data
49
50                 //The values in the tables and arrays are directly related through
51                 //their indices, in the following way:
52                 //For alpha=alphaArray[i], speed=speedArray[j] and freq=freqArray[k]
53                 //phi=phiArray[l]
54                 //the lift is equal to liftTable[i][j][k][l]
55                 int alphaLength, speedLength, freqLength, phiLength;
56                 int lastAlphaIndex, lastSpeedIndex, lastFreqIndex, lastPhiIndex;
57                 //since we're assuming the angle of attack, velocity, and frequency
58                 //don't change much between calls to flap, we keep the last indices
59                 //as a good guess of where to start searching next time
60
61         //public methods
62         public:
63                 //Constructors:
64                         //The default constructor:
65                         //Just sets the arrays to null and the guesses to zero
66                         FlapData();
67                         //A constructor that takes a file name:
68                         //Opens that file and fills all the arrays from it
69                         //sets the guesses to zero for the speed and halfway
70                         //along the array for the alpha and frequency
71                         FlapData(const char* filename);
72                 //The destructor:
73                 //Frees all memory associated with this object
74                 ~FlapData();
75                 //An initialization function that does the same thing
76                 //as the second constructor
77                 //returns zero if it was successful
78                 int init(const char* filename);
79                 //A function that returns the interpolated values
80                 //for all four associated numbers
81                 //given the angle of attack, speed, and flapping frequency
82                 flapStruct flapper(double alpha, double speed, double frequency, double phi);
83         //private methods
84         private:
85                 //A function that returns an index i such that
86                 // array[i] < value < array[i+1]
87                 //The function returns -1 if
88                 // (value < array[0]) OR (value > array[n-1])
89                 //(i.e. the value is not within the bounds of the array)
90                 //It performs a linear search starting at LastIndex
91                 int findIndex(double array[], double n, double value, int LastIndex);
92                 //A function that performs a linear interpolation based on the
93                 //eight points surrounding the value required
94                 double interpolate(double**** table, int alphaIndex, int speedIndex, int freqIndex, int phiIndex, double alpha, double speed, double freq, double phi2);
95                 //A function that performs a linear interpolation based on the two nearest points
96                 double interpolate(double x1, double y1, double x2, double y2, double x);
97                 //A function called by init that reads in the file
98                 //of the correct format and stores it in the arrays and tables
99                 int readIn(ifstream* f);
100 };
101
102 #endif