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