JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGLocation Class Reference

FGLocation holds an arbitrary location in the Earth centered Earth fixed reference frame (ECEF). More...

#include <FGLocation.h>

+ Inheritance diagram for FGLocation:
+ Collaboration diagram for FGLocation:

Public Member Functions

 FGLocation (void)
 Default constructor. More...
 
 FGLocation (double lon, double lat, double radius)
 Constructor to set the longitude, latitude and the distance from the center of the earth. More...
 
 FGLocation (const FGColumnVector3 &lv)
 Constructor to initialize the location with the cartesian coordinates (X,Y,Z) contained in the input FGColumnVector3. More...
 
 FGLocation (const FGLocation &l)
 Copy constructor. More...
 
double Entry (unsigned int idx) const
 Read access the entries of the vector. More...
 
double & Entry (unsigned int idx)
 Write access the entries of the vector. More...
 
double GetCosLatitude () const
 Get the cosine of Latitude. More...
 
double GetCosLongitude () const
 Get the cosine of Longitude. More...
 
double GetDistanceTo (double target_longitude, double target_latitude) const
 Get the geodetic distance between the current location and a given location. More...
 
double GetEPA () const
 Return the Earth Position Angle. More...
 
double GetGeodAltitude (void) const
 Gets the geodetic altitude in feet. More...
 
double GetGeodLatitudeDeg (void) const
 Get the geodetic latitude in degrees. More...
 
double GetGeodLatitudeRad (void) const
 Get the geodetic latitude. More...
 
double GetHeadingTo (double target_longitude, double target_latitude) const
 Get the heading that should be followed from the current location to a given location along the shortest path. More...
 
double GetLatitude () const
 Get the latitude. More...
 
double GetLatitudeDeg () const
 Get the latitude. More...
 
double GetLongitude () const
 Get the longitude. More...
 
double GetLongitudeDeg () const
 Get the longitude. More...
 
double GetRadius () const
 Get the distance from the center of the earth. More...
 
double GetSinLatitude () const
 Get the sine of Latitude. More...
 
double GetSinLongitude () const
 Get the sine of Longitude. More...
 
double GetTanLatitude () const
 Get the cosine of Latitude. More...
 
const FGMatrix33GetTec2i (void) const
 Transform matrix from the earth centered to inertial frame. More...
 
const FGMatrix33GetTec2l (void) const
 Transform matrix from the earth centered to local horizontal frame. More...
 
const FGMatrix33GetTi2ec (void) const
 Transform matrix from inertial to earth centered frame. More...
 
const FGMatrix33GetTi2l (void) const
 Transform matrix from the inertial to local horizontal frame. More...
 
const FGMatrix33GetTl2ec (void) const
 Transform matrix from local horizontal to earth centered frame. More...
 
const FGMatrix33GetTl2i (void) const
 Transform matrix from local horizontal to inertial frame. More...
 
void IncrementEarthPositionAngle (double delta)
 Increments the Earth position angle. More...
 
FGLocation LocalToLocation (const FGColumnVector3 &lvec) const
 Conversion from Local frame coordinates to a location in the earth centered and fixed frame. More...
 
FGColumnVector3 LocationToLocal (const FGColumnVector3 &ecvec) const
 Conversion from a location in the earth centered and fixed frame to local horizontal frame coordinates. More...
 
 operator const FGColumnVector3 & () const
 Cast to a simple 3d vector.
 
bool operator!= (const FGLocation &l) const
 This operator returns true if the ECEF location vectors for the two location objects are not equal. More...
 
double operator() (unsigned int idx) const
 Read access the entries of the vector. More...
 
double & operator() (unsigned int idx)
 Write access the entries of the vector. More...
 
FGLocation operator* (double scalar) const
 This operator scales an ECEF position vector. More...
 
const FGLocationoperator*= (double scalar)
 This operator scales the ECEF position vector. More...
 
FGLocation operator+ (const FGLocation &l) const
 This operator adds two ECEF position vectors. More...
 
const FGLocationoperator+= (const FGLocation &l)
 This operator adds the ECEF position vectors. More...
 
FGLocation operator- (const FGLocation &l) const
 This operator substracts two ECEF position vectors. More...
 
const FGLocationoperator-= (const FGLocation &l)
 This operator substracts the ECEF position vectors. More...
 
const FGLocationoperator/= (double scalar)
 This operator scales the ECEF position vector. More...
 
const FGLocationoperator= (const FGColumnVector3 &v)
 Sets this location via the supplied vector. More...
 
const FGLocationoperator= (const FGLocation &l)
 Sets this location via the supplied location object. More...
 
bool operator== (const FGLocation &l) const
 This operator returns true if the ECEF location vectors for the two location objects are equal. More...
 
void SetEarthPositionAngle (double EPA)
 Sets the Earth position angle. More...
 
void SetEllipse (double semimajor, double semiminor)
 Sets the semimajor and semiminor axis lengths for this planet. More...
 
void SetLatitude (double latitude)
 Set the latitude. More...
 
void SetLongitude (double longitude)
 Set the longitude. More...
 
void SetPosition (double lon, double lat, double radius)
 Sets the longitude, latitude and the distance from the center of the earth. More...
 
void SetPositionGeodetic (double lon, double lat, double height)
 Sets the longitude, latitude and the distance above the reference ellipsoid. More...
 
void SetRadius (double radius)
 Set the distance from the center of the earth. More...
 
Functions that rely on the ground callback

The following functions allow to set and get the vehicle position above the sea or the ground.

The sea and the ground levels are obtained by interrogating an FGGroundCallback instance. A ground callback must therefore be set with SetGroundCallback() before calling any of these functions.

void SetAltitudeASL (double altitudeASL)
 Set the altitude above sea level. More...
 
void SetAltitudeAGL (double altitudeAGL)
 Set the altitude above ground level. More...
 
double GetSeaLevelRadius (void) const
 Get the local sea level radius. More...
 
double GetTerrainRadius (void) const
 Get the local terrain radius. More...
 
double GetAltitudeASL (void) const
 Get the altitude above sea level. More...
 
double GetAltitudeAGL (void) const
 Get the altitude above ground level. More...
 
double GetContactPoint (FGLocation &contact, FGColumnVector3 &normal, FGColumnVector3 &v, FGColumnVector3 &w) const
 Get terrain contact point information below the current location. More...
 
