utility.h
00001 /* 00002 * Player - One Hell of a Robot Server 00003 * Copyright (C) 2000-2003 00004 * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 */ 00022 /******************************************************************** 00023 * 00024 * This library is free software; you can redistribute it and/or 00025 * modify it under the terms of the GNU Lesser General Public 00026 * License as published by the Free Software Foundation; either 00027 * version 2.1 of the License, or (at your option) any later version. 00028 * 00029 * This library is distributed in the hope that it will be useful, 00030 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00031 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00032 * Lesser General Public License for more details. 00033 * 00034 * You should have received a copy of the GNU Lesser General Public 00035 * License along with this library; if not, write to the Free Software 00036 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00037 * 00038 ********************************************************************/ 00039 00040 /*************************************************************************** 00041 * Desc: Player v2.0 C++ client 00042 * Authors: Brad Kratochvil, Toby Collett 00043 * 00044 * Date: 23 Sep 2005 00045 # CVS: $Id: utility.h 4100 2007-07-10 09:01:53Z thjc $ 00046 **************************************************************************/ 00047 00048 00049 #ifndef PLAYERCC_UTILITY_H 00050 #define PLAYERCC_UTILITY_H 00051 namespace PlayerCc 00052 { 00060 00061 const int PLAYER_PORTNUM = 6665; 00063 const std::string PLAYER_HOSTNAME = "localhost"; 00064 00065 // Since they are inline, these functions are as efficient as DEFINES, 00066 // but now they have the benefit of type checking! 00067 00069 inline double rtod(double r) 00070 { 00071 return r * 180.0 / M_PI; 00072 } 00073 00075 inline double dtor(double r) 00076 { 00077 return r * M_PI / 180.0; 00078 } 00079 00081 inline double normalize(double z) 00082 { 00083 return atan2(sin(z), cos(z)); 00084 } 00085 00087 template<typename T> 00088 inline T min(T a, T b) 00089 { 00090 if (a < b) 00091 return a; 00092 else 00093 return b; 00094 } 00095 00097 template<typename T> 00098 inline T max(T a, T b) 00099 { 00100 if (a > b) 00101 return a; 00102 else 00103 return b; 00104 } 00105 00107 template<typename T> 00108 inline T limit(T a, T min, T max) 00109 { 00110 if (a < min) 00111 return min; 00112 else if (a > max) 00113 return max; 00114 else 00115 return a; 00116 } 00117 00120 } // namespace 00121 00122 #endif 00123