2001-03-30 03:08:44 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
Header: FGTable.h
|
|
|
|
Author: Jon S. Berndt
|
|
|
|
Date started: 1/9/2001
|
|
|
|
|
|
|
|
------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) --------------
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Further information about the GNU General Public License can also be found on
|
|
|
|
the world wide web at http://www.gnu.org.
|
|
|
|
|
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
JSB 1/9/00 Created
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
SENTRY
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
#ifndef FGTABLE_H
|
|
|
|
#define FGTABLE_H
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
INCLUDES
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
#include "FGConfigFile.h"
|
2001-10-05 20:19:59 +00:00
|
|
|
#include "FGJSBBase.h"
|
2001-03-30 03:08:44 +00:00
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
DEFINITIONS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
#define ID_TABLE "$Id$"
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
FORWARD DECLARATIONS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS DOCUMENTATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/** Lookup table class.
|
|
|
|
Models a lookup table for use in FGCoefficient, FGPropeller, etc.
|
|
|
|
@author Jon S. Berndt
|
|
|
|
@version $Id$
|
|
|
|
@see FGCoefficient
|
|
|
|
@see FGPropeller
|
2002-04-06 16:03:16 +00:00
|
|
|
@see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGTable.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
|
|
|
|
Header File </a>
|
|
|
|
@see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGTable.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
|
|
|
|
Source File </a>
|
2001-03-30 03:08:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS DECLARATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
class FGTable : public FGJSBBase
|
|
|
|
{
|
2001-03-30 03:08:44 +00:00
|
|
|
public:
|
|
|
|
~FGTable();
|
|
|
|
FGTable(int nRows);
|
|
|
|
FGTable(int nRows, int nCols);
|
2001-11-20 22:34:24 +00:00
|
|
|
double GetValue(double key);
|
|
|
|
double GetValue(double rowKey, double colKey);
|
2001-03-30 03:08:44 +00:00
|
|
|
/** Read the table in.
|
|
|
|
Data in the config file should be in matrix format with the row
|
|
|
|
independents as the first column and the column independents in
|
|
|
|
the first row. The implication of this layout is that there should
|
|
|
|
be no value in the upper left corner of the matrix e.g:
|
|
|
|
<pre>
|
|
|
|
0 10 20 30 ...
|
|
|
|
-5 1 2 3 4 ...
|
|
|
|
...
|
|
|
|
</pre>
|
|
|
|
*/
|
|
|
|
void operator<<(FGConfigFile&);
|
2001-10-29 18:25:19 +00:00
|
|
|
FGTable& operator<<(const double n);
|
2001-11-20 22:34:24 +00:00
|
|
|
FGTable& operator<<(const int n);
|
|
|
|
// FGTable& operator<<(const double n);
|
|
|
|
inline double GetElement(int r, int c) {return Data[r][c];}
|
2001-03-30 03:08:44 +00:00
|
|
|
void Print(void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum type {tt1D, tt2D} Type;
|
2001-11-20 22:34:24 +00:00
|
|
|
double** Data;
|
2001-03-30 03:08:44 +00:00
|
|
|
int nRows, nCols;
|
2001-12-03 22:24:40 +00:00
|
|
|
int colCounter;
|
|
|
|
int rowCounter;
|
2001-11-20 22:34:24 +00:00
|
|
|
double** Allocate(void);
|
2001-12-13 04:48:34 +00:00
|
|
|
void Debug(int from);
|
2001-03-30 03:08:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|