mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-peak.git
synced 2025-06-12 02:45:59 +00:00
Added clip for integers and updated attitude from tilt
This commit is contained in:
parent
315abe5d6f
commit
6350091baf
@ -9,6 +9,8 @@ namespace sta
|
|||||||
{
|
{
|
||||||
float fast_inv_sqrt(float);
|
float fast_inv_sqrt(float);
|
||||||
|
|
||||||
|
int clip(int value, int min, int max);
|
||||||
|
|
||||||
float clip(float value, float min, float max);
|
float clip(float value, float min, float max);
|
||||||
} // namespace math
|
} // namespace math
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
@ -24,8 +24,8 @@ namespace sta
|
|||||||
az /= norm;
|
az /= norm;
|
||||||
}
|
}
|
||||||
|
|
||||||
float theta = std::atan(ay / az);
|
float theta = std::atan2(ay, az);
|
||||||
float phi = std::atan(-ax / std::sqrt(ay*ay + az*az));
|
float phi = std::atan2(-ax, std::sqrt(ay*ay + az*az));
|
||||||
|
|
||||||
Quaternion tilt(
|
Quaternion tilt(
|
||||||
std::cos(phi / 2.0f) * std::cos(theta / 2.0f),
|
std::cos(phi / 2.0f) * std::cos(theta / 2.0f),
|
||||||
|
@ -22,6 +22,21 @@ namespace sta
|
|||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int clip(int value, int min, int max)
|
||||||
|
{
|
||||||
|
if (value < min)
|
||||||
|
{
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value > max)
|
||||||
|
{
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
float clip(float value, float min, float max)
|
float clip(float value, float min, float max)
|
||||||
{
|
{
|
||||||
if (value < min)
|
if (value < min)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user