From 578af00b0d48100c540154f54293a1b77a0655fe Mon Sep 17 00:00:00 2001 From: jmt Date: Thu, 31 Dec 2009 16:48:03 +0000 Subject: [PATCH] Allow geocentric distance computations to return radians. --- simgear/math/SGGeodesy.cxx | 11 +++++++++-- simgear/math/SGGeodesy.hxx | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/simgear/math/SGGeodesy.cxx b/simgear/math/SGGeodesy.cxx index 208218b7..b9974f14 100644 --- a/simgear/math/SGGeodesy.cxx +++ b/simgear/math/SGGeodesy.cxx @@ -540,7 +540,7 @@ SGGeodesy::courseRad(const SGGeoc& from, const SGGeoc& to) } double -SGGeodesy::distanceM(const SGGeoc& from, const SGGeoc& to) +SGGeodesy::distanceRad(const SGGeoc& from, const SGGeoc& to) { // d = 2*asin(sqrt((sin((lat1-lat2)/2))^2 + // cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2)) @@ -550,5 +550,12 @@ SGGeodesy::distanceM(const SGGeoc& from, const SGGeoc& to) double tmp2 = sin(0.5*(from.getLongitudeRad() - to.getLongitudeRad())); double square = tmp1*tmp1 + cosLatFrom*cosLatTo*tmp2*tmp2; double s = SGMiscd::min(sqrt(SGMiscd::max(square, 0)), 1); - return 2 * asin(s) * SG_RAD_TO_NM * SG_NM_TO_METER; + return 2 * asin(s); +} + + +double +SGGeodesy::distanceM(const SGGeoc& from, const SGGeoc& to) +{ + return distanceRad(from, to) * SG_RAD_TO_NM * SG_NM_TO_METER; } diff --git a/simgear/math/SGGeodesy.hxx b/simgear/math/SGGeodesy.hxx index 53e2cbb3..ef1be21f 100644 --- a/simgear/math/SGGeodesy.hxx +++ b/simgear/math/SGGeodesy.hxx @@ -61,6 +61,7 @@ public: static void advanceRadM(const SGGeoc& geoc, double course, double distance, SGGeoc& result); static double courseRad(const SGGeoc& from, const SGGeoc& to); + static double distanceRad(const SGGeoc& from, const SGGeoc& to); static double distanceM(const SGGeoc& from, const SGGeoc& to); }; -- 2.39.5