1 // FGAIWingman - FGAIBllistic-derived class creates an AI Wingman
3 // Written by Vivian Meazza, started February 2008.
4 // - vivian.meazza at lineone.net
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License as
8 // published by the Free Software Foundation; either version 2 of the
9 // License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef _FG_AIWINGMAN_HXX
21 #define _FG_AIWINGMAN_HXX
23 #include "AIBallistic.hxx"
25 #include "AIManager.hxx"
28 #include <simgear/sg_inlines.h>
29 #include <simgear/math/SGMath.hxx>
32 class FGAIWingman : public FGAIBallistic {
35 virtual ~FGAIWingman();
37 virtual void readFromScenario(SGPropertyNode* scFileNode);
39 bool init(bool search_in_AI_path=false);
41 virtual void reinit();
42 virtual void update (double dt);
44 virtual const char* getTypeString(void) const { return "wingman"; }
47 void formateToAC(double dt);
48 void Break(double dt);
52 double getDistanceToOffset() const;
53 double getElevToOffset() const;
55 double calcAngle(double rangeM, SGGeod pos1, SGGeod pos2);
56 double calcDistanceM(SGGeod pos1, SGGeod pos2) const;
62 double _break_angle; //degrees relative
63 double _coeff_hdg; //dimensionless coefficient
64 double _coeff_pch; //dimensionless coefficient
65 double _coeff_bnk; //dimensionless coefficient
66 double _coeff_spd; //dimensionless coefficient
68 SGPropertyNode_ptr user_WoW_node;
70 inline void setFormate(bool f);
71 inline void setTgtHdg(double hdg);
72 inline void setTgtSpd(double spd);
73 inline void setBrkHdg(double angle);
74 inline void setBrkAng(double angle);
75 inline void setCoeffHdg(double h);
76 inline void setCoeffPch(double p);
77 inline void setCoeffBnk(double r);
78 inline void setCoeffSpd(double s);
80 inline bool getFormate() const { return _formate_to_ac;}
82 inline double getTgtHdg() const { return tgt_heading;}
83 inline double getTgtSpd() const { return tgt_speed;}
84 inline double getBrkAng() const { return _break_angle;}
86 inline SGVec3d getCartInPos(SGGeod in_pos) const;
90 void FGAIWingman::setFormate(bool f) {
94 void FGAIWingman::setTgtHdg(double h) {
98 void FGAIWingman::setTgtSpd(double s) {
102 void FGAIWingman::setBrkHdg(double a){
103 tgt_heading = hdg + a ;
104 SG_NORMALIZE_RANGE(tgt_heading, 0.0, 360.0);
107 void FGAIWingman::setBrkAng(double a){
109 SG_NORMALIZE_RANGE(_break_angle, -180.0, 180.0);
112 void FGAIWingman::setCoeffHdg(double h){
116 void FGAIWingman::setCoeffPch(double p){
120 void FGAIWingman::setCoeffBnk(double b){
124 void FGAIWingman::setCoeffSpd(double s){
128 //bool FGAIWingman::getFormate() const {
129 // return _formate_to_ac;
132 //double FGAIWingman::getTgtHdg() const{
133 // return tgt_heading;
136 //double FGAIWingman::getTgtSpd() const{
140 //double FGAIWingman::getBrkAng() const{
141 // return _break_angle;
144 SGVec3d FGAIWingman::getCartInPos(SGGeod in_pos) const {
145 SGVec3d cartPos = SGVec3d::fromGeod(in_pos);
149 #endif // FG_AIWINGMAN_HXX