Main MRPT website > C++ reference for MRPT 1.5.6
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-2017, 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 
11 #include <mrpt/math/fresnel.h>
12 #include <mrpt/system/os.h>
13 #include <gtest/gtest.h>
14 #include <cmath>
15 
16 TEST(fresnel,fresnelc)
17 {
18  // fresnelc()
19  const double test_values[][2] = {
20  { 0.0, .0},
21  { 0.79788456080286541, 0.721705924292605 },
22  { 1.0, 0.779893400376823 },
23  { 0.4, 0.397480759172359 },
24  { 1.5, 0.445261176039822 },
25  { 2.0, 0.488253406075341 },
26  { 2.4, 0.554961405856428 },
27  { 3.34, 0.407099627096608 },
28  { 50.0, 0.499999189430728 },
29  { -0.4, -0.397480759172359 },
30  { -1.5, -0.445261176039822 },
31  { -2.0, -0.488253406075341 },
32  { -2.4, -0.554961405856428 },
33  { -3.34, -0.407099627096608 },
34  { -50.0, -0.499999189430728 }
35  };
36 
37  const unsigned int nTests = sizeof(test_values)/sizeof(test_values[0]);
38 
39  for (unsigned int i=0;i<nTests;i++)
40  {
41  const double x = test_values[i][0], val_good = test_values[i][1];
42  const double val = mrpt::math::fresnel_cos_integral(x);
43  EXPECT_NEAR(val, val_good, 1e-5) << " x: " << x << "\n val_good: " << val_good << "\n val: " << val << "\n";
44  }
45 }
46 
47 TEST(fresnel, fresnels)
48 {
49  // fresnelc()
50  const double test_values[][2] = {
51  { 0.0, .0 },
52  { 1.0, 0.438259147390355 },
53  { 1.5, 0.697504960082093 },
54  { 2.4, 0.619689964945684 },
55  { 50.0, 0.493633802585939 },
56  { -2.0, -0.343415678363698 },
57  { -2.4, -0.619689964945684 },
58  { -3.34, -0.479600423968308 },
59  { -50.0, -0.493633802585939 }
60  };
61 
62  const unsigned int nTests = sizeof(test_values) / sizeof(test_values[0]);
63 
64  for (unsigned int i = 0; i<nTests; i++)
65  {
66  const double x = test_values[i][0], val_good = test_values[i][1];
67  const double val = mrpt::math::fresnel_sin_integral(x);
68  EXPECT_NEAR(val, val_good, 1e-5) << " x: " << x << "\n val_good: " << val_good << "\n val: " << val << "\n";
69  }
70 }
double BASE_IMPEXP fresnel_cos_integral(double x) MRPT_NO_THROWS
Evaluates the integral from 0 to x of sqrt(2/pi) cos(t^2) dt.
Definition: fresnel.cpp:73
TEST(fresnel, fresnelc)
GLint GLint GLint GLint GLint x
Definition: glew.h:1166
double BASE_IMPEXP fresnel_sin_integral(double x) MRPT_NO_THROWS
Evaluates the integral from 0 to x of sqrt(2/pi) sin(t^2) dt.
Definition: fresnel.cpp:68
GLuint GLfloat * val
Definition: glew.h:7785



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018