MRPT  2.0.2
fresnel_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
11 #include <mrpt/math/fresnel.h>
12 #include <mrpt/system/os.h>
13 #include <cmath>
14 
15 TEST(fresnel, fresnelc)
16 {
17  // fresnelc()
18  const double test_values[][2] = {{0.0, .0},
19  {0.79788456080286541, 0.721705924292605},
20  {1.0, 0.779893400376823},
21  {0.4, 0.397480759172359},
22  {1.5, 0.445261176039822},
23  {2.0, 0.488253406075341},
24  {2.4, 0.554961405856428},
25  {3.34, 0.407099627096608},
26  {50.0, 0.499999189430728},
27  {-0.4, -0.397480759172359},
28  {-1.5, -0.445261176039822},
29  {-2.0, -0.488253406075341},
30  {-2.4, -0.554961405856428},
31  {-3.34, -0.407099627096608},
32  {-50.0, -0.499999189430728}};
33 
34  for (auto test_value : test_values)
35  {
36  const double x = test_value[0], val_good = test_value[1];
37  const double val = mrpt::math::fresnel_cos_integral(x);
38  EXPECT_NEAR(val, val_good, 1e-5)
39  << " x: " << x << "\n val_good: " << val_good << "\n val: " << val
40  << "\n";
41  }
42 }
43 
44 TEST(fresnel, fresnels)
45 {
46  // fresnelc()
47  const double test_values[][2] = {{0.0, .0},
48  {1.0, 0.438259147390355},
49  {1.5, 0.697504960082093},
50  {2.4, 0.619689964945684},
51  {50.0, 0.493633802585939},
52  {-2.0, -0.343415678363698},
53  {-2.4, -0.619689964945684},
54  {-3.34, -0.479600423968308},
55  {-50.0, -0.493633802585939}};
56 
57  for (auto test_value : test_values)
58  {
59  const double x = test_value[0], val_good = test_value[1];
60  const double val = mrpt::math::fresnel_sin_integral(x);
61  EXPECT_NEAR(val, val_good, 1e-5)
62  << " x: " << x << "\n val_good: " << val_good << "\n val: " << val
63  << "\n";
64  }
65 }
double fresnel_cos_integral(double x) noexcept
Evaluates the integral from 0 to x of sqrt(2/pi) cos(t^2) dt.
Definition: fresnel.cpp:74
TEST(fresnel, fresnelc)
int val
Definition: mrpt_jpeglib.h:957
double fresnel_sin_integral(double x) noexcept
Evaluates the integral from 0 to x of sqrt(2/pi) sin(t^2) dt.
Definition: fresnel.cpp:68
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)



Page generated by Doxygen 1.8.14 for MRPT 2.0.2 Git: 9b4fd2465 Mon May 4 16:59:08 2020 +0200 at lun may 4 17:26:07 CEST 2020