2 changed files with 21 additions and 0 deletions
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
#include "AP_Math.h" |
||||
|
||||
// a varient of asin() that checks the input ranges and ensures a
|
||||
// valid angle as output. If nan is given as input then zero is
|
||||
// returned.
|
||||
float safe_asin(float v) |
||||
{ |
||||
if (isnan(v)) { |
||||
return 0; |
||||
} |
||||
if (v >= 1.0) { |
||||
return PI/2; |
||||
} |
||||
if (v <= -1.0) { |
||||
return -PI/2; |
||||
} |
||||
return asin(v); |
||||
} |
Loading…
Reference in new issue