56 double RotationRate = 0.00007292115;
57 GM = 14.0764417572E15;
72 vOmegaPlanet = { 0.0, 0.0, RotationRate };
91 if (!
Upload(el,
true))
return false;
105 vOmegaPlanet = {0., 0., RotationRate};
112 GroundCallback->SetEllipse(a, b);
115 if (a != b && J2 == 0.0)
116 cout <<
"Gravitational constant J2 is null for a non-spherical planet." << endl;
117 if (a == b && J2 != 0.0)
118 cout <<
"Gravitational constant J2 is non-zero for a spherical planet." << endl;
131 if (Holding)
return false;
137 double radius =
in.Position.GetRadius();
138 vGravAccel = -(GetGAccel(radius) / radius) *
in.Position;
142 vGravAccel = GetGravityJ2(
in.Position);
167 Down = GetGravityJ2(location);
168 Down -= vOmegaPlanet*(vOmegaPlanet*sea_level);}
175 North(
eY), East(
eY), Down(
eY),
176 North(
eZ), 0.0, Down(
eZ)};
181double FGInertial::GetGAccel(
double r)
const
193FGColumnVector3 FGInertial::GetGravityJ2(
const FGLocation& position)
const
195 FGColumnVector3 J2Gravity;
198 double r = position.GetRadius();
199 double sinLat = sin(position.GetLatitude());
202 double preCommon = 1.5*J2*adivr*adivr;
203 double xy = 1.0 - 5.0*(sinLat*sinLat);
204 double z = 3.0 - 5.0*(sinLat*sinLat);
205 double GMOverr2 = GM/(r*r);
207 J2Gravity(1) = -GMOverr2 * ((1.0 + (preCommon * xy)) * position(
eX)/r);
208 J2Gravity(2) = -GMOverr2 * ((1.0 + (preCommon * xy)) * position(
eY)/r);
209 J2Gravity(3) = -GMOverr2 * ((1.0 + (preCommon * z)) * position(
eZ)/r);
221 GroundCallback->GetAGLevel(location, contact, vDummy, vDummy, vDummy);
226 groundHeight + altitudeAGL);
238 cout <<
"Warning: Standard gravity model has been set for a non-spherical planet" << endl;
242 cout <<
"Warning: WGS84 gravity model has been set without specifying the J2 gravitational constant." << endl;
250void FGInertial::bind(
void)
277void FGInertial::Debug(
int from)
284 cout << endl <<
" Planet " <<
Name << endl;
285 cout <<
" Semi major axis: " << a << endl;
286 cout <<
" Semi minor axis: " << b << endl;
287 cout <<
" Rotation rate : " << scientific << vOmegaPlanet(
eZ) << endl;
288 cout <<
" GM : " << GM << endl;
289 cout <<
" J2 : " << J2 << endl << defaultfloat;
293 if (from == 0) cout <<
"Instantiated: FGInertial" << endl;
294 if (from == 1) cout <<
"Destroyed: FGInertial" << endl;
double FindElementValueAsNumberConvertTo(const std::string &el, const std::string &target_units)
Searches for the named element and converts and returns the data belonging to it.
double FindElementValueAsNumber(const std::string &el="")
Searches for the named element and returns the data belonging to it as a number.
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
Element * FindElement(const std::string &el="")
Searches for a specified element.
This class implements a 3 element column vector.
FGColumnVector3 & Normalize(void)
Normalize.
void SetGravityType(int gt)
Set the gravity type.
bool Run(bool Holding) override
Runs the Inertial model; called by the Executive Can pass in a value indicating if the executive is d...
bool Load(Element *el) override
@ gtStandard
Evaluate gravity using Newton's classical formula assuming the Earth is spherical.
@ gtWGS84
Evaluate gravity using WGS84 formulas that take the Earth oblateness into account.
void SetAltitudeAGL(FGLocation &location, double altitudeAGL)
Set the altitude above ground level.
struct JSBSim::FGInertial::Inputs in
int GetGravityType(void) const
Get the gravity type.
FGMatrix33 GetTl2ec(const FGLocation &location) const
Transform matrix from the local horizontal frame to earth centered.
FGLocation holds an arbitrary location in the Earth centered Earth fixed reference frame (ECEF).
double GetGeodAltitude(void) const
Gets the geodetic altitude in feet.
void SetPositionGeodetic(double lon, double lat, double height)
Sets the longitude, latitude and the distance above the reference spheroid.
double GetLongitude() const
Get the longitude.
double GetGeodLatitudeRad(void) const
Get the GEODETIC latitude in radians.
double GetSeaLevelRadius(void) const
Get the sea level radius in feet below the current location.
void SetEllipse(double semimajor, double semiminor)
Sets the semimajor and semiminor axis lengths for this planet.
Handles matrix math operations.
FGPropertyManager * PropertyManager
FGModel(FGFDMExec *)
Constructor.
bool Upload(Element *el, bool preLoad)
Uploads this model in memory.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
void Tie(const std::string &name, T *pointer)
Tie a property to an external variable.