diff --git a/geo/geo.cpp b/geo/geo.cpp index 28bb3dcda8..876745ef9c 100644 --- a/geo/geo.cpp +++ b/geo/geo.cpp @@ -524,10 +524,10 @@ float get_distance_to_point_global_wgs84(double lat_now, double lon_now, float a double lat_next, double lon_next, float alt_next, float *dist_xy, float *dist_z) { - double current_x_rad = lat_next / 180.0 * M_PI; - double current_y_rad = lon_next / 180.0 * M_PI; - double x_rad = lat_now / 180.0 * M_PI; - double y_rad = lon_now / 180.0 * M_PI; + double current_x_rad = math::radians(lat_next); + double current_y_rad = math::radians(lon_next); + double x_rad = math::radians(lat_now); + double y_rad = math::radians(lon_now); double d_lat = x_rad - current_x_rad; double d_lon = y_rad - current_y_rad; diff --git a/mathlib/mathlib.h b/mathlib/mathlib.h index 0bcbf7f44c..57bc724586 100644 --- a/mathlib/mathlib.h +++ b/mathlib/mathlib.h @@ -57,19 +57,29 @@ namespace math { template -Type min(Type val1, Type val2) { return (val1 < val2) ? val1 : val2; } +Type min(Type val1, Type val2) { + return (val1 < val2) ? val1 : val2; +} template -Type max(Type val1, Type val2) { return (val1 > val2) ? val1 : val2; } +Type max(Type val1, Type val2) { + return (val1 > val2) ? val1 : val2; +} template -Type constrain(Type val, Type min, Type max) { return (val < min) ? min : ((val > max) ? max : val); } +Type constrain(Type val, Type min, Type max) { + return (val < min) ? min : ((val > max) ? max : val); +} template -Type radians(Type degrees) { return (degrees / Type(180)) * Type(M_PI); } +Type radians(Type degrees) { + return (degrees / Type(180)) * Type(M_PI); +} template -Type degrees(Type radians) { return (radians * Type(180)) / Type(M_PI); } +Type degrees(Type radians) { + return (radians * Type(180)) / Type(M_PI); +} } // namespace math #else