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 "simgear/structure/SGReferenced.hxx"
42 #include "simgear/structure/SGSharedPtr.hxx"
44 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48 #define ID_GROUNDCALLBACK "$Id: FGGroundCallback.h,v 1.16 2013/02/02 13:23:40 bcoconni Exp $"
53 class FGColumnVector3;
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 /** This class provides callback slots to get ground specific data.
61 The default implementation returns values for a
62 ball formed earth with an adjustable terrain elevation.
64 @author Mathias Froehlich
65 @version $Id: FGGroundCallback.h,v 1.16 2013/02/02 13:23:40 bcoconni Exp $
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72 class FGGroundCallback : public SGReferenced
77 virtual ~FGGroundCallback() {}
79 /** Compute the altitude above sealevel
82 virtual double GetAltitude(const FGLocation& l) const = 0;
84 /** Compute the altitude above ground.
85 The altitude depends on time t and location l.
86 @param t simulation time
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
94 virtual double GetAGLevel(double t, const FGLocation& location,
96 FGColumnVector3& normal, FGColumnVector3& v,
97 FGColumnVector3& w) const = 0;
99 /** Compute the local terrain radius
100 @param t simulation time
101 @param location location
103 virtual double GetTerrainGeoCentRadius(double t, const FGLocation& location) const = 0;
105 /** Return the sea level radius
106 @param t simulation time
107 @param location location
109 virtual double GetSeaLevelRadius(const FGLocation& location) const = 0;
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)
115 virtual void SetTerrainGeoCentRadius(double radius) { }
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)
121 virtual void SetSeaLevelRadius(double radius) { }
125 typedef SGSharedPtr<FGGroundCallback> FGGroundCallback_ptr;
127 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128 // The default sphere earth implementation:
129 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131 class FGDefaultGroundCallback : public FGGroundCallback
135 FGDefaultGroundCallback(double referenceRadius = 20925650.0);
137 double GetAltitude(const FGLocation& l) const;
139 double GetAGLevel(double t, const FGLocation& location,
141 FGColumnVector3& normal, FGColumnVector3& v,
142 FGColumnVector3& w) const;
144 void SetTerrainGeoCentRadius(double radius) { mTerrainLevelRadius = radius;}
145 double GetTerrainGeoCentRadius(double t, const FGLocation& location) const
146 { return mTerrainLevelRadius; }
148 void SetSeaLevelRadius(double radius) { mSeaLevelRadius = radius; }
149 double GetSeaLevelRadius(const FGLocation& location) const
150 {return mSeaLevelRadius; }
154 double mSeaLevelRadius;
155 double mTerrainLevelRadius;
160 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%