mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
OP-1309 turned boundf() static inline as requested
This commit is contained in:
parent
59bdab697a
commit
2f572995ac
@ -29,21 +29,4 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// returns min(boundary1,boundary2) if val<min(boundary1,boundary2)
|
// space deliberately left empty, any non inline misc math functions can go here
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
@ -34,6 +34,20 @@
|
|||||||
// returns min(boundary1,boundary2) if val<min(boundary1,boundary2)
|
// returns min(boundary1,boundary2) if val<min(boundary1,boundary2)
|
||||||
// returns max(boundary1,boundary2) if val>max(boundary1,boundary2)
|
// returns max(boundary1,boundary2) if val>max(boundary1,boundary2)
|
||||||
// returns val if min(boundary1,boundary2)<=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 */
|
#endif /* MATHMISC_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user