1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

OP-1309 turned boundf() static inline as requested

This commit is contained in:
Corvus Corax 2014-04-29 18:36:53 +02:00
parent 59bdab697a
commit 2f572995ac
2 changed files with 16 additions and 19 deletions

View File

@ -29,21 +29,4 @@
*/
// returns min(boundary1,boundary2) if val<min(boundary1,boundary2)
// returns max(boundary1,boundary2) if val>max(boundary1,boundary2)
// returns val if min(boundary1,boundary2)<=val<=max(boundary1,boundary2)
float boundf(float val, float boundary1, float boundary2)
{
if (boundary1 > boundary2) {
float tmp = boundary2;
boundary2 = boundary1;
boundary1 = tmp;
}
if (!(val >= boundary1)) {
val = boundary1;
}
if (!(val <= boundary2)) {
val = boundary2;
}
return val;
}
// space deliberately left empty, any non inline misc math functions can go here

View File

@ -34,6 +34,20 @@
// returns min(boundary1,boundary2) if val<min(boundary1,boundary2)
// returns max(boundary1,boundary2) if val>max(boundary1,boundary2)
// returns val if min(boundary1,boundary2)<=val<=max(boundary1,boundary2)
float boundf(float val, float boundary1, float boundary2);
static inline float boundf(float val, float boundary1, float boundary2)
{
if (boundary1 > boundary2) {
float tmp = boundary2;
boundary2 = boundary1;
boundary1 = tmp;
}
if (!(val >= boundary1)) {
val = boundary1;
}
if (!(val <= boundary2)) {
val = boundary2;
}
return val;
}
#endif /* MATHMISC_H */