1 /*******************************************************************************
7 ------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 You should have received a copy of the GNU General Public License along with
20 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 Place - Suite 330, Boston, MA 02111-1307, USA.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
28 --------------------------------------------------------------------------------
32 FUNCTIONAL DESCRIPTION
33 --------------------------------------------------------------------------------
35 This class takes the given set of IC's and finds the angle of attack, elevator,
36 and throttle setting required to fly steady level. This is currently for in-air
37 conditions only. It is implemented using an iterative, one-axis-at-a-time
42 ********************************************************************************
44 *******************************************************************************/
49 /*******************************************************************************
51 *******************************************************************************/
53 #include "FGFDMExec.h"
54 #include "FGRotation.h"
55 #include "FGAtmosphere.h"
58 #include "FGAircraft.h"
59 #include "FGTranslation.h"
60 #include "FGPosition.h"
61 #include "FGAuxiliary.h"
64 #include "FGTrimAxis.h"
68 #define ID_TRIM "$Header"
70 /*******************************************************************************
72 *******************************************************************************/
74 typedef enum { tLongitudinal, tFull, tGround } TrimMode;
79 vector<FGTrimAxis*> TrimAxes;
85 float Tolerance, A_Tolerance;
88 float *sub_iterations;
91 int max_sub_iterations;
99 float xlo,xhi,alo,ahi;
103 FGInitialCondition* fgic;
105 // returns false if there is no change in the current axis accel
106 // between accel(control_min) and accel(control_max). if there is a
107 // change, sets solutionDomain to:
108 // 0 for no sign change,
109 // -1 if sign change between accel(control_min) and accel(0)
110 // 1 if sign between accel(0) and accel(control_max)
112 bool findInterval(void);
113 bool checkLimits(void);
116 FGTrim(FGFDMExec *FDMExec, FGInitialCondition *FGIC, TrimMode tt);
122 void ReportState(void);
125 inline void SetUdotTrim(bool bb) { trimudot=bb; }
126 inline bool GetUdotTrim(void) { return trimudot; }
128 inline void SetGammaFallback(bool bb) { gamma_fallback=true; }
129 inline bool GetGammaFallback(void) { return gamma_fallback; }
131 inline void SetMaxCycles(int ii) { max_iterations = ii; }
132 inline void SetMaxCyclesPerAxis(int ii) { max_sub_iterations = ii; }
133 inline void SetTolerance(float tt) {
135 A_Tolerance = tt / 10;
137 //Debug level 1 shows results of each top-level iteration
138 //Debug level 2 shows level 1 & results of each per-axis iteration
139 inline void SetDebug(int level) { Debug = level; }
140 inline void ClearDebug(void) { Debug = 0; }