- Public Member Functions inherited from FGJSBBase
 FGJSBBase ()
 Constructor for FGJSBBase.
 
virtual ~FGJSBBase ()
 Destructor for FGJSBBase.
 
void disableHighLighting (void)
 Disables highlighting in the console output.
 
std::string GetVersion (void)
 Returns the version number of JSBSim. More...
 
void PutMessage (const Message &msg)
 Places a Message structure on the Message queue. More...
 
void PutMessage (const std::string &text)
 Creates a message with the given text and places it on the queue. More...
 
void PutMessage (const std::string &text, bool bVal)
 Creates a message with the given text and boolean value and places it on the queue. More...
 
void PutMessage (const std::string &text, int iVal)
 Creates a message with the given text and integer value and places it on the queue. More...
 
void PutMessage (const std::string &text, double dVal)
 Creates a message with the given text and double value and places it on the queue. More...
 
int SomeMessages (void)
 Reads the message on the queue (but does not delete it). More...
 
void ProcessMessage (void)
 Reads the message on the queue and removes it from the queue. More...
 
MessageProcessNextMessage (void)
 Reads the next message on the queue and removes it from the queue. More...
 

Static Public Member Functions

static FGGroundCallbackGetGroundCallback (void)
 Get a pointer to the ground callback currently used. More...
 
static void SetGroundCallback (FGGroundCallback *gc)
 Sets the ground callback pointer. More...
 
- Static Public Member Functions inherited from FGJSBBase
static double CelsiusToFahrenheit (double celsius)
 Converts from degrees Celsius to degrees Fahrenheit. More...
 
static double CelsiusToKelvin (double celsius)
 Converts from degrees Celsius to degrees Kelvin. More...
 
static double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine. More...
 
static double Constrain (double min, double value, double max)
 Constrain a value between a minimum and a maximum value.
 
static bool EqualToRoundoff (double a, double b)
 Finite precision comparison. More...
 
static bool EqualToRoundoff (float a, float b)
 Finite precision comparison. More...
 
static bool EqualToRoundoff (float a, double b)
 Finite precision comparison. More...
 
static bool EqualToRoundoff (double a, float b)
 Finite precision comparison. More...
 
static double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius. More...
 
static double FeetToMeters (double measure)
 Converts from feet to meters. More...
 
static double GaussianRandomNumber (void)
 
static double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius. More...
 
static double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit. More...
 
static double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine. More...
 
static double MachFromVcalibrated (double vcas, double p, double psl, double rhosl)
 Calculate the Mach number from the calibrated airspeed. More...
 
static double PitotTotalPressure (double mach, double p)
 Compute the total pressure in front of the Pitot tube. More...
 
static double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius. More...
 
static double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin. More...
 
static double sign (double num)
 
static double VcalibratedFromMach (double mach, double p, double psl, double rhosl)
 Calculate the calibrated airspeed from the Mach number. More...
 

Additional Inherited Members

- Public Types inherited from FGJSBBase
enum  { eL = 1, eM, eN }
 Moments L, M, N.
 
enum  { eP = 1, eQ, eR }
 Rates P, Q, R.
 
enum  { eU = 1, eV, eW }
 Velocities U, V, W.
 
enum  { eX = 1, eY, eZ }
 Positions X, Y, Z.
 
enum  { ePhi = 1, eTht, ePsi }
 Euler angles Phi, Theta, Psi.
 
enum  { eDrag = 1, eSide, eLift }
 Stability axis forces, Drag, Side force, Lift.
 
enum  { eRoll = 1, ePitch, eYaw }
 Local frame orientation Roll, Pitch, Yaw.
 
enum  { eNorth = 1, eEast, eDown }
 Local frame position North, East, Down.
 
enum  { eLat = 1, eLong, eRad }
 Locations Radius, Latitude, Longitude.
 
enum  {
  inNone = 0, inDegrees, inRadians, inMeters,
  inFeet
}
 Conversion specifiers.
 
- Static Public Attributes inherited from FGJSBBase
static short debug_lvl = 1
 
static char highint [5] = {27, '[', '1', 'm', '\0' }
 highlights text
 
static char halfint [5] = {27, '[', '2', 'm', '\0' }
 low intensity text
 
static char normint [6] = {27, '[', '2', '2', 'm', '\0' }
 normal intensity text
 
static char reset [5] = {27, '[', '0', 'm', '\0' }
 resets text properties
 
static char underon [5] = {27, '[', '4', 'm', '\0' }
 underlines text
 
static char underoff [6] = {27, '[', '2', '4', 'm', '\0' }
 underline off
 
static char fgblue [6] = {27, '[', '3', '4', 'm', '\0' }
 blue text
 
static char fgcyan [6] = {27, '[', '3', '6', 'm', '\0' }
 cyan text
 
static char fgred [6] = {27, '[', '3', '1', 'm', '\0' }
 red text
 
static char fggreen [6] = {27, '[', '3', '2', 'm', '\0' }
 green text
 
static char fgdef [6] = {27, '[', '3', '9', 'm', '\0' }
 default text
 
- Protected Member Functions inherited from FGJSBBase
void Debug (int)
 
- Static Protected Member Functions inherited from FGJSBBase
static std::string CreateIndexedPropertyName (const std::string &Property, int index)
 
- Static Protected Attributes inherited from FGJSBBase
static const double degtorad = 0.017453292519943295769236907684886
 
static const double fpstokts = 1.0/ktstofps
 
static const double fttom = 0.3048
 
static int gaussian_random_number_phase = 0
 
static const double hptoftlbssec = 550.0
 
static const double in3tom3 = 1.638706E-5
 
static const double inchtoft = 0.08333333
 
static const double inhgtopa = 3386.38
 
static const std::string JSBSim_version = "1.0 " __DATE__ " " __TIME__
 
static const double kgtolb = 2.20462
 
static const double kgtoslug = 0.06852168
 
static const double ktstofps = 1.68781
 
static const double lbtoslug = 1.0/slugtolb
 
static Message localMsg
 
static const double m3toft3 = 1.0/(fttom*fttom*fttom)
 
static double Mair = 28.9645
 
static unsigned int messageId = 0
 
static std::queue< MessageMessages
 
static const std::string needed_cfg_version = "2.0"
 
static const double psftoinhg = 0.014138
 
static const double psftopa = 47.88
 
static const double radtodeg = 57.295779513082320876798154814105
 
static double Reng = 1716.56
 
static double Rstar = 1545.348
 
static const double SHRatio = 1.40
 
static const double slugtolb = 32.174049
 

Detailed Description

FGLocation holds an arbitrary location in the Earth centered Earth fixed reference frame (ECEF).

The coordinate frame ECEF has its center in the middle of the earth. The X-axis points from the center of the Earth towards a location with zero latitude and longitude on the Earth surface. The Y-axis points from the center of the Earth towards a location with zero latitude and 90 deg East longitude on the Earth surface. The Z-axis points from the Earth center to the geographic north pole.

This class provides access functions to set and get the location as either the simple X, Y and Z values in ft or longitude/latitude and the radial distance of the location from the Earth center.

It is common to associate a parent frame with a location. This frame is usually called the local horizontal frame or simply the local frame. It is also called the NED frame (North, East, Down), as well as the Navigation frame. This frame has its X/Y plane parallel to the surface of the Earth (with the assumption of a spherical Earth). The X-axis points towards north, the Y-axis points east and the Z-axis points to the center of the Earth.

Since the local frame is determined by the location (and NOT by the orientation of the vehicle IN any frame), this class also provides the rotation matrices required to transform from the Earth centered (ECEF) frame to the local horizontal frame and back. This class also "owns" the transformations that go from the inertial frame (Earth-centered Inertial, or ECI) to and from the ECEF frame, as well as to and from the local frame. Again, this is because the ECI, ECEF, and local frames do not involve the actual orientation of the vehicle - only the location on the Earth surface, and the angular difference between the ECI and ECEF frames. There are conversion functions for conversion of position vectors given in the one frame to positions in the other frame.

To keep the transformation matrices between the ECI and ECEF frames up to date, the Earth angular position must be updated by calling SetEarthPositionAngle() or IncrementEarthPositionAngle(). This must be done prior to any conversion from and to the ECI frame.

The Earth centered reference frame is NOT an inertial frame since it rotates with the Earth.

The cartesian coordinates (X,Y,Z) in the Earth centered frame are the master values. All other values are computed from these master values and are cached as long as the location is changed by access through a non-const member function. Values are cached to improve performance. It is best practice to work with a natural set of master values. Other parameters that are derived from these master values are calculated only when needed, and IF they are needed and calculated, then they are cached (stored and remembered) so they do not need to be re-calculated until the master values they are derived from are themselves changed (and become stale).

Accuracy and round off

Given,

  • that we model a vehicle near the Earth
  • that the Earth surface radius is about 2*10^7, ft
  • that we use double values for the representation of the location

we have an accuracy of about

1e-16*2e7ft/1 = 2e-9 ft

left. This should be sufficient for our needs. Note that this is the same relative accuracy we would have when we compute directly with lon/lat/radius. For the radius value this is clear. For the lon/lat pair this is easy to see. Take for example KSFO located at about 37.61 deg north 122.35 deg west, which corresponds to 0.65642 rad north and 2.13541 rad west. Both values are of magnitude of about 1. But 1 ft corresponds to about 1/(2e7*2*pi) = 7.9577e-09 rad. So the left accuracy with this representation is also about 1*1e-16/7.9577e-09 = 1.2566e-08 which is of the same magnitude as the representation chosen here.

The advantage of this representation is that it is a linear space without singularities. The singularities are the north and south pole and most notably the non-steady jump at -pi to pi. It is harder to track this jump correctly especially when we need to work with error norms and derivatives of the equations of motion within the time-stepping code. Also, the rate of change is of the same magnitude for all components in this representation which is an advantage for numerical stability in implicit time-stepping.

Note: The latitude is a GEOCENTRIC value. FlightGear converts latitude to a geodetic value and uses that. In order to get best matching relative to a map, geocentric latitude must be converted to geodetic.

See also
Stevens and Lewis, "Aircraft Control and Simulation", Second edition
W. C. Durham "Aircraft Dynamics & Control", section 2.2
Author
Mathias Froehlich
Version
Id
FGLocation.h,v 1.35 2015/09/20 20:53:13 bcoconni Exp

Definition at line 160 of file FGLocation.h.

Constructor & Destructor Documentation

◆ FGLocation() [1/4]

FGLocation ( void  )

Default constructor.

Definition at line 60 of file FGLocation.cpp.

61  : mECLoc(1.0, 0.0, 0.0), mCacheValid(false)
62 {
63  e2 = c = 0.0;
64  a = ec = ec2 = 1.0;
65  epa = 0.0;
66 
67  mLon = mLat = mRadius = 0.0;
68  mGeodLat = GeodeticAltitude = 0.0;
69 
70  mTl2ec.InitMatrix();
71  mTec2l.InitMatrix();
72  mTi2ec.InitMatrix();
73  mTec2i.InitMatrix();
74  mTi2l.InitMatrix();
75  mTl2i.InitMatrix();
76 }
void InitMatrix(void)
Initialize the matrix.
Definition: FGMatrix33.cpp:257
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FGLocation() [2/4]

FGLocation ( double  lon,
double  lat,
double  radius 
)

Constructor to set the longitude, latitude and the distance from the center of the earth.

Parameters
lonlongitude
latGEOCENTRIC latitude
radiusdistance from center of earth to vehicle in feet

Definition at line 80 of file FGLocation.cpp.

81  : mCacheValid(false)
82 {
83  e2 = c = 0.0;
84  a = ec = ec2 = 1.0;
85  epa = 0.0;
86 
87  mLon = mLat = mRadius = 0.0;
88  mGeodLat = GeodeticAltitude = 0.0;
89 
90  mTl2ec.InitMatrix();
91  mTec2l.InitMatrix();
92  mTi2ec.InitMatrix();
93  mTec2i.InitMatrix();
94  mTi2l.InitMatrix();
95  mTl2i.InitMatrix();
96 
97  double sinLat = sin(lat);
98  double cosLat = cos(lat);
99  double sinLon = sin(lon);
100  double cosLon = cos(lon);
101  mECLoc = FGColumnVector3( radius*cosLat*cosLon,
102  radius*cosLat*sinLon,
103  radius*sinLat );
104 }
void InitMatrix(void)
Initialize the matrix.
Definition: FGMatrix33.cpp:257
+ Here is the call graph for this function:

◆ FGLocation() [3/4]

FGLocation ( const FGColumnVector3 lv)

Constructor to initialize the location with the cartesian coordinates (X,Y,Z) contained in the input FGColumnVector3.

Distances are in feet, the position is expressed in the ECEF frame.

Parameters
lvvector that contain the cartesian coordinates

Definition at line 108 of file FGLocation.cpp.

109  : mECLoc(lv), mCacheValid(false)
110 {
111  e2 = c = 0.0;
112  a = ec = ec2 = 1.0;
113  epa = 0.0;
114 
115  mLon = mLat = mRadius = 0.0;
116  mGeodLat = GeodeticAltitude = 0.0;
117 
118  mTl2ec.InitMatrix();
119  mTec2l.InitMatrix();
120  mTi2ec.InitMatrix();
121  mTec2i.InitMatrix();
122  mTi2l.InitMatrix();
123  mTl2i.InitMatrix();
124 }
void InitMatrix(void)
Initialize the matrix.
Definition: FGMatrix33.cpp:257
+ Here is the call graph for this function:

◆ FGLocation() [4/4]

FGLocation ( const FGLocation l)

Copy constructor.

Definition at line 128 of file FGLocation.cpp.

129  : mECLoc(l.mECLoc), mCacheValid(l.mCacheValid)
130 {
131  a = l.a;
132  e2 = l.e2;
133  c = l.c;
134  ec = l.ec;
135  ec2 = l.ec2;
136  epa = l.epa;
137 
138  /*ag
139  * if the cache is not valid, all of the following values are unset.
140  * They will be calculated once ComputeDerivedUnconditional is called.
141  * If unset, they may possibly contain NaN and could thus trigger floating
142  * point exceptions.
143  */
144  if (!mCacheValid) return;
145 
146  mLon = l.mLon;
147  mLat = l.mLat;
148  mRadius = l.mRadius;
149 
150  mTl2ec = l.mTl2ec;
151  mTec2l = l.mTec2l;
152  mTi2ec = l.mTi2ec;
153  mTec2i = l.mTec2i;
154  mTi2l = l.mTi2l;
155  mTl2i = l.mTl2i;
156 
157  mGeodLat = l.mGeodLat;
158  GeodeticAltitude = l.GeodeticAltitude;
159 }

Member Function Documentation

◆ Entry() [1/2]

double Entry ( unsigned int  idx) const
inline

Read access the entries of the vector.

Parameters
idxthe component index.
Returns
the value of the matrix entry at the given index. Indices are counted starting with 1. This function is just a shortcut for the double operator()(unsigned int idx) const function. It is used internally to access the elements in a more convenient way. Note that the index given in the argument is unchecked.

Definition at line 505 of file FGLocation.h.

505 { return mECLoc.Entry(idx); }
double Entry(const unsigned int idx) const
Read access the entries of the vector.
+ Here is the call graph for this function:

◆ Entry() [2/2]

double& Entry ( unsigned int  idx)
inline

Write access the entries of the vector.

Parameters
idxthe component index.
Returns
a reference to the vector entry at the given index. Indices are counted starting with 1. This function is just a shortcut for the double& operator()(unsigned int idx) function. It is used internally to access the elements in a more convenient way. Note that the index given in the argument is unchecked.

Definition at line 515 of file FGLocation.h.

515  {
516  mCacheValid = false; return mECLoc.Entry(idx);
517  }
double Entry(const unsigned int idx) const
Read access the entries of the vector.
+ Here is the call graph for this function:

◆ GetAltitudeAGL()

double GetAltitudeAGL ( void  ) const
inline

Get the altitude above ground level.

Returns
the altitude AGL in feet.
See also
SetGroundCallback

Definition at line 365 of file FGLocation.h.

365  {
366  FGLocation c;
367  FGColumnVector3 n,v,w;
368  return GetContactPoint(c,n,v,w);
369  }
double GetContactPoint(FGLocation &contact, FGColumnVector3 &normal, FGColumnVector3 &v, FGColumnVector3 &w) const
Get terrain contact point information below the current location.
Definition: FGLocation.h:378
FGLocation(void)
Default constructor.
Definition: FGLocation.cpp:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAltitudeASL()

double GetAltitudeASL ( void  ) const
inline

Get the altitude above sea level.

Returns
the altitude ASL in feet.
See also
SetGroundCallback

Definition at line 359 of file FGLocation.h.

360  { ComputeDerived(); return GroundCallback->GetAltitude(*this); }
+ Here is the caller graph for this function:

◆ GetContactPoint()

double GetContactPoint ( FGLocation contact,
FGColumnVector3 normal,
FGColumnVector3 v,
FGColumnVector3 w 
) const
inline

Get terrain contact point information below the current location.

Parameters
contactContact point location
normalTerrain normal vector in contact point (ECEF frame)
vTerrain linear velocity in contact point (ECEF frame)
wTerrain angular velocity in contact point (ECEF frame)
Returns
Location altitude above contact point (AGL) in feet.
See also
SetGroundCallback

Definition at line 378 of file FGLocation.h.

380  { ComputeDerived(); return GroundCallback->GetAGLevel(*this, contact, normal, v, w); }
+ Here is the caller graph for this function:

◆ GetCosLatitude()

double GetCosLatitude ( ) const
inline

Get the cosine of Latitude.

Definition at line 299 of file FGLocation.h.

299 { ComputeDerived(); return mTec2l(1,3); }
+ Here is the caller graph for this function:

◆ GetCosLongitude()

double GetCosLongitude ( ) const
inline

Get the cosine of Longitude.

Definition at line 266 of file FGLocation.h.

266 { ComputeDerived(); return mTec2l(2,2); }

◆ GetDistanceTo()

double GetDistanceTo ( double  target_longitude,
double  target_latitude 
) const

Get the geodetic distance between the current location and a given location.

This corresponds to the shortest distance between the two locations. Earth curvature is taken into account.

Parameters
target_longitudethe target longitude
target_latitudethe target latitude
Returns
The geodetic distance between the two locations

Definition at line 418 of file FGLocation.cpp.

420 {
421  double delta_lat_rad = target_latitude - GetLatitude();
422  double delta_lon_rad = target_longitude - GetLongitude();
423 
424  double distance_a = pow(sin(0.5*delta_lat_rad), 2.0)
425  + (GetCosLatitude() * cos(target_latitude)
426  * (pow(sin(0.5*delta_lon_rad), 2.0)));
427 
428  return 2.0 * GetRadius() * atan2(sqrt(distance_a), sqrt(1.0 - distance_a));
429 }
double GetLatitude() const
Get the latitude.
Definition: FGLocation.h:272
double GetRadius() const
Get the distance from the center of the earth.
Definition: FGLocation.h:323
double GetLongitude() const
Get the longitude.
Definition: FGLocation.h:254
double GetCosLatitude() const
Get the cosine of Latitude.
Definition: FGLocation.h:299
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetEPA()

double GetEPA ( ) const
inline

Return the Earth Position Angle.

This is the relative orientation of the ECEF frame with respect to the Inertial frame.

Returns
the Earth fixed frame (ECEF) rotation offset about the axis with respect to the Inertial (ECI) frame in radians.

Definition at line 316 of file FGLocation.h.

316 {return epa;}

◆ GetGeodAltitude()

double GetGeodAltitude ( void  ) const
inline

Gets the geodetic altitude in feet.

Definition at line 293 of file FGLocation.h.

293 {ComputeDerived(); return GeodeticAltitude;}
+ Here is the caller graph for this function:

◆ GetGeodLatitudeDeg()

double GetGeodLatitudeDeg ( void  ) const
inline

Get the geodetic latitude in degrees.

Returns
the geodetic latitude in degrees of the location represented by this class instance. The returned value is in the range between -90 <= lon <= 90. Latitude is positive north and negative south.

Definition at line 290 of file FGLocation.h.

290 { ComputeDerived(); return radtodeg*mGeodLat; }
+ Here is the caller graph for this function:

◆ GetGeodLatitudeRad()

double GetGeodLatitudeRad ( void  ) const
inline

Get the geodetic latitude.

Returns
the geodetic latitude in rad of the location represented with this class instance. The returned values are in the range between -pi/2 <= lon <= pi/2. Latitude is positive north and negative south.

Definition at line 278 of file FGLocation.h.

278 { ComputeDerived(); return mGeodLat; }
+ Here is the caller graph for this function:

◆ GetGroundCallback()

static FGGroundCallback* GetGroundCallback ( void  )
inlinestatic

Get a pointer to the ground callback currently used.

Since the FGGroundcallback instance might have been created outside JSBSim, it is recommanded to store the returned pointer in a 'smart pointer' FGGroundCallback_ptr. This pointer maintains a reference counter and protects the returned pointer against an accidental deletion of the object it is pointing to.

Returns
A pointer to the current ground callback object.
See also
FGGroundCallback

Definition at line 404 of file FGLocation.h.

404 { return GroundCallback; }
+ Here is the caller graph for this function:

◆ GetHeadingTo()

double GetHeadingTo ( double  target_longitude,
double  target_latitude 
) const

Get the heading that should be followed from the current location to a given location along the shortest path.

Earth curvature is taken into account.

Parameters
target_longitudethe target longitude
target_latitudethe target latitude
Returns
The heading that should be followed to reach the targeted location along the shortest path

Definition at line 447 of file FGLocation.cpp.

449 {
450  double delta_lon_rad = target_longitude - GetLongitude();
451 
452  double Y = sin(delta_lon_rad) * cos(target_latitude);
453  double X = GetCosLatitude() * sin(target_latitude)
454  - GetSinLatitude() * cos(target_latitude) * cos(delta_lon_rad);
455 
456  double heading_to_waypoint_rad = atan2(Y, X);
457  if (heading_to_waypoint_rad < 0) heading_to_waypoint_rad += 2.0*M_PI;
458 
459  return heading_to_waypoint_rad;
460 }
double GetSinLatitude() const
Get the sine of Latitude.
Definition: FGLocation.h:296
double GetLongitude() const
Get the longitude.
Definition: FGLocation.h:254
double GetCosLatitude() const
Get the cosine of Latitude.
Definition: FGLocation.h:299
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetLatitude()

double GetLatitude ( void  ) const
inline

Get the latitude.

Returns
the latitude in rad of the location represented with this class instance. The returned values are in the range between -pi/2 <= lon <= pi/2. Latitude is positive north and negative south.

Definition at line 272 of file FGLocation.h.

272 { ComputeDerived(); return mLat; }
+ Here is the caller graph for this function:

◆ GetLatitudeDeg()

double GetLatitudeDeg ( void  ) const
inline

Get the latitude.

Returns
the latitude in deg of the location represented with this class instance. The returned value is in the range between -90 <= lon <= 90. Latitude is positive north and negative south.

Definition at line 284 of file FGLocation.h.

284 { ComputeDerived(); return radtodeg*mLat; }
+ Here is the caller graph for this function:

◆ GetLongitude()

double GetLongitude ( void  ) const
inline

Get the longitude.

Returns
the longitude in rad of the location represented with this class instance. The returned values are in the range between -pi <= lon <= pi. Longitude is positive east and negative west.

Definition at line 254 of file FGLocation.h.

254 { ComputeDerived(); return mLon; }
+ Here is the caller graph for this function:

◆ GetLongitudeDeg()

double GetLongitudeDeg ( void  ) const
inline

Get the longitude.

Returns
the longitude in deg of the location represented with this class instance. The returned values are in the range between -180 <= lon <= 180. Longitude is positive east and negative west.

Definition at line 260 of file FGLocation.h.

260 { ComputeDerived(); return radtodeg*mLon; }
+ Here is the caller graph for this function:

◆ GetRadius()

double GetRadius ( void  ) const
inline

Get the distance from the center of the earth.

Returns
the distance of the location represented with this class instance to the center of the earth in ft. The radius value is always positive.

Definition at line 323 of file FGLocation.h.

323 { ComputeDerived(); return mRadius; }
+ Here is the caller graph for this function:

◆ GetSeaLevelRadius()

double GetSeaLevelRadius ( void  ) const
inline

Get the local sea level radius.

Returns
the sea level radius at the location in feet.
See also
SetGroundCallback

Definition at line 347 of file FGLocation.h.

348  { ComputeDerived(); return GroundCallback->GetSeaLevelRadius(*this); }
+ Here is the caller graph for this function:

◆ GetSinLatitude()

double GetSinLatitude ( ) const
inline

Get the sine of Latitude.

Definition at line 296 of file FGLocation.h.

296 { ComputeDerived(); return -mTec2l(3,3); }
+ Here is the caller graph for this function:

◆ GetSinLongitude()

double GetSinLongitude ( ) const
inline

Get the sine of Longitude.

Definition at line 263 of file FGLocation.h.

263 { ComputeDerived(); return -mTec2l(2,1); }

◆ GetTanLatitude()

double GetTanLatitude ( ) const
inline

Get the cosine of Latitude.

Definition at line 302 of file FGLocation.h.

302  {
303  ComputeDerived();
304  double cLat = mTec2l(1,3);
305  if (cLat == 0.0)
306  return 0.0;
307  else
308  return -mTec2l(3,3)/cLat;
309  }
+ Here is the caller graph for this function:

◆ GetTec2i()

const FGMatrix33& GetTec2i ( void  ) const
inline

Transform matrix from the earth centered to inertial frame.

Returns
a const reference to the rotation matrix of the transform from the earth centered frame to the inertial frame (ECEF to ECI).
See also
SetEarthPositionAngle
IncrementEarthPositionAngle

Definition at line 428 of file FGLocation.h.

428 { ComputeDerived(); return mTec2i; }
+ Here is the caller graph for this function:

◆ GetTec2l()

const FGMatrix33& GetTec2l ( void  ) const
inline

Transform matrix from the earth centered to local horizontal frame.

Returns
a const reference to the rotation matrix of the transform from the earth centered frame to the local horizontal frame.

Definition at line 414 of file FGLocation.h.

414 { ComputeDerived(); return mTec2l; }
+ Here is the caller graph for this function:

◆ GetTerrainRadius()

double GetTerrainRadius ( void  ) const
inline

Get the local terrain radius.

Returns
the terrain level radius at the location in feet.
See also
SetGroundCallback

Definition at line 353 of file FGLocation.h.

354  { ComputeDerived(); return GroundCallback->GetTerrainGeoCentRadius(*this); }
+ Here is the caller graph for this function:

◆ GetTi2ec()

const FGMatrix33& GetTi2ec ( void  ) const
inline

Transform matrix from inertial to earth centered frame.

Returns
a const reference to the rotation matrix of the transform from the inertial frame to the earth centered frame (ECI to ECEF).
See also
SetEarthPositionAngle
IncrementEarthPositionAngle

Definition at line 421 of file FGLocation.h.

421 { ComputeDerived(); return mTi2ec; }
+ Here is the caller graph for this function:

◆ GetTi2l()

const FGMatrix33& GetTi2l ( void  ) const
inline

Transform matrix from the inertial to local horizontal frame.

Returns
a const reference to the rotation matrix of the transform from the inertial frame to the local horizontal frame.
See also
SetEarthPositionAngle
IncrementEarthPositionAngle

Definition at line 435 of file FGLocation.h.

435 {ComputeDerived(); return mTi2l;}
+ Here is the caller graph for this function:

◆ GetTl2ec()

const FGMatrix33& GetTl2ec ( void  ) const
inline

Transform matrix from local horizontal to earth centered frame.

Returns
a const reference to the rotation matrix of the transform from the local horizontal frame to the earth centered frame.

Definition at line 409 of file FGLocation.h.

409 { ComputeDerived(); return mTl2ec; }
+ Here is the caller graph for this function:

◆ GetTl2i()

const FGMatrix33& GetTl2i ( void  ) const
inline

Transform matrix from local horizontal to inertial frame.

Returns
a const reference to the rotation matrix of the transform from the local horizontal frame to the inertial frame.
See also
SetEarthPositionAngle
IncrementEarthPositionAngle

Definition at line 442 of file FGLocation.h.

442 {ComputeDerived(); return mTl2i;}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IncrementEarthPositionAngle()

void IncrementEarthPositionAngle ( double  delta)
inline

Increments the Earth position angle.

This is the relative orientation of the ECEF frame with respect to the Inertial frame.

Parameters
deltadelta to the Earth fixed frame (ECEF) rotation offset about the axis with respect to the Inertial (ECI) frame in radians.

Definition at line 248 of file FGLocation.h.

248 {epa += delta; mCacheValid = false;}
+ Here is the caller graph for this function:

◆ LocalToLocation()

FGLocation LocalToLocation ( const FGColumnVector3 lvec) const
inline

Conversion from Local frame coordinates to a location in the earth centered and fixed frame.

This function calculates the FGLocation of an object which position relative to the vehicle is given as in input.

Parameters
lvecVector in the local horizontal coordinate frame
Returns
The location in the earth centered and fixed frame

Definition at line 467 of file FGLocation.h.

467  {
468  ComputeDerived(); return mTl2ec*lvec + mECLoc;
469  }
+ Here is the caller graph for this function:

◆ LocationToLocal()

FGColumnVector3 LocationToLocal ( const FGColumnVector3 ecvec) const
inline

Conversion from a location in the earth centered and fixed frame to local horizontal frame coordinates.

This function calculates the relative position between the vehicle and the input vector and returns the result expressed in the local frame.

Parameters
ecvecVector in the earth centered and fixed frame
Returns
The vector in the local horizontal coordinate frame

Definition at line 477 of file FGLocation.h.

477  {
478  ComputeDerived(); return mTec2l*(ecvec - mECLoc);
479  }

◆ operator!=()

bool operator!= ( const FGLocation l) const
inline

This operator returns true if the ECEF location vectors for the two location objects are not equal.

Definition at line 548 of file FGLocation.h.

548 { return ! operator==(l); }
bool operator==(const FGLocation &l) const
This operator returns true if the ECEF location vectors for the two location objects are equal...
Definition: FGLocation.h:542
+ Here is the call graph for this function:

◆ operator()() [1/2]

double operator() ( unsigned int  idx) const
inline

Read access the entries of the vector.

Parameters
idxthe component index. Return the value of the matrix entry at the given index. Indices are counted starting with 1. Note that the index given in the argument is unchecked.

Definition at line 488 of file FGLocation.h.

488 { return mECLoc.Entry(idx); }
double Entry(const unsigned int idx) const
Read access the entries of the vector.
+ Here is the call graph for this function:

◆ operator()() [2/2]

double& operator() ( unsigned int  idx)
inline

Write access the entries of the vector.

Parameters
idxthe component index.
Returns
a reference to the vector entry at the given index. Indices are counted starting with 1. Note that the index given in the argument is unchecked.

Definition at line 495 of file FGLocation.h.

495 { mCacheValid = false; return mECLoc.Entry(idx); }
double Entry(const unsigned int idx) const
Read access the entries of the vector.
+ Here is the call graph for this function:

◆ operator*()

FGLocation operator* ( double  scalar) const
inline

This operator scales an ECEF position vector.

A new object is returned that defines a position made of the cartesian coordinates of the provided ECEF position scaled by the supplied scalar value.

Definition at line 606 of file FGLocation.h.

606  {
607  return FGLocation(scalar*mECLoc);
608  }
FGLocation(void)
Default constructor.
Definition: FGLocation.cpp:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator*=()

const FGLocation& operator*= ( double  scalar)
inline

This operator scales the ECEF position vector.

The cartesian coordinates of the ECEF position vector on the left side of the equality are scaled by the supplied value (right side), and a reference to this object is returned.

Definition at line 574 of file FGLocation.h.

574  {
575  mCacheValid = false;
576  mECLoc *= scalar;
577  return *this;
578  }
+ Here is the caller graph for this function:

◆ operator+()

FGLocation operator+ ( const FGLocation l) const
inline

This operator adds two ECEF position vectors.

A new object is returned that defines a position which is the sum of the cartesian coordinates of the two positions provided.

Definition at line 591 of file FGLocation.h.

591  {
592  return FGLocation(mECLoc + l.mECLoc);
593  }
FGLocation(void)
Default constructor.
Definition: FGLocation.cpp:60
+ Here is the call graph for this function:

◆ operator+=()

const FGLocation& operator+= ( const FGLocation l)
inline

This operator adds the ECEF position vectors.

The cartesian coordinates of the supplied vector (right side) are added to the ECEF position vector on the left side of the equality, and a reference to this object is returned.

Definition at line 554 of file FGLocation.h.

554  {
555  mCacheValid = false;
556  mECLoc += l.mECLoc;
557  return *this;
558  }

◆ operator-()

FGLocation operator- ( const FGLocation l) const
inline

This operator substracts two ECEF position vectors.

A new object is returned that defines a position which is the difference of the cartesian coordinates of the two positions provided.

Definition at line 598 of file FGLocation.h.

598  {
599  return FGLocation(mECLoc - l.mECLoc);
600  }
FGLocation(void)
Default constructor.
Definition: FGLocation.cpp:60
+ Here is the call graph for this function:

◆ operator-=()

const FGLocation& operator-= ( const FGLocation l)
inline

This operator substracts the ECEF position vectors.

The cartesian coordinates of the supplied vector (right side) are substracted from the ECEF position vector on the left side of the equality, and a reference to this object is returned.

Definition at line 564 of file FGLocation.h.

564  {
565  mCacheValid = false;
566  mECLoc -= l.mECLoc;
567  return *this;
568  }

◆ operator/=()

const FGLocation& operator/= ( double  scalar)
inline

This operator scales the ECEF position vector.

The cartesian coordinates of the ECEF position vector on the left side of the equality are scaled by the inverse of the supplied value (right side), and a reference to this object is returned.

Definition at line 584 of file FGLocation.h.

584  {
585  return operator*=(1.0/scalar);
586  }
const FGLocation & operator*=(double scalar)
This operator scales the ECEF position vector.
Definition: FGLocation.h:574
+ Here is the call graph for this function:

◆ operator=() [1/2]

const FGLocation& operator= ( const FGColumnVector3 v)
inline

Sets this location via the supplied vector.

The location can be set by an Earth-centered, Earth-fixed (ECEF) frame position vector. The cache is marked as invalid, so any future requests for selected important data will cause the parameters to be calculated.

Parameters
vthe ECEF column vector in feet.
Returns
a reference to the FGLocation object.

Definition at line 525 of file FGLocation.h.

526  {
527  mECLoc(eX) = v(eX);
528  mECLoc(eY) = v(eY);
529  mECLoc(eZ) = v(eZ);
530  mCacheValid = false;
531  //ComputeDerived();
532  return *this;
533  }

◆ operator=() [2/2]

const FGLocation & operator= ( const FGLocation l)

Sets this location via the supplied location object.

Parameters
vA location object reference.
Returns
a reference to the FGLocation object.

Definition at line 163 of file FGLocation.cpp.

164 {
165  mECLoc = l.mECLoc;
166  mCacheValid = l.mCacheValid;
167 
168  a = l.a;
169  e2 = l.e2;
170  c = l.c;
171  ec = l.ec;
172  ec2 = l.ec2;
173  epa = l.epa;
174 
175  //ag See comment in constructor above
176  if (!mCacheValid) return *this;
177 
178  mLon = l.mLon;
179  mLat = l.mLat;
180  mRadius = l.mRadius;
181 
182  mTl2ec = l.mTl2ec;
183  mTec2l = l.mTec2l;
184  mTi2ec = l.mTi2ec;
185  mTec2i = l.mTec2i;
186  mTi2l = l.mTi2l;
187  mTl2i = l.mTl2i;
188 
189  mGeodLat = l.mGeodLat;
190  GeodeticAltitude = l.GeodeticAltitude;
191 
192  return *this;
193 }

◆ operator==()

bool operator== ( const FGLocation l) const
inline

This operator returns true if the ECEF location vectors for the two location objects are equal.

Definition at line 542 of file FGLocation.h.

542  {
543  return mECLoc == l.mECLoc;
544  }
+ Here is the caller graph for this function:

◆ SetAltitudeAGL()

void SetAltitudeAGL ( double  altitudeAGL)
inline

Set the altitude above ground level.

Parameters
altitudeAGLaltitude above Ground Level in feet.
See also
SetGroundCallback

Definition at line 341 of file FGLocation.h.

342  { SetRadius(GetTerrainRadius() + altitudeAGL); }
void SetRadius(double radius)
Set the distance from the center of the earth.
Definition: FGLocation.cpp:241
double GetTerrainRadius(void) const
Get the local terrain radius.
Definition: FGLocation.h:353
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetAltitudeASL()

void SetAltitudeASL ( double  altitudeASL)
inline

Set the altitude above sea level.

Parameters
altitudeASLaltitude above Sea Level in feet.
See also
SetGroundCallback

Definition at line 335 of file FGLocation.h.

336  { SetRadius(GetSeaLevelRadius() + altitudeASL); }
double GetSeaLevelRadius(void) const
Get the local sea level radius.
Definition: FGLocation.h:347
void SetRadius(double radius)
Set the distance from the center of the earth.
Definition: FGLocation.cpp:241
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetEarthPositionAngle()

void SetEarthPositionAngle ( double  EPA)
inline

Sets the Earth position angle.

This is the relative orientation of the ECEF frame with respect to the Inertial frame.

Parameters
EPAEarth fixed frame (ECEF) rotation offset about the axis with respect to the Inertial (ECI) frame in radians.

Definition at line 241 of file FGLocation.h.

241 {epa = EPA; mCacheValid = false;}
+ Here is the caller graph for this function:

◆ SetEllipse()

void SetEllipse ( double  semimajor,
double  semiminor 
)

Sets the semimajor and semiminor axis lengths for this planet.

The eccentricity and flattening are calculated from the semimajor and semiminor axis lengths

Definition at line 285 of file FGLocation.cpp.

286 {
287  mCacheValid = false;
288 
289  a = semimajor;
290  ec = semiminor/a;
291  ec2 = ec * ec;
292  e2 = 1.0 - ec2;
293  c = a * e2;
294 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetGroundCallback()

static void SetGroundCallback ( FGGroundCallback gc)
inlinestatic

Sets the ground callback pointer.

The FGGroundCallback instance will be interrogated by FGLocation each time some terrain informations are needed. This will mainly occur when altitudes above the sea level or above the ground level are needed. A 'smart pointer' is used internally to prevent the FGGroundCallback instance against accidental deletion. This can only work if the calling application also make use of FGGroundCallback_ptr 'smart pointers' to manage their copy of the ground callback.

Parameters
gcA pointer to a ground callback object
See also
FGGroundCallback

Definition at line 393 of file FGLocation.h.

393 { GroundCallback = gc; }
+ Here is the caller graph for this function:

◆ SetLatitude()

void SetLatitude ( double  latitude)

Set the latitude.

Parameters
latitudeLatitude in rad to set. Sets the latitude of the location represented with this class instance to the value of the given argument. The value is meant to be in rad. The longitude and the radius value are preserved with this call with the exception of radius being equal to zero. If the radius is previously set to zero it is changed to be equal to 1.0 past this call. Latitude is positive north and negative south. The arguments should be within the bounds of -pi/2 <= lat <= pi/2. The behavior of this function with arguments outside this range is left as an exercise to the gentle reader ...

Definition at line 217 of file FGLocation.cpp.

218 {
219  mCacheValid = false;
220 
221  double r = mECLoc.Magnitude();
222  if (r == 0.0) {
223  mECLoc(eX) = 1.0;
224  r = 1.0;
225  }
226 
227  double rtmp = mECLoc.Magnitude(eX, eY);
228  if (rtmp != 0.0) {
229  double fac = r/rtmp*cos(latitude);
230  mECLoc(eX) *= fac;
231  mECLoc(eY) *= fac;
232  } else {
233  mECLoc(eX) = r*cos(latitude);
234  mECLoc(eY) = 0.0;
235  }
236  mECLoc(eZ) = r*sin(latitude);
237 }
double Magnitude(void) const
Length of the vector.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetLongitude()

void SetLongitude ( double  longitude)

Set the longitude.

Parameters
longitudeLongitude in rad to set. Sets the longitude of the location represented with this class instance to the value of the given argument. The value is meant to be in rad. The latitude and the radius value are preserved with this call with the exception of radius being equal to zero. If the radius is previously set to zero it is changed to be equal to 1.0 past this call. Longitude is positive east and negative west.

Definition at line 197 of file FGLocation.cpp.

198 {
199  double rtmp = mECLoc.Magnitude(eX, eY);
200  // Check if we have zero radius.
201  // If so set it to 1, so that we can set a position
202  if (0.0 == mECLoc.Magnitude())
203  rtmp = 1.0;
204 
205  // Fast return if we are on the north or south pole ...
206  if (rtmp == 0.0)
207  return;
208 
209  mCacheValid = false;
210 
211  mECLoc(eX) = rtmp*cos(longitude);
212  mECLoc(eY) = rtmp*sin(longitude);
213 }
double Magnitude(void) const
Length of the vector.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetPosition()

void SetPosition ( double  lon,
double  lat,
double  radius 
)

Sets the longitude, latitude and the distance from the center of the earth.

Parameters
lonlongitude in radians
latGEOCENTRIC latitude in radians
radiusdistance from center of earth to vehicle in feet

Definition at line 254 of file FGLocation.cpp.

255 {
256  mCacheValid = false;
257 
258  double sinLat = sin(lat);
259  double cosLat = cos(lat);
260  double sinLon = sin(lon);
261  double cosLon = cos(lon);
262 
263  mECLoc = FGColumnVector3( radius*cosLat*cosLon,
264  radius*cosLat*sinLon,
265  radius*sinLat );
266 }

◆ SetPositionGeodetic()

void SetPositionGeodetic ( double  lon,
double  lat,
double  height 
)

Sets the longitude, latitude and the distance above the reference ellipsoid.

Parameters
lonlongitude in radians
latGEODETIC latitude in radians
heightdistance above the reference ellipsoid to vehicle in feet

Definition at line 270 of file FGLocation.cpp.

271 {
272  mCacheValid = false;
273 
274  double slat = sin(lat);
275  double clat = cos(lat);
276  double RN = a / sqrt(1.0 - e2*slat*slat);
277 
278  mECLoc(eX) = (RN + height)*clat*cos(lon);
279  mECLoc(eY) = (RN + height)*clat*sin(lon);
280  mECLoc(eZ) = ((1 - e2)*RN + height)*slat;
281 }
+ Here is the caller graph for this function:

◆ SetRadius()

void SetRadius ( double  radius)

Set the distance from the center of the earth.

Parameters
radiusRadius in ft to set. Sets the radius of the location represented with this class instance to the value of the given argument. The value is meant to be in ft. The latitude and longitude values are preserved with this call with the exception of radius being equal to zero. If the radius is previously set to zero, latitude and longitude is set equal to zero past this call. The argument should be positive. The behavior of this function called with a negative argument is left as an exercise to the gentle reader ...

Definition at line 241 of file FGLocation.cpp.

242 {
243  mCacheValid = false;
244 
245  double rold = mECLoc.Magnitude();
246  if (rold == 0.0)
247  mECLoc(eX) = radius;
248  else
249  mECLoc *= radius/rold;
250 }
double Magnitude(void) const
Length of the vector.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: