Fawkes API  Fawkes Development Version
qa_angle.cpp
1 
2 /***************************************************************************
3  * qa_angle.cpp - angle QA app
4  *
5  * Created: Mon Jun 18 15:54:55
6  * Copyright 2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <utils/math/angle.h>
25 #include <cstdio>
26 
27 using namespace fawkes;
28 
29 int
30 main(int argc, char **argv)
31 {
32  float f = -2 * M_PI;
33  float fnm = normalize_mirror_rad(f);
34  float expd = 0;
35  printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
36 
37  f = 2 * M_PI;
38  fnm = normalize_mirror_rad(f);
39  expd = 0;
40  printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
41 
42 
43  f = 2 * M_PI + 1;
44  fnm = normalize_mirror_rad(f);
45  expd = 1;
46  printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
47 
48 
49  f = - 2 * M_PI - 1.4;
50  fnm = normalize_mirror_rad(f);
51  expd = -1.4;
52  printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
53 
54 
55  f = - 2 * M_PI - 2.9;
56  fnm = normalize_mirror_rad(f);
57  expd = -2.9;
58  printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
59 
60 
61  f = - 3 * M_PI - 1;
62  fnm = normalize_mirror_rad(f);
63  expd = f + 4 * M_PI;
64  printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
65 
66 
67  f = -M_PI;
68  float fnr = normalize_rad(f);
69  expd = M_PI;
70  printf("f=%f normalize_rad(f)=%f expected=%f\n", f, fnr, expd);
71 
72  f = 3 * M_PI;
73  fnr = normalize_rad(f);
74  expd = M_PI;
75  printf("f=%f normalize_rad(f)=%f expected=%f\n", f, fnr, expd);
76 
77  f = - 3 * M_PI;
78  fnr = normalize_rad(f);
79  expd = M_PI;
80  printf("f=%f normalize_rad(f)=%f expected=%f\n", f, fnr, expd);
81 
82  f = - 2 * M_PI - 1;
83  fnr = normalize_rad(f);
84  expd = 2 * M_PI - 1;
85  printf("f=%f normalize_rad(f)=%f expected=%f\n", f, fnr, expd);
86 
87  f = 10 * M_PI;
88  fnr = normalize_rad(f);
89  expd = 0;
90  printf("f=%f normalize_rad(f)=%f expected=%f\n", f, fnr, expd);
91 
92  return 0;
93 }
float normalize_rad(float angle_rad)
Normalize angle in radian between 0 (inclusive) and 2*PI (exclusive).
Definition: angle.h:93
Fawkes library namespace.
float normalize_mirror_rad(float angle_rad)
Normalize angle in radian between -PI (inclusive) and PI (exclusive).
Definition: angle.h:75