Line data Source code
1 : #pragma once 2 : 3 : #include <inttypes.h> 4 : 5 : #include "vector2.h" 6 : #include "vector3.h" 7 : 8 : /* 9 : * LOCATION 10 : */ 11 : 12 : // Computes straight-line distance in the horizontal plane between two positions. 13 : // Input units (e.g., meters, centimeters) must match; no unit conversion is performed. 14 : template <typename T> 15 201879 : float get_horizontal_distance(const Vector2<T> &origin, const Vector2<T> &destination) 16 : { 17 201879 : return (destination - origin).length(); 18 : } 19 : 20 : // return bearing in radians between two positions 21 : float get_bearing_rad(const Vector2f &origin, const Vector2f &destination); 22 : 23 : // return bearing in centi-degrees between two positions 24 : float get_bearing_cd(const Vector2f &origin, const Vector2f &destination); 25 : 26 : // Converts from WGS84 geodetic coordinates (lat, lon, height) 27 : // into WGS84 Earth Centered, Earth Fixed (ECEF) coordinates 28 : // (X, Y, Z) 29 : void wgsllh2ecef(const Vector3d &llh, Vector3d &ecef); 30 : 31 : // Converts from WGS84 Earth Centered, Earth Fixed (ECEF) 32 : // coordinates (X, Y, Z), into WHS84 geodetic 33 : // coordinates (lat, lon, height) 34 : void wgsecef2llh(const Vector3d &ecef, Vector3d &llh); 35 : 36 : // return true when lat and lng are within range 37 : bool check_lat(float lat) WARN_IF_UNUSED; 38 : bool check_lng(float lng) WARN_IF_UNUSED; 39 : bool check_lat(int32_t lat) WARN_IF_UNUSED; 40 : bool check_lng(int32_t lng) WARN_IF_UNUSED; 41 : bool check_latlng(float lat, float lng) WARN_IF_UNUSED; 42 : bool check_latlng(int32_t lat, int32_t lng) WARN_IF_UNUSED;