10 #include <gtest/gtest.h> 16 template <
class LUT_CLASS>
18 const LUT_CLASS& atan2lut,
const double SIZE,
const double max_deg_errors,
19 const double skip_area)
21 for (
int i = 0; i < 1000; i++)
24 -.5 * SIZE, .5 * SIZE);
26 -.5 * SIZE, .5 * SIZE);
29 if (std::abs(x) < skip_area || std::abs(y) < skip_area)
continue;
31 const double atan2_good = ::atan2(y, x);
32 double atan2_lut = .0;
33 bool atan2_lut_valid = atan2lut.atan2(y, x, atan2_lut);
37 std::abs(atan2_good - atan2_lut),
mrpt::DEG2RAD(max_deg_errors))
38 <<
"(x,y): (" << x <<
" , " << y <<
")" 39 <<
"\natan2_good:" << atan2_good <<
" atan2_lut:" << atan2_lut
44 TEST(CAtan2LookUpTable, ValidValidTest)
46 const double SIZE = 20.0;
47 const double RES = 0.10;
49 -.5 * SIZE, .5 * SIZE, -.5 * SIZE, .5 * SIZE, RES);
53 TEST(CAtan2LookUpTable, MultiResTest)
55 const double SIZE = 20.0;
58 std::map<double, double> res2extension;
59 res2extension[0.001] = 0.8;
60 res2extension[0.01] = 2.0;
61 res2extension[0.02] = 5.0;
62 res2extension[0.05] = 11.0;
63 atan2lut.
resize(res2extension);
EXPECT_LT(out.final_rmse, 3.0)
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
TEST(CAtan2LookUpTable, ValidValidTest)
void resize(const std::map< double, double > &lst_resolutions2extensions) noexcept
See CAtan2LookUpTableMultiRes for a discussion of the parameters.
A look-up-table (LUT) of atan values for any (x,y) value in a square/rectangular grid of predefined r...
return_t drawUniform(const double Min, const double Max)
Generate a uniformly distributed pseudo-random number using the MT19937 algorithm, scaled to the selected range.
constexpr double DEG2RAD(const double x)
Degrees to radians.
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)
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.