FGLocation Class Reference

#include <FGLocation.h>

Inherits FGJSBBase.

List of all members.


Detailed Description

This coordinate frame has its center in the middle of the earth. Its x-axis points from the center of the earth towards a location with zero latitude and longitude on the earths surface. The y-axis points from the center of the earth towards a location with zero latitude and 90deg longitude on the earths surface. The z-axis points from the earths 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. 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 towards east and the z-axis points to the center of the earth.

Since this frame is determined by the location, this class also provides the rotation matrices required to transform from the earth centered frame to the local horizontal frame and back. There are also conversion functions for conversion of position vectors given in the one frame to positions in the other frame.

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

The coordinates 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, the earths surface radius is about 2*10^7, ft and that we use double values for the representation of the location, we have an accuracy of about 1e-16*2e7ft/1=2e-9ft 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.61deg north 122.35deg west, which corresponds to 0.65642rad north and 2.13541rad west. Both values are of magnitude of about 1. But 1ft corresponds to about 1/(2e7*2*pi)=7.9577e-09rad. 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 too.

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.13 2008/05/04 19:20:45 dpculp Exp

Definition at line 142 of file FGLocation.h.


Public Member Functions

double & Entry (unsigned int idx)
 Write access the entries of the vector.
double Entry (unsigned int idx) const
 Read access the entries of the vector.
 FGLocation (const FGLocation &l)
 Copy constructor.
 FGLocation (const FGColumnVector3 &lv)
 Column constructor.
 FGLocation (double lon, double lat, double radius)
 Constructor to set the longitude, latitude and the distance from the center of the earth.
 FGLocation (void)
 Default constructor.
double GetCosLatitude () const
 Get the cosine of Latitude.
double GetCosLongitude () const
 Get the cosine of Longitude.
double GetGeodAltitude (void) const
 Gets the geodetic altitude in feet.
double GetGeodLatitudeDeg (void) const
 Get the geodetic latitude in degrees.
double GetGeodLatitudeRad (void) const
 Get the geodetic latitude.
double GetLatitude () const
 Get the latitude.
double GetLatitudeDeg () const
 Get the latitude.
double GetLongitude () const
 Get the longitude.
double GetLongitudeDeg () const
 Get the longitude.
double GetRadius () const
 Get the distance from the center of the earth.
double GetSinLatitude () const
 Get the sine of Latitude.
double GetSinLongitude () const
 Get the sine of Longitude.
double GetTanLatitude () const
 Get the cosine of Latitude.
const FGMatrix33GetTec2i (double epa)
 Transform matrix from the earth centered to inertial frame.
const FGMatrix33GetTec2l (void) const
 Transform matrix from the earth centered to local horizontal frame.
const FGMatrix33GetTi2ec (double epa)
 Transform matrix from inertial to earth centered frame.
const FGMatrix33GetTl2ec (void) const
 Transform matrix from local horizontal to earth centered frame.
FGLocation LocalToLocation (const FGColumnVector3 &lvec) const
 Conversion from Local frame coordinates to a location in the earth centered and fixed frame.
FGColumnVector3 LocationToLocal (const FGColumnVector3 &ecvec) const
 Conversion from a location in the earth centered and fixed frame to local horizontal frame coordinates.
 operator const FGColumnVector3 & () const
 Cast to a simple 3d vector.
bool operator!= (const FGLocation &l) const
double & operator() (unsigned int idx)
 Write access the entries of the vector.
double operator() (unsigned int idx) const
 Read access the entries of the vector.
FGLocation operator* (double scalar) const
const FGLocationoperator*= (double scalar)
FGLocation operator+ (const FGLocation &l) const
const FGLocationoperator+= (const FGLocation &l)
FGLocation operator- (const FGLocation &l) const
const FGLocationoperator-= (const FGLocation &l)
const FGLocationoperator/= (double scalar)
const FGLocationoperator= (const FGLocation &l)
const FGLocationoperator= (const FGColumnVector3 &v)
bool operator== (const FGLocation &l) const
void SetEllipse (double semimajor, double semiminor)
 Sets the semimajor and semiminor axis lengths for this planet.
void SetLatitude (double latitude)
 Set the latitude.
void SetLongitude (double longitude)
 Set the longitude.
void SetPosition (double lon, double lat, double radius)
 Sets the longitude, latitude and the distance from the center of the earth.
void SetRadius (double radius)
 Set the distance from the center of the earth.

Constructor & Destructor Documentation

FGLocation ( void   ) 

Definition at line 55 of file FGLocation.cpp.

FGLocation ( double  lon,
double  lat,
double  radius 
)

Parameters:
lon longitude
lat GEOCENTRIC latitude
radius distance from center of earth to vehicle in feet

Definition at line 71 of file FGLocation.cpp.

FGLocation ( const FGColumnVector3 lv  )  [inline]

Definition at line 156 of file FGLocation.h.

FGLocation ( const FGLocation l  )  [inline]

Definition at line 169 of file FGLocation.h.


Member Function Documentation

double& Entry ( unsigned int  idx  )  [inline]

Parameters:
idx the 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 378 of file FGLocation.h.

double Entry ( unsigned int  idx  )  const [inline]

Parameters:
idx the 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 368 of file FGLocation.h.

double GetCosLatitude (  )  const [inline]

Definition at line 290 of file FGLocation.h.

double GetCosLongitude (  )  const [inline]

Definition at line 257 of file FGLocation.h.

double GetGeodAltitude ( void   )  const [inline]

Definition at line 284 of file FGLocation.h.

double GetGeodLatitudeDeg ( void   )  const [inline]

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 281 of file FGLocation.h.

double GetGeodLatitudeRad ( void   )  const [inline]

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 269 of file FGLocation.h.

double GetLatitude ( void   )  const [inline]

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 263 of file FGLocation.h.

double GetLatitudeDeg ( void   )  const [inline]

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 275 of file FGLocation.h.

double GetLongitude ( void   )  const [inline]

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 245 of file FGLocation.h.

double GetLongitudeDeg ( void   )  const [inline]

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 251 of file FGLocation.h.

double GetRadius ( void   )  const [inline]

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 306 of file FGLocation.h.

double GetSinLatitude (  )  const [inline]

Definition at line 287 of file FGLocation.h.

double GetSinLongitude (  )  const [inline]

Definition at line 254 of file FGLocation.h.

double GetTanLatitude (  )  const [inline]

Definition at line 293 of file FGLocation.h.

const FGMatrix33 & GetTec2i ( double  epa  ) 

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

Definition at line 189 of file FGLocation.cpp.

const FGMatrix33& GetTec2l ( void   )  const [inline]

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

Definition at line 316 of file FGLocation.h.

const FGMatrix33 & GetTi2ec ( double  epa  ) 

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

Definition at line 200 of file FGLocation.cpp.

const FGMatrix33& GetTl2ec ( void   )  const [inline]

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

Definition at line 311 of file FGLocation.h.

FGLocation LocalToLocation ( const FGColumnVector3 lvec  )  const [inline]

Parameters:
lvec Vector in the local horizontal coordinate frame
Returns:
The location in the earth centered and fixed frame

Definition at line 332 of file FGLocation.h.

FGColumnVector3 LocationToLocal ( const FGColumnVector3 ecvec  )  const [inline]

Parameters:
ecvec Vector in the earth centered and fixed frame
Returns:
The vector in the local horizontal coordinate frame

Definition at line 340 of file FGLocation.h.

double& operator() ( unsigned int  idx  )  [inline]

Parameters:
idx the 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 358 of file FGLocation.h.

double operator() ( unsigned int  idx  )  const [inline]

Parameters:
idx the 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 351 of file FGLocation.h.

void SetEllipse ( double  semimajor,
double  semiminor 
)

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

Definition at line 171 of file FGLocation.cpp.

void SetLatitude ( double  latitude  ) 

Parameters:
latitude Latitude 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 117 of file FGLocation.cpp.

void SetLongitude ( double  longitude  ) 

Parameters:
longitude Longitude 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 95 of file FGLocation.cpp.

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

Parameters:
lon longitude in radians
lat GEOCENTRIC latitude in radians
radius distance from center of earth to vehicle in feet

Definition at line 154 of file FGLocation.cpp.

void SetRadius ( double  radius  ) 

Parameters:
radius Radius 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 141 of file FGLocation.cpp.


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

Generated on Tue May 26 00:55:11 2009 for JSBSim Flight Dynamics Model by  doxygen 1.5.5