mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-22 15:53:56 -04:00
Math: add wrap_PI
This commit is contained in:
parent
23ce35d292
commit
8b87849acd
@ -94,6 +94,11 @@ void location_offset(struct Location *loc, float ofs_north, float ofs_eas
|
|||||||
int32_t wrap_360_cd(int32_t error);
|
int32_t wrap_360_cd(int32_t error);
|
||||||
int32_t wrap_180_cd(int32_t error);
|
int32_t wrap_180_cd(int32_t error);
|
||||||
|
|
||||||
|
/*
|
||||||
|
wrap an angle defined in radians to -PI ~ PI (equivalent to +- 180 degrees)
|
||||||
|
*/
|
||||||
|
float wrap_PI(float angle_in_radians);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
print a int32_t lat/long in decimal degrees
|
print a int32_t lat/long in decimal degrees
|
||||||
*/
|
*/
|
||||||
|
@ -161,6 +161,15 @@ int32_t wrap_180_cd(int32_t error)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
wrap an angle defined in radians to -PI ~ PI (equivalent to +- 180 degrees)
|
||||||
|
*/
|
||||||
|
float wrap_PI(float angle_in_radians)
|
||||||
|
{
|
||||||
|
while (angle_in_radians > PI) angle_in_radians -= 2.0f*PI;
|
||||||
|
while (angle_in_radians < -PI) angle_in_radians += 2.0f*PI;
|
||||||
|
return angle_in_radians;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
print a int32_t lat/long in decimal degrees
|
print a int32_t lat/long in decimal degrees
|
||||||
|
Loading…
Reference in New Issue
Block a user