sg_geodesy.hxx

00001 #ifndef _SG_GEODESY_HXX
00002 #define _SG_GEODESY_HXX
00003 
00004 #include <simgear/math/point3d.hxx>
00005 #include "SGMath.hxx"
00006 
00016 inline void sgGeocToGeod(double lat_geoc, double radius,
00017                          double *lat_geod, double *alt, double *sea_level_r)
00018 {
00019   SGVec3<double> cart;
00020   SGGeodesy::SGGeocToCart(SGGeoc::fromRadM(0, lat_geoc, radius), cart);
00021   SGGeod geod;
00022   SGGeodesy::SGCartToGeod(cart, geod);
00023   *lat_geod = geod.getLatitudeRad();
00024   *alt = geod.getElevationM();
00025   *sea_level_r = SGGeodesy::SGGeodToSeaLevelRadius(geod);
00026 }
00027 
00043 inline void sgGeodToGeoc(double lat_geod, double alt,
00044                          double *sl_radius, double *lat_geoc)
00045 {
00046   SGVec3<double> cart;
00047   SGGeod geod = SGGeod::fromRadM(0, lat_geod, alt);
00048   SGGeodesy::SGGeodToCart(geod, cart);
00049   SGGeoc geoc;
00050   SGGeodesy::SGCartToGeoc(cart, geoc);
00051   *lat_geoc = geoc.getLatitudeRad();
00052   *sl_radius = SGGeodesy::SGGeodToSeaLevelRadius(geod);
00053 }
00054 
00055 
00064 inline void sgCartToGeod(const double* xyz, double* lat, double* lon, double* alt)
00065 {
00066   SGGeod geod;
00067   SGGeodesy::SGCartToGeod(SGVec3<double>(xyz), geod);
00068   *lat = geod.getLatitudeRad();
00069   *lon = geod.getLongitudeRad();
00070   *alt = geod.getElevationM();
00071 }
00072 
00080 inline Point3D sgCartToGeod(const Point3D& p)
00081 {
00082   SGGeod geod;
00083   SGGeodesy::SGCartToGeod(SGVec3<double>(p.x(), p.y(), p.z()), geod);
00084   return Point3D::fromSGGeod(geod);
00085 }
00086 
00087 
00096 inline void sgGeodToCart(double lat, double lon, double alt, double* xyz)
00097 {
00098   SGVec3<double> cart;
00099   SGGeodesy::SGGeodToCart(SGGeod::fromRadM(lon, lat, alt), cart);
00100   xyz[0] = cart(0);
00101   xyz[1] = cart(1);
00102   xyz[2] = cart(2);
00103 }
00104 
00112 inline Point3D sgGeodToCart(const Point3D& geod)
00113 {
00114   SGVec3<double> cart;
00115   SGGeodesy::SGGeodToCart(SGGeod::fromRadM(geod.lon(), geod.lat(), geod.elev()), cart);
00116   return Point3D::fromSGVec3(cart);
00117 }
00118 
00131 int geo_direct_wgs_84 ( double lat1, double lon1, double az1, 
00132                         double s, double *lat2, double *lon2,
00133                         double *az2 );
00134 inline int geo_direct_wgs_84 ( double alt, double lat1,
00135                         double lon1, double az1, 
00136                         double s, double *lat2, double *lon2,
00137                         double *az2 )
00138 { return geo_direct_wgs_84(lat1, lon1, az1, s, lat2, lon2, az2); }
00139 
00149 inline int geo_direct_wgs_84(const SGGeod& p1, double az1,
00150                              double s, SGGeod& p2, double *az2 )
00151 {
00152   double lat2, lon2;
00153   int ret = geo_direct_wgs_84(p1.getLatitudeDeg(), p1.getLongitudeDeg(),
00154                               az1, s, &lat2, &lon2, az2);
00155   p2.setLatitudeDeg(lat2);
00156   p2.setLongitudeDeg(lon2);
00157   return ret;
00158 }
00159 
00172 int geo_inverse_wgs_84( double lat1, double lon1, double lat2,
00173                         double lon2, double *az1, double *az2,
00174                         double *s );
00175 inline int geo_inverse_wgs_84( double alt, double lat1,
00176                                double lon1, double lat2,
00177                                double lon2, double *az1, double *az2,
00178                                double *s )
00179 { return geo_inverse_wgs_84(lat1, lon1, lat2, lon2, az1, az2, s); }
00180 
00181 
00191 inline int geo_inverse_wgs_84(const SGGeod& p1, const SGGeod& p2,
00192                               double *az1, double *az2, double *s )
00193 {
00194   return geo_inverse_wgs_84(p1.getLatitudeDeg(), p1.getLongitudeDeg(),
00195                             p2.getLatitudeDeg(), p2.getLongitudeDeg(),
00196                             az1, az2, s);
00197 }
00198 
00199 #endif // _SG_GEODESY_HXX

Generated on Mon Dec 17 09:30:55 2007 for SimGear by  doxygen 1.5.1