]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGInertial.cpp
Merge branch 'topic/gcintersect' into next
[flightgear.git] / src / FDM / JSBSim / models / FGInertial.cpp
index c86ba673a06ab6b7709636ace759357842989a94..39aa91ddc3750657d57c76151086bc2f6efc0550 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.
 
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  Place - Suite 330, Boston, MA  02111-1307, USA.
 
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 FUNCTIONAL DESCRIPTION
@@ -54,13 +54,33 @@ FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex)
 {
   Name = "FGInertial";
 
-  // Defaults
-  RotationRate    = 0.00007272205217;
-  GM              = 14.06252720E15;
-  RadiusReference = 20925650.00;
+  // Earth defaults
+  RotationRate    = 0.00007292115;
+  GM              = 14.07644180E15;     // WGS84 value
+  RadiusReference = 20925650.00;        // Equatorial radius (WGS84)
+  C2_0            = -4.84165371736E-04; // WGS84 value for the C2,0 coefficient
+  J2              = 1.0826266836E-03;   // WGS84 value for J2
+  a               = 20925646.3255;      // WGS84 semimajor axis length in feet 
+  b               = 20855486.5951;      // WGS84 semiminor axis length in feet
+  earthPosAngle   = 0.0;
+
+  // Lunar defaults
+  /*
+  RotationRate    = 0.0000026617;
+  GM              = 1.7314079E14;         // Lunar GM
+  RadiusReference = 5702559.05;           // Equatorial radius
+  C2_0            = 0;                    // value for the C2,0 coefficient
+  J2              = 2.033542482111609E-4; // value for J2
+  a               = 5702559.05;           // semimajor axis length in feet 
+  b               = 5695439.63;           // semiminor axis length in feet
+  earthPosAngle   = 0.0;
+  */
+
   gAccelReference = GM/(RadiusReference*RadiusReference);
   gAccel          = GM/(RadiusReference*RadiusReference);
 
+  bind();
+
   Debug(0);
 }
 
@@ -73,6 +93,17 @@ FGInertial::~FGInertial(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+bool FGInertial::InitModel(void)
+{
+  if (!FGModel::InitModel()) return false;
+
+  earthPosAngle   = 0.0;
+
+  return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 bool FGInertial::Run(void)
 {
   // Fast return if we have nothing to do ...
@@ -82,10 +113,25 @@ bool FGInertial::Run(void)
   // Gravitation accel
   double r = Propagate->GetRadius();
   gAccel = GetGAccel(r);
+  earthPosAngle += State->Getdt()*RotationRate;
 
   return false;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGInertial::GetGAccel(double r) const
+{
+  return GM/(r*r);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGInertial::bind(void)
+{
+  PropertyManager->Tie("position/epa-rad", this, &FGInertial::GetEarthPositionAngle);
+}
+
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 //    The bitmasked value choices are as follows:
 //    unset: In this case (the default) JSBSim would only print