X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmath%2Fpolar3d.hxx;h=9721dc728b0bf51281727f03bd813487c764573c;hb=dfea3623f6549c9173fed5149da41285863fc290;hp=4a0c7ed798bb9af3da09341baefb43be1ccba29f;hpb=37b4005d3e117ac9b65d7a83fa69bd29e8092e63;p=simgear.git diff --git a/simgear/math/polar3d.hxx b/simgear/math/polar3d.hxx index 4a0c7ed7..9721dc72 100644 --- a/simgear/math/polar3d.hxx +++ b/simgear/math/polar3d.hxx @@ -17,10 +17,9 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the -// Free Software Foundation, Inc., 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ @@ -29,45 +28,12 @@ #define _POLAR3D_HXX -#ifndef __cplusplus +#ifndef __cplusplus # error This library requires C++ -#endif +#endif - -#include - -#include #include - - -/** - * 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 - */ -double sgGeodAltFromCart(const Point3D& cp); - - -/** - * 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 - */ -Point3D sgPolarToCart3d(const Point3D& p); - - -/** - * 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 - */ -Point3D sgCartToPolar3d(const Point3D& cp); - +#include "SGMath.hxx" /** * Calculate new lon/lat given starting lon/lat, and offset radial, and @@ -79,7 +45,8 @@ Point3D sgCartToPolar3d(const Point3D& cp); * @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)); } /** @@ -89,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