Player
Frontpage
Contents
User
Installation
Quick start
Supported devices
Tutorials
Utilities
Client libraries
FAQ
Help
Developer
Architecture
libplayercore
interfaces
libplayerdrivers
drivers
libplayercommon
libplayerutils
libplayersd
libplayertcp
libplayerxdr
TODO
Online
Homepage
Download
Project
Bugs
Help
client_libs
libplayerc++
utility.h
1
/*
2
* Player - One Hell of a Robot Server
3
* Copyright (C) 2000-2003
4
* Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
5
*
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
*
21
*/
22
/********************************************************************
23
*
24
* This library is free software; you can redistribute it and/or
25
* modify it under the terms of the GNU Lesser General Public
26
* License as published by the Free Software Foundation; either
27
* version 2.1 of the License, or (at your option) any later version.
28
*
29
* This library is distributed in the hope that it will be useful,
30
* but WITHOUT ANY WARRANTY; without even the implied warranty of
31
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32
* Lesser General Public License for more details.
33
*
34
* You should have received a copy of the GNU Lesser General Public
35
* License along with this library; if not, write to the Free Software
36
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37
*
38
********************************************************************/
39
40
/***************************************************************************
41
* Desc: Player v2.0 C++ client
42
* Authors: Brad Kratochvil, Toby Collett
43
*
44
* Date: 23 Sep 2005
45
# CVS: $Id: utility.h 7342 2009-02-18 03:43:36Z gbiggs $
46
**************************************************************************/
47
48
49
#ifndef PLAYERCC_UTILITY_H
50
#define PLAYERCC_UTILITY_H
51
namespace
PlayerCc
52
{
60
const
int
PLAYER_PORTNUM
= 6665;
63
const
std::string
PLAYER_HOSTNAME
=
"localhost"
;
64
65
// Since they are inline, these functions are as efficient as DEFINES,
66
// but now they have the benefit of type checking!
67
69
inline
double
rtod
(
double
r)
70
{
71
return
r * 180.0 / M_PI;
72
}
73
75
inline
double
dtor
(
double
r)
76
{
77
return
r * M_PI / 180.0;
78
}
79
81
inline
double
normalize
(
double
z)
82
{
83
return
atan2(sin(z), cos(z));
84
}
85
87
#if defined (min)
88
#undef min
89
#endif
90
template
<
typename
T>
91
inline
T
min
(T a, T b)
92
{
93
if
(a < b)
94
return
a;
95
else
96
return
b;
97
}
98
100
#if defined (max)
101
#undef max
102
#endif
103
template
<
typename
T>
104
inline
T
max
(T a, T b)
105
{
106
if
(a > b)
107
return
a;
108
else
109
return
b;
110
}
111
113
template
<
typename
T>
114
inline
T
limit
(T a, T
min
, T
max
)
115
{
116
if
(a < min)
117
return
min
;
118
else
if
(a > max)
119
return
max
;
120
else
121
return
a;
122
}
123
126
}
// namespace
127
128
#endif
129
Last updated 12 September 2005 21:38:45