]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/polar3d.hxx
Merge branch 'tat/framework'
[simgear.git] / simgear / math / polar3d.hxx
index 75d1f26cd65e8d4867050a7188ce4e4233d0dc09..9721dc728b0bf51281727f03bd813487c764573c 100644 (file)
 # error This library requires C++
 #endif
 
-
-#include <simgear/constants.h>
 #include <simgear/math/point3d.hxx>
-
 #include "SGMath.hxx"
 
-/** 
- * Find the Altitude above the Ellipsoid (WGS84) given the Earth
- * Centered Cartesian coordinate vector Distances are specified in
- * meters.
- * @param cp point specified in cartesian coordinates
- * @return altitude above the (wgs84) earth in meters
- */
-inline double sgGeodAltFromCart(const Point3D& p)
-{
-  SGGeod geod;
-  SGGeodesy::SGCartToGeod(SGVec3<double>(p.x(), p.y(), p.z()), geod);
-  return geod.getElevationM();
-}
-
-
-/**
- * Convert a polar coordinate to a cartesian coordinate.  Lon and Lat
- * must be specified in radians.  The SG convention is for distances
- * to be specified in meters
- * @param p point specified in polar coordinates
- * @return the same point in cartesian coordinates
- */
-inline Point3D sgPolarToCart3d(const Point3D& p)
-{
-  SGVec3<double> cart;
-  SGGeodesy::SGGeocToCart(SGGeoc::fromRadM(p.lon(), p.lat(), p.radius()), cart);
-  return Point3D::fromSGVec3(cart);
-}
-
-
-/**
- * Convert a cartesian coordinate to polar coordinates (lon/lat
- * specified in radians.  Distances are specified in meters.
- * @param cp point specified in cartesian coordinates
- * @return the same point in polar coordinates
- */
-inline Point3D sgCartToPolar3d(const Point3D& p)
-{
-  SGGeoc geoc;
-  SGGeodesy::SGCartToGeoc(SGVec3<double>(p.x(), p.y(), p.z()), geoc);
-  return Point3D::fromSGGeoc(geoc);
-}
-
-
 /**
  * Calculate new lon/lat given starting lon/lat, and offset radial, and
  * distance.  NOTE: starting point is specifed in radians, distance is
@@ -92,7 +45,8 @@ inline Point3D sgCartToPolar3d(const Point3D& p)
  * @param dist offset distance
  * @return destination point in polar coordinates
  */
-Point3D calc_gc_lon_lat( const Point3D& orig, double course, double dist );
+inline Point3D calc_gc_lon_lat(const Point3D& orig, double course, double dist)
+{ return Point3D::fromSGGeoc(orig.toSGGeoc().advanceRadM(course, dist)); }
 
 
 /**
@@ -102,20 +56,14 @@ Point3D calc_gc_lon_lat( const Point3D& orig, double course, double dist );
  * @param course resulting course
  * @param dist resulting distance
  */
-void calc_gc_course_dist( const Point3D& start, const Point3D& dest, 
-                                 double *course, double *dist );
-
-#if 0
-/**
- * Calculate course/dist given two spherical points.
- * @param start starting point
- * @param dest ending point
- * @param course resulting course
- * @param dist resulting distance
- */
-void calc_gc_course_dist( const Point3D& start, const Point3D& dest, 
-                                double *course, double *dist );
-#endif // 0
+inline void calc_gc_course_dist( const Point3D& start, const Point3D& dest, 
+                                 double *course, double *dist )
+{
+  SGGeoc gs = start.toSGGeoc();
+  SGGeoc gd = dest.toSGGeoc();
+  *course = SGGeoc::courseRad(gs, gd);
+  *dist = SGGeoc::distanceM(gs, gd);
+}
 
 #endif // _POLAR3D_HXX