Prior to this commit, the range of the function was -M_PI/2 to M_PI*3/2 (-90 to 270 degrees).
This adjust the function range to be -M_PI to M_PI (-180 to 180 degrees)
This makes the function consistent with methods such as "get_bearing_cd"
Co-authored-by: Leonard Hall <leonardthall@gmail.com>
Most `radians` uses give a float argument and use a float return type.
On `HAL_WITH_EKF_DOUBLE` boards this results in a bunch of unnecessary
conversions. Create separate double and float variants of the function
to eliminate the impact. The `DEG_TO_RAD` constant is already a float,
therefore there is no loss of precision in the operation.
We also need a variant that takes an `int` argument as these are
supplied in several places, primarily as constants, and the `int`
conversion is otherwise ambiguous.
Saves a few hundred bytes of flash on such boards.
The cross-product code can produce something slightly negative. Fix
safe_sqrt to avoid barfing on that, as was originally intended, and
clarify why it's being used.
Co-authored-by: Leonard Hall <leonardthall@gmail.com>
Co-authored-by: Thomas Watson <twatson52@icloud.com>
2024-08-08T01:51:53.6780446Z ../../libraries/AP_Math/vector3.cpp:432:9: warning: absolute value function 'fabsf' given an argument of type 'const double' but has parameter of type 'float' which may cause truncation of value [-Wabsolute-value]
2024-08-08T01:51:53.6781336Z if (fabsF(cosv) >= 1) {
2024-08-08T01:51:53.6781583Z ^
2024-08-08T01:51:53.6781930Z ../../libraries/AP_Math/ftype.h:50:18: note: expanded from macro 'fabsF'
2024-08-08T01:51:53.6782342Z #define fabsF(x) fabsf(x)
2024-08-08T01:51:53.6782572Z ^
2024-08-08T01:51:53.6789178Z ../../libraries/AP_Math/vector3.cpp:633:16: note: in instantiation of member function 'Vector3<double>::angle' requested here
2024-08-08T01:51:53.6789800Z template class Vector3<double>;
remove the metho operator from the class.
This means this will no longer work:
Quaternion q{0,1,2,3};
q(5,6,7,8);
.... that used to set the quaternion componets, but is an odd / atypical syntax to use