1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 Header: FGGroundCallback.h
4 Author: Mathias Froehlich
7 ------ Copyright (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) -------
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
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
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.
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.
27 -------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34 #ifndef FGGROUNDCALLBACK_H
35 #define FGGROUNDCALLBACK_H
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41 #include "math/FGColumnVector3.h"
42 #include "math/FGLocation.h"
44 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48 #define ID_GROUNDCALLBACK "$Id: FGGroundCallback.h,v 1.12 2011/10/14 22:46:49 bcoconni Exp $"
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56 /** This class provides callback slots to get ground specific data.
58 The default implementation returns values for a
59 ball formed earth with an adjustable terrain elevation.
61 @author Mathias Froehlich
62 @version $Id: FGGroundCallback.h,v 1.12 2011/10/14 22:46:49 bcoconni Exp $
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69 class FGGroundCallback : public FGJSBBase
74 virtual ~FGGroundCallback() {}
76 /** Compute the altitude above sealevel
79 virtual double GetAltitude(const FGLocation& l) const = 0;
81 /** Compute the altitude above ground.
82 The altitude depends on time t and location l.
83 @param t simulation time
85 @param contact Contact point location below the location l
86 @param normal Normal vector at the contact point
87 @param v Linear velocity at the contact point
88 @param w Angular velocity at the contact point
89 @return altitude above ground
91 virtual double GetAGLevel(double t, const FGLocation& location,
93 FGColumnVector3& normal, FGColumnVector3& v,
94 FGColumnVector3& w) const = 0;
96 /** Compute the local terrain radius
97 @param t simulation time
98 @param location location
100 virtual double GetTerrainGeoCentRadius(double t, const FGLocation& location) const = 0;
102 /** Return the sea level radius
103 @param t simulation time
104 @param location location
106 virtual double GetSeaLevelRadius(const FGLocation& location) const = 0;
108 /** Set the local terrain radius.
109 Only needs to be implemented if JSBSim should be allowed
110 to modify the local terrain radius (see the default implementation)
112 virtual void SetTerrainGeoCentRadius(double radius) { }
114 /** Set the sea level radius.
115 Only needs to be implemented if JSBSim should be allowed
116 to modify the sea level radius (see the default implementation)
118 virtual void SetSeaLevelRadius(double radius) { }
122 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
123 // The default sphere earth implementation:
124 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
126 class FGDefaultGroundCallback : public FGGroundCallback
130 FGDefaultGroundCallback(double referenceRadius = 20925650.0);
132 double GetAltitude(const FGLocation& l) const;
134 double GetAGLevel(double t, const FGLocation& location,
136 FGColumnVector3& normal, FGColumnVector3& v,
137 FGColumnVector3& w) const;
139 void SetTerrainGeoCentRadius(double radius) { mTerrainLevelRadius = radius;}
140 double GetTerrainGeoCentRadius(double t, const FGLocation& location) const
141 { return mTerrainLevelRadius; }
143 void SetSeaLevelRadius(double radius) { mSeaLevelRadius = radius; }
144 double GetSeaLevelRadius(const FGLocation& location) const
145 {return mSeaLevelRadius; }
149 double mSeaLevelRadius;
150 double mTerrainLevelRadius;
155 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%