mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-26 17:53:59 -04:00
AP_Common: move get_bearing_cd to Location and rename to get_bearing_to
This commit is contained in:
parent
5ac19bc5a3
commit
6faf1d2849
@ -270,3 +270,16 @@ bool Location::sanitize(const Location &defaultLoc)
|
|||||||
|
|
||||||
// make sure we know what size the Location object is:
|
// make sure we know what size the Location object is:
|
||||||
assert_storage_size<Location, 16> _assert_storage_size_Location;
|
assert_storage_size<Location, 16> _assert_storage_size_Location;
|
||||||
|
|
||||||
|
|
||||||
|
// return bearing in centi-degrees from location to loc2
|
||||||
|
int32_t Location::get_bearing_to(const struct Location &loc2) const
|
||||||
|
{
|
||||||
|
const int32_t off_x = loc2.lng - lng;
|
||||||
|
const int32_t off_y = (loc2.lat - lat) / loc2.longitude_scale();
|
||||||
|
int32_t bearing = 9000 + atan2f(-off_y, off_x) * DEGX100;
|
||||||
|
if (bearing < 0) {
|
||||||
|
bearing += 36000;
|
||||||
|
}
|
||||||
|
return bearing;
|
||||||
|
}
|
||||||
|
@ -85,6 +85,9 @@ public:
|
|||||||
|
|
||||||
void zero(void);
|
void zero(void);
|
||||||
|
|
||||||
|
// return bearing in centi-degrees from location to loc2
|
||||||
|
int32_t get_bearing_to(const struct Location &loc2) const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* convert invalid waypoint with useful data. return true if location changed
|
* convert invalid waypoint with useful data. return true if location changed
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user