All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Angle.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 _IGNITION_ANGLE_HH_
18 #define _IGNITION_ANGLE_HH_
19 
20 #include <iostream>
21 #include <ignition/math/Helpers.hh>
22 
26 #define IGN_RTOD(r) ((r) * 180 / IGN_PI)
27 
31 #define IGN_DTOR(d) ((d) * IGN_PI / 180)
32 
36 #define IGN_NORMALIZE(a) (atan2(sin(a), cos(a)))
37 
38 namespace ignition
39 {
40  namespace math
41  {
45  {
47  public: static const Angle Zero;
48 
50  public: static const Angle Pi;
51 
53  public: static const Angle HalfPi;
54 
56  public: static const Angle TwoPi;
57 
59  public: Angle();
60 
63  public: Angle(double _radian);
64 
67  public: Angle(const Angle &_angle);
68 
70  public: virtual ~Angle();
71 
74  public: void Radian(double _radian);
75 
78  public: void Degree(double _degree);
79 
82  public: double Radian() const;
83 
86  public: double Degree() const;
87 
89  public: void Normalize();
90 
93  public: double operator()() const;
94 
97  public: inline double operator*() const
98  {
99  return value;
100  }
101 
105  public: Angle operator-(const Angle &_angle) const;
106 
110  public: Angle operator+(const Angle &_angle) const;
111 
115  public: Angle operator*(const Angle &_angle) const;
116 
120  public: Angle operator/(const Angle &_angle) const;
121 
125  public: Angle operator-=(const Angle &_angle);
126 
130  public: Angle operator+=(const Angle &_angle);
131 
135  public: Angle operator*=(const Angle &_angle);
136 
140  public: Angle operator/=(const Angle &_angle);
141 
145  public: bool operator==(const Angle &_angle) const;
146 
150  public: bool operator!=(const Angle &_angle) const;
151 
155  public: bool operator<(const Angle &_angle) const;
156 
160  public: bool operator<=(const Angle &_angle) const;
161 
165  public: bool operator>(const Angle &_angle) const;
166 
170  public: bool operator>=(const Angle &_angle) const;
171 
176  public: friend std::ostream &operator<<(std::ostream &_out,
177  const ignition::math::Angle &_a)
178  {
179  _out << _a.Radian();
180  return _out;
181  }
182 
187  public: friend std::istream &operator>>(std::istream &_in,
189  {
190  // Skip white spaces
191  _in.setf(std::ios_base::skipws);
192  _in >> _a.value;
193  return _in;
194  }
195 
197  private: double value;
198  };
199  }
200 }
201 
202 #endif
An angle and related functions.
Definition: Angle.hh:44
#define IGNITION_VISIBLE
Use to represent &quot;symbol visible&quot; if supported.
Definition: Helpers.hh:408
static const Angle Zero
math::Angle(0)
Definition: Angle.hh:47
friend std::ostream & operator<<(std::ostream &_out, const ignition::math::Angle &_a)
Stream insertion operator.
Definition: Angle.hh:176
double operator*() const
Dereference operator.
Definition: Angle.hh:97
static const Angle TwoPi
math::Angle(IGN_PI * 2)
Definition: Angle.hh:56
static const Angle HalfPi
math::Angle(IGN_PI * 0.5)
Definition: Angle.hh:53
void Radian(double _radian)
Set the value from an angle in radians.
friend std::istream & operator>>(std::istream &_in, ignition::math::Angle &_a)
Stream extraction operator.
Definition: Angle.hh:187
static const Angle Pi
math::Angle(IGN_PI)
Definition: Angle.hh:50