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 7342 2009-02-18 03:43:36Z gbiggs $ 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 #if defined (min) 00088 #undef min 00089 #endif 00090 template<typename T> 00091 inline T min(T a, T b) 00092 { 00093 if (a < b) 00094 return a; 00095 else 00096 return b; 00097 } 00098 00100 #if defined (max) 00101 #undef max 00102 #endif 00103 template<typename T> 00104 inline T max(T a, T b) 00105 { 00106 if (a > b) 00107 return a; 00108 else 00109 return b; 00110 } 00111 00113 template<typename T> 00114 inline T limit(T a, T min, T max) 00115 { 00116 if (a < min) 00117 return min; 00118 else if (a > max) 00119 return max; 00120 else 00121 return a; 00122 } 00123 00126 } // namespace 00127 00128 #endif 00129