]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/input_output/FGGroundCallback.h
Fix for bug 1304 - crash loading XML route
[flightgear.git] / src / FDM / JSBSim / input_output / FGGroundCallback.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGGroundCallback.h
4  Author:       Mathias Froehlich
5  Date started: 05/21/04
6
7  ------ Copyright (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) -------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
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 Lesser General Public License for more
17  details.
18
19  You should have received a copy of the GNU Lesser 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.
22
23  Further information about the GNU Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 -------------------------------------------------------------------------------
28 05/21/00   MF   Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGGROUNDCALLBACK_H
35 #define FGGROUNDCALLBACK_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include "simgear/structure/SGReferenced.hxx"
42 #include "simgear/structure/SGSharedPtr.hxx"
43
44 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 DEFINITIONS
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47
48 #define ID_GROUNDCALLBACK "$Id: FGGroundCallback.h,v 1.16 2013/02/02 13:23:40 bcoconni Exp $"
49
50 namespace JSBSim {
51
52 class FGLocation;
53 class FGColumnVector3;
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 CLASS DOCUMENTATION
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 /** This class provides callback slots to get ground specific data.
60
61     The default implementation returns values for a
62     ball formed earth with an adjustable terrain elevation.
63
64     @author Mathias Froehlich
65     @version $Id: FGGroundCallback.h,v 1.16 2013/02/02 13:23:40 bcoconni Exp $
66 */
67
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 CLASS DECLARATION
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71
72 class FGGroundCallback : public SGReferenced
73 {
74 public:
75
76   FGGroundCallback() {}
77   virtual ~FGGroundCallback() {}
78
79   /** Compute the altitude above sealevel
80       @param l location
81    */
82   virtual double GetAltitude(const FGLocation& l) const = 0;
83
84   /** Compute the altitude above ground.
85       The altitude depends on time t and location l.
86       @param t simulation time
87       @param l location
88       @param contact Contact point location below the location l
89       @param normal Normal vector at the contact point
90       @param v Linear velocity at the contact point
91       @param w Angular velocity at the contact point
92       @return altitude above ground
93    */
94   virtual double GetAGLevel(double t, const FGLocation& location,
95                             FGLocation& contact,
96                             FGColumnVector3& normal, FGColumnVector3& v,
97                             FGColumnVector3& w) const = 0;
98
99   /** Compute the local terrain radius
100       @param t simulation time
101       @param location location
102    */
103   virtual double GetTerrainGeoCentRadius(double t, const FGLocation& location) const = 0;
104
105   /** Return the sea level radius
106       @param t simulation time
107       @param location location
108    */
109   virtual double GetSeaLevelRadius(const FGLocation& location) const = 0;
110
111   /** Set the local terrain radius.
112       Only needs to be implemented if JSBSim should be allowed
113       to modify the local terrain radius (see the default implementation)
114    */
115   virtual void SetTerrainGeoCentRadius(double radius)  { }
116
117   /** Set the sea level radius.
118       Only needs to be implemented if JSBSim should be allowed
119       to modify the sea level radius (see the default implementation)
120    */
121   virtual void SetSeaLevelRadius(double radius) {  }
122
123 };
124
125 typedef SGSharedPtr<FGGroundCallback> FGGroundCallback_ptr;
126
127 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128 // The default sphere earth implementation:
129 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130
131 class FGDefaultGroundCallback : public FGGroundCallback
132 {
133 public:
134
135    FGDefaultGroundCallback(double referenceRadius = 20925650.0);
136
137    double GetAltitude(const FGLocation& l) const;
138
139    double GetAGLevel(double t, const FGLocation& location,
140                      FGLocation& contact,
141                      FGColumnVector3& normal, FGColumnVector3& v,
142                      FGColumnVector3& w) const;
143
144    void SetTerrainGeoCentRadius(double radius)  {  mTerrainLevelRadius = radius;}
145    double GetTerrainGeoCentRadius(double t, const FGLocation& location) const
146    { return mTerrainLevelRadius; }
147
148    void SetSeaLevelRadius(double radius) { mSeaLevelRadius = radius;   }
149    double GetSeaLevelRadius(const FGLocation& location) const
150    {return mSeaLevelRadius; }
151
152 private:
153
154    double mSeaLevelRadius;
155    double mTerrainLevelRadius;
156 };
157
158
159 }
160 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161 #endif