Main MRPT website > C++ reference for MRPT 1.9.9
fresnel_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <mrpt/math/fresnel.h>
11 #include <mrpt/system/os.h>
12 #include <gtest/gtest.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  const unsigned int nTests = sizeof(test_values) / sizeof(test_values[0]);
35 
36  for (unsigned int i = 0; i < nTests; i++)
37  {
38  const double x = test_values[i][0], val_good = test_values[i][1];
39  const double val = mrpt::math::fresnel_cos_integral(x);
40  EXPECT_NEAR(val, val_good, 1e-5)
41  << " x: " << x << "\n val_good: " << val_good << "\n val: " << val
42  << "\n";
43  }
44 }
45 
46 TEST(fresnel, fresnels)
47 {
48  // fresnelc()
49  const double test_values[][2] = {{0.0, .0},
50  {1.0, 0.438259147390355},
51  {1.5, 0.697504960082093},
52  {2.4, 0.619689964945684},
53  {50.0, 0.493633802585939},
54  {-2.0, -0.343415678363698},
55  {-2.4, -0.619689964945684},
56  {-3.34, -0.479600423968308},
57  {-50.0, -0.493633802585939}};
58 
59  const unsigned int nTests = sizeof(test_values) / sizeof(test_values[0]);
60 
61  for (unsigned int i = 0; i < nTests; i++)
62  {
63  const double x = test_values[i][0], val_good = test_values[i][1];
64  const double val = mrpt::math::fresnel_sin_integral(x);
65  EXPECT_NEAR(val, val_good, 1e-5)
66  << " x: " << x << "\n val_good: " << val_good << "\n val: " << val
67  << "\n";
68  }
69 }
os.h
fresnel.h
TEST
TEST(fresnel, fresnelc)
Definition: fresnel_unittest.cpp:15
val
int val
Definition: mrpt_jpeglib.h:955
mrpt::math::fresnel_sin_integral
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
mrpt::math::fresnel_cos_integral
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
x
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST