helper.h
Go to the documentation of this file.
00001 /******************************************************************************
00002    STDR Simulator - Simple Two DImensional Robot Simulator
00003    Copyright (C) 2013 STDR Simulator
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 3 of the License, or
00007    (at your option) any later version.
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software Foundation,
00014    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015    
00016    Authors : 
00017    * Manos Tsardoulias, etsardou@gmail.com
00018    * Aris Thallas, aris.thallas@gmail.com
00019    * Chris Zalidis, zalidis@gmail.com 
00020 ******************************************************************************/
00021 
00022 #ifndef HELPER_H
00023 #define HELPER_H
00024 
00025 
00026 #define PI 3.141592653589793
00027 
00028 namespace stdr_robot {
00029 
00037   static bool angCheck(float target_, float min_, float max_) 
00038   {
00039     int c = 0;
00040     c = (target_ + 2 * PI) / (2 * PI);
00041     float target = target_ + (1 - c) * PI * 2;
00042     c = (min_ + 2 * PI) / (2 * PI);
00043     float min = min_ + (1 - c) * PI * 2;
00044     c = (max_ + 2 * PI) / (2 * PI);
00045     float max = max_ + (1 - c) * PI * 2;
00046     
00047     if(min_ * max_ > 0) 
00048     {
00049       if(target > min && target < max)
00050       {
00051         return true;
00052       }
00053     }
00054     else
00055     {
00056       max += 2 * PI;
00057       if(target > min && target < max)
00058       {
00059         return true;
00060       }
00061       target += 2 * PI;
00062       if(target > min && target < max)
00063       {
00064         return true;
00065       }
00066     }
00067     return false;
00068   }
00069 
00070 }  // namespace stdr_robot
00071 
00072 #endif


stdr_robot
Author(s): Manos Tsardoulias, Chris Zalidis, Aris Thallas
autogenerated on Thu Jun 6 2019 18:57:28