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
26#include <cstdio>
27
28using namespace fawkes;
29
30int
31main(int argc, char **argv)
32{
33 float f = -2 * M_PI;
34 float fnm = normalize_mirror_rad(f);
35 float expd = 0;
36 printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
37
38 f = 2 * M_PI;
39 fnm = normalize_mirror_rad(f);
40 expd = 0;
41 printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
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 f = -2 * M_PI - 1.4;
49 fnm = normalize_mirror_rad(f);
50 expd = -1.4;
51 printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
52
53 f = -2 * M_PI - 2.9;
54 fnm = normalize_mirror_rad(f);
55 expd = -2.9;
56 printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
57
58 f = -3 * M_PI - 1;
59 fnm = normalize_mirror_rad(f);
60 expd = f + 4 * M_PI;
61 printf("f=%f normalize_mirror_rad(f)=%f expected=%f\n", f, fnm, expd);
62
63 f = -M_PI;
64 float fnr = normalize_rad(f);
65 expd = M_PI;
66 printf("f=%f normalize_rad(f)=%f expected=%f\n", f, fnr, expd);
67
68 f = 3 * M_PI;
69 fnr = normalize_rad(f);
70 expd = M_PI;
71 printf("f=%f normalize_rad(f)=%f expected=%f\n", f, fnr, expd);
72
73 f = -3 * M_PI;
74 fnr = normalize_rad(f);
75 expd = M_PI;
76 printf("f=%f normalize_rad(f)=%f expected=%f\n", f, fnr, expd);
77
78 f = -2 * M_PI - 1;
79 fnr = normalize_rad(f);
80 expd = 2 * M_PI - 1;
81 printf("f=%f normalize_rad(f)=%f expected=%f\n", f, fnr, expd);
82
83 f = 10 * M_PI;
84 fnr = normalize_rad(f);
85 expd = 0;
86 printf("f=%f normalize_rad(f)=%f expected=%f\n", f, fnr, expd);
87
88 return 0;
89}
Fawkes library namespace.
float normalize_mirror_rad(float angle_rad)
Normalize angle in radian between -PI (inclusive) and PI (exclusive).
Definition: angle.h:72
float normalize_rad(float angle_rad)
Normalize angle in radian between 0 (inclusive) and 2*PI (exclusive).
Definition: angle.h:90