From a94a92af7fdba018e87f048cf05b7b5fc1b16c14 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Tue, 19 Nov 2019 23:05:50 -0400 Subject: [PATCH] Fix convertGeoToNed and convertNedToGeo --- src/Geo/QGCGeo.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Geo/QGCGeo.cc b/src/Geo/QGCGeo.cc index 9621b7572..cbe1d14cc 100644 --- a/src/Geo/QGCGeo.cc +++ b/src/Geo/QGCGeo.cc @@ -46,7 +46,7 @@ void convertGeoToNed(QGeoCoordinate coord, QGeoCoordinate origin, double* x, dou double ref_cos_lat = cos(ref_lat_rad); double c = acos(ref_sin_lat * sin_lat + ref_cos_lat * cos_lat * cos_d_lon); - double k = (abs(c) < epsilon) ? 1.0 : (c / sin(c)); + double k = (fabs(c) < epsilon) ? 1.0 : (c / sin(c)); *x = k * (ref_cos_lat * sin_lat - ref_sin_lat * cos_lat * cos_d_lon) * CONSTANTS_RADIUS_OF_EARTH; *y = k * cos_lat * sin(lon_rad - ref_lon_rad) * CONSTANTS_RADIUS_OF_EARTH; @@ -70,7 +70,7 @@ void convertNedToGeo(double x, double y, double z, QGeoCoordinate origin, QGeoCo double lat_rad; double lon_rad; - if (abs(c) > epsilon) { + if (fabs(c) > epsilon) { lat_rad = asin(cos_c * ref_sin_lat + (x_rad * sin_c * ref_cos_lat) / c); lon_rad = (ref_lon_rad + atan2(y_rad * sin_c, c * ref_cos_lat * cos_c - x_rad * ref_sin_lat * sin_c)); -- 2.22.0