13 #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);
33 bool atan2_lut_valid = atan2lut.atan2(
y,
x, atan2_lut);
35 EXPECT_TRUE(atan2_lut_valid);
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);