1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header:       FGGroundCallback.cpp
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
11  Software Foundation; either version 2 of the License, or (at your option) any
12  later 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
20  with this program; if not, write to the Free Software Foundation, Inc., 59
21  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be
24  found on 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 #include "math/FGLocation.h"
35 #include "FGGroundCallback.h"
36 
37 namespace JSBSim {
38 
39 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 
GetAGLevel(double t,const FGLocation & loc,FGLocation & contact,FGColumnVector3 & normal,FGColumnVector3 & vel,FGColumnVector3 & angularVel) const41 double FGDefaultGroundCallback::GetAGLevel(double t, const FGLocation& loc,
42                                     FGLocation& contact, FGColumnVector3& normal,
43                                     FGColumnVector3& vel, FGColumnVector3& angularVel) const
44 {
45   vel.InitMatrix();
46   angularVel.InitMatrix();
47   normal = FGColumnVector3(loc).Normalize();
48   double loc_radius = loc.GetRadius();  // Get the radius of the given location
49                                         // (e.g. the CG)
50   double agl = loc_radius - mTerrainLevelRadius;
51   contact = (mTerrainLevelRadius/loc_radius)*FGColumnVector3(loc);
52   return agl;
53 }
54 
55 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 
57 } // namespace JSBSim
58