38 float dlat = (float)(loc2.
lat - loc1.
lat);
52 return norm(destination.
x-origin.
x,destination.
y-origin.
y);
58 int32_t off_x = loc2.
lng - loc1.
lng;
61 if (bearing < 0) bearing += 36000;
100 float dsquared =
sq(vec1.
x) +
sq(vec1.
y);
101 if (dsquared < 0.001
f) {
105 return (vec1 * vec2) / dsquared;
153 (loc1.
alt - loc2.
alt) * 0.01f);
160 return (loc1.
lat == loc2.
lat) && (loc1.
lng == loc2.
lng);
168 bool has_changed =
false;
170 if (loc.
lat == 0 && loc.
lng == 0) {
198 int32_t dec_portion, frac_portion;
199 int32_t abs_lat_or_lon = labs(lat_or_lon);
202 dec_portion = abs_lat_or_lon / 10000000UL;
205 frac_portion = abs_lat_or_lon - dec_portion*10000000UL;
208 if( lat_or_lon < 0 ) {
211 s->
printf(
"%ld.%07ld",(
long)dec_portion,(
long)frac_portion);
217 return fabsf(lat) <= 90;
221 return fabsf(lng) <= 180;
225 return labs(lat) <= 90*1e7;
229 return labs(lng) <= 180*1e7;
float norm(const T first, const U second, const Params... parameters)
#define LOCATION_SCALING_FACTOR
void location_update(struct Location &loc, float bearing, float distance)
Vector2< float > Vector2f
Vector3< float > Vector3f
float location_path_proportion(const struct Location &location, const struct Location &point1, const struct Location &point2)
float get_distance(const struct Location &loc1, const struct Location &loc2)
float longitude_scale(const struct Location &loc)
bool check_lng(float lng)
void location_offset(struct Location &loc, float ofs_north, float ofs_east)
int32_t lat
param 3 - Latitude * 10**7
int32_t get_bearing_cd(const struct Location &loc1, const struct Location &loc2)
uint32_t get_distance_cm(const struct Location &loc1, const struct Location &loc2)
virtual void printf(const char *,...) FMT_PRINTF(2
Vector2f location_diff(const struct Location &loc1, const struct Location &loc2)
float get_horizontal_distance_cm(const Vector3f &origin, const Vector3f &destination)
int32_t alt
param 2 - Altitude in centimeters (meters * 100) see LOCATION_ALT_MAX_M
bool is_zero(const T fVal1)
bool check_latlng(float lat, float lng)
#define LOCATION_SCALING_FACTOR_INV
Location_Option_Flags flags
options bitmask (1<<0 = relative altitude)
bool check_lat(float lat)
float constrain_float(const float amt, const float low, const float high)
int32_t lng
param 4 - Longitude * 10**7
Vector3f location_3d_diff_NED(const struct Location &loc1, const struct Location &loc2)
static constexpr float radians(float deg)
bool location_sanitize(const struct Location &defaultLoc, struct Location &loc)
bool location_passed_point(const struct Location &location, const struct Location &point1, const struct Location &point2)
void print_latlon(AP_HAL::BetterStream *s, int32_t lat_or_lon)
bool locations_are_same(const struct Location &loc1, const struct Location &loc2)