12 #include <gtest/gtest.h> 16 template <
class LUT_CLASS>
17 void atan2_lut_test(
const LUT_CLASS & atan2lut,
const double SIZE,
const double max_deg_errors,
const double skip_area)
19 for (
int i=0;i<1000;i++)
25 if (std::abs(
x)<skip_area || std::abs(
y)<skip_area)
28 const double atan2_good = ::atan2(
y,
x);
30 bool atan2_lut_valid = atan2lut.atan2(
y,
x,atan2_lut);
32 EXPECT_TRUE(atan2_lut_valid);
33 EXPECT_LT(std::abs(atan2_good-atan2_lut),
mrpt::utils::DEG2RAD(max_deg_errors) ) <<
"(x,y): ("<<
x <<
" , " <<
y <<
")" <<
"\natan2_good:" << atan2_good <<
" atan2_lut:" << atan2_lut << std::endl;
37 TEST(CAtan2LookUpTable,ValidValidTest)
39 const double SIZE = 20.0;
40 const double RES = 0.10;
45 TEST(CAtan2LookUpTable,MultiResTest)
47 const double SIZE = 20.0;
50 std::map<double,double> res2extension;
51 res2extension[0.001] = 0.8;
52 res2extension[0.01] = 2.0;
53 res2extension[0.02] = 5.0;
54 res2extension[0.05] = 11.0;
55 atan2lut.
resize(res2extension);
double drawUniform(const double Min, const double Max)
Generate a uniformly distributed pseudo-random number using the MT19937 algorithm, scaled to the selected range.
BASE_IMPEXP CRandomGenerator randomGenerator
A static instance of a CRandomGenerator class, for use in single-thread applications.
TEST(CAtan2LookUpTable, ValidValidTest)
A look-up-table (LUT) of atan values for any (x,y) value in a square/rectangular grid of predefined r...
Like CAtan2LookUpTable but with a multiresolution grid for increasingly better accuracy in points nea...
void atan2_lut_test(const LUT_CLASS &atan2lut, const double SIZE, const double max_deg_errors, const double skip_area)
double DEG2RAD(const double x)
Degrees to radians.
void resize(const std::map< double, double > &lst_resolutions2extensions) MRPT_NO_THROWS
See CAtan2LookUpTableMultiRes for a discussion of the parameters.