helper.h
Go to the documentation of this file.
1 /******************************************************************************
2  STDR Simulator - Simple Two DImensional Robot Simulator
3  Copyright (C) 2013 STDR Simulator
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 
16  Authors :
17  * Manos Tsardoulias, etsardou@gmail.com
18  * Aris Thallas, aris.thallas@gmail.com
19  * Chris Zalidis, zalidis@gmail.com
20 ******************************************************************************/
21 
22 #ifndef HELPER_H
23 #define HELPER_H
24 
25 
26 #define PI 3.141592653589793
27 
28 namespace stdr_robot {
29 
37  static bool angCheck(float target_, float min_, float max_)
38  {
39  int c = 0;
40  c = (target_ + 2 * PI) / (2 * PI);
41  float target = target_ + (1 - c) * PI * 2;
42  c = (min_ + 2 * PI) / (2 * PI);
43  float min = min_ + (1 - c) * PI * 2;
44  c = (max_ + 2 * PI) / (2 * PI);
45  float max = max_ + (1 - c) * PI * 2;
46 
47  if(min_ * max_ > 0)
48  {
49  if(target > min && target < max)
50  {
51  return true;
52  }
53  }
54  else
55  {
56  max += 2 * PI;
57  if(target > min && target < max)
58  {
59  return true;
60  }
61  target += 2 * PI;
62  if(target > min && target < max)
63  {
64  return true;
65  }
66  }
67  return false;
68  }
69 
70 } // namespace stdr_robot
71 
72 #endif
The main namespace for STDR Robot.
Definition: exceptions.h:27
static bool angCheck(float target_, float min_, float max_)
Checks if an angle is between two others. Supposes that min < max.
Definition: helper.h:37
#define PI
Definition: helper.h:26
int min(int a, int b)


stdr_robot
Author(s): Manos Tsardoulias, Chris Zalidis, Aris Thallas
autogenerated on Mon Jun 10 2019 15:15:10