mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 17:13:33 +08:00
30 lines
334 B
C++
30 lines
334 B
C++
#pragma once
|
|
|
|
#include "math.hpp"
|
|
#include <math.h>
|
|
|
|
|
|
namespace matrix
|
|
{
|
|
template<typename Type>
|
|
float wrap_pi(Type x)
|
|
{
|
|
if (!isfinite(x)) {
|
|
return x;
|
|
}
|
|
|
|
while (x >= (Type)M_PI) {
|
|
x -= (Type)(2.0 * M_PI);
|
|
|
|
}
|
|
|
|
while (x < (Type)(-M_PI)) {
|
|
x += (Type)(2.0 * M_PI);
|
|
|
|
}
|
|
|
|
return x;
|
|
}
|
|
|
|
|
|
}; |