Gazebo Math
API Reference
7.5.1
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-math
include
gz
math
gz/math/Angle.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2012 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
#ifndef GZ_MATH_ANGLE_HH_
18
#define GZ_MATH_ANGLE_HH_
19
20
#include <istream>
21
#include <ostream>
22
#include <
gz/math/Helpers.hh
>
23
#include <gz/math/config.hh>
24
29
#define GZ_RTOD(r) ((r) * 180 / GZ_PI)
30
35
#define GZ_DTOR(d) ((d) * GZ_PI / 180)
36
41
#define GZ_NORMALIZE(a) (atan2(sin(a), cos(a)))
42
43
namespace
gz::math
44
{
45
// Inline bracket to help doxygen filtering.
46
inline
namespace
GZ_MATH_VERSION_NAMESPACE {
47
//
60
class
GZ_MATH_VISIBLE
Angle
61
{
64
public
:
static
const
Angle
&
Zero
;
65
68
public
:
static
const
Angle
&
Pi
;
69
72
public
:
static
const
Angle
&
HalfPi
;
73
76
public
:
static
const
Angle
&
TwoPi
;
77
80
public
:
Angle
() =
default
;
81
89
//
91
// cppcheck-suppress noExplicitConstructor
92
public
: constexpr
Angle
(
double
_radian)
93
: value(_radian)
94
{
95
}
96
100
public
:
void
GZ_DEPRECATED(7) Radian(
double
_radian);
101
104
public:
void
SetRadian(
double
_radian);
105
109
public:
void
GZ_DEPRECATED(7) Degree(
double
_degree);
110
113
public:
void
SetDegree(
double
_degree);
114
117
public:
double
Radian() const;
118
121
public:
double
Degree() const;
122
126
public:
void
Normalize();
127
131
public:
Angle
Normalized() const;
132
135
public:
double
operator()() const;
136
139
public: inline
double
operator*()
const
140
{
141
return
value;
142
}
143
147
public
:
Angle
operator-(
const
Angle
&_angle)
const
;
148
152
public
:
Angle
operator+(
const
Angle
&_angle)
const
;
153
157
public
:
Angle
operator*(
const
Angle
&_angle)
const
;
158
162
public
:
Angle
operator/(
const
Angle
&_angle)
const
;
163
167
public
:
Angle
operator-=(
const
Angle
&_angle);
168
172
public
:
Angle
operator+=(
const
Angle
&_angle);
173
177
public
:
Angle
operator*=(
const
Angle
&_angle);
178
182
public
:
Angle
operator/=(
const
Angle
&_angle);
183
187
public
:
bool
operator==(
const
Angle
&_angle)
const
;
188
192
public
:
bool
operator!=(
const
Angle
&_angle)
const
;
193
197
public
:
bool
operator<(
const
Angle
&_angle)
const
;
198
202
public
:
bool
operator<=(
const
Angle
&_angle)
const
;
203
207
public
:
bool
operator>(
const
Angle
&_angle)
const
;
208
212
public
:
bool
operator>=(
const
Angle
&_angle)
const
;
213
218
public
:
friend
std::ostream
&
operator<<
(
std::ostream
&_out,
219
const
gz::math::Angle
&_a)
220
{
221
_out << _a.
Radian
();
222
return
_out;
223
}
224
229
public
:
friend
std::istream
&
operator>>
(
std::istream
&_in,
230
gz::math::Angle
&_a)
231
{
232
// Skip white spaces
233
_in.
setf
(std::ios_base::skipws);
234
_in >> _a.value;
235
return
_in;
236
}
237
239
private
:
double
value{0};
240
};
241
}
// namespace GZ_MATH_VERSION_NAMESPACE
242
}
// namespace gz::math
243
244
#endif // GZ_MATH_ANGLE_HH_