Skip to content

Commit

Permalink
[Refactor] Update gps to utm conveter utils for better clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
artzha committed Nov 10, 2024
1 parent 78fc399 commit f2f5f6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions math/conversion.h → math/gps_util.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#ifndef GPS_UTIL_H_
#define GPS_UTIL_H_

#include <math.h>
#include <tuple>

std::tuple<double, double, int> gpsToUTM(double lat, double lon) {
namespace gps_util {
inline std::tuple<double, double, int> gpsToUTM(double lat, double lon) {
// Constants for UTM conversion
constexpr double a = 6378137.0; // WGS-84 major axis
constexpr double f = 1 / 298.257223563; // WGS-84 flattening
Expand Down Expand Up @@ -46,9 +50,12 @@ std::tuple<double, double, int> gpsToUTM(double lat, double lon) {
return std::make_tuple(easting, northing, zone);
}

std::tuple<double, double> gpsToGlobalCoord(double lat0, double lon0, double lat1, double lon1) {
inline std::tuple<double, double> gpsToGlobalCoord(double lat0, double lon0, double lat1, double lon1) {
// Convert latitude and longitude to utm coordinates
const auto& [e0, n0, zone0] = gpsToUTM(lat0, lon0);
const auto& [e1, n1, zone1] = gpsToUTM(lat1, lon1);
return {e1 - e0, n1 - n0};
}
}

#endif

0 comments on commit f2f5f6a

Please sign in to comment.