| 1 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 | |
| 3 | Header: FGGroundCallback.cpp |
| 4 | Author: Mathias Froehlich |
| 5 | Date started: 05/21/04 |
| 6 | |
| 7 | ------ Copyright (C) 2004 Mathias Froehlich ([email protected]) ------- |
| 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 | |
| 41 | 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 | FGLocation l = loc; |
| 48 | l.SetEllipse(a,b); |
| 49 | double latitude = l.GetGeodLatitudeRad(); |
| 50 | double cosLat = cos(latitude); |
| 51 | double longitude = l.GetLongitude(); |
| 52 | normal = FGColumnVector3(cosLat*cos(longitude), cosLat*sin(longitude), |
| 53 | sin(latitude)); |
| 54 | contact.SetEllipse(a, b); |
| 55 | contact.SetPositionGeodetic(longitude, latitude, mTerrainElevation); |
| 56 | return l.GetGeodAltitude() - mTerrainElevation; |
| 57 | } |
| 58 | |
| 59 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 60 | |
| 61 | } // namespace JSBSim